blob: 2017c40181a3efd84d4108e16aff3de04b30ce70 [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 Rogersce9eca62011-10-07 17:11:03 -070055 /*
56 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
57 * exception is Thread::Current()->exception_
58 */
59.macro DELIVER_PENDING_EXCEPTION
60 SETUP_CALLEE_SAVE_FRAME @ save callee saves for throw
61 mov r0, r9 @ pass Thread::Current
62 mov r1, sp @ pass SP
63 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
64.endm
65
Ian Rogersff1ed472011-09-20 13:46:24 -070066 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070067 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070068 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
69 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
70 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070071 */
Ian Rogersff1ed472011-09-20 13:46:24 -070072art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070073 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070074 mov r1, r9 @ pass Thread::Current
75 mov r2, sp @ pass SP
76 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070077
78 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070079 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070080 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070081 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070082 */
83art_throw_null_pointer_exception_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 artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070088
89 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070090 .extern artThrowDivZeroFromCode
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 ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -070093 */
94art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070095 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070096 mov r0, r9 @ pass Thread::Current
97 mov r1, sp @ pass SP
98 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070099
100 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700101 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700102 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700103 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -0700104 */
105art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700106 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700107 mov r2, r9 @ pass Thread::Current
108 mov r3, sp @ pass SP
109 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -0700110
Ian Rogers932746a2011-09-22 18:57:50 -0700111 .global art_throw_stack_overflow_from_code
112 .extern artThrowStackOverflowFromCode
113art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700114 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700115 mov r1, r9 @ pass Thread::Current
116 mov r2, sp @ pass SP
117 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
118
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700119 .global art_throw_neg_array_size_from_code
120 .extern artThrowNegArraySizeFromCode
121art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700122 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700123 mov r1, r9 @ pass Thread::Current
124 mov r2, sp @ pass SP
125 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
126
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700127 .global art_throw_no_such_method_from_code
128 .extern artThrowNoSuchMethodFromCode
129art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700130 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700131 mov r1, r9 @ pass Thread::Current
132 mov r2, sp @ pass SP
133 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
134
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700135 .global art_throw_verification_error_from_code
136 .extern artThrowVerificationErrorFromCode
137art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700138 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700139 mov r2, r9 @ pass Thread::Current
140 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700141 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700142
buzbee4a3164f2011-09-03 11:25:10 -0700143 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700144 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700145 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700146 * All generated callsites for interface invokes will load arguments as usual - except instead
147 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
148 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
149 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
150 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700151 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700152 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
153 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700154 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700155 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
156 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700157 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700158 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
159 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700160 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700161art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700162 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
163 mov r2, r9 @ pass Thread::Current
164 mov r3, sp @ pass SP
165 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, Thread*, SP)
166 mov r12, r1 @ save r0->code_
167 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
168 cmp r0, #0 @ did we find the target?
169 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700170 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700171
172 .global art_handle_fill_data_from_code
173 .extern artHandleFillArrayDataFromCode
174 /*
175 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
176 * failure.
177 */
178art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700179 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
180 mov r2, r9 @ pass Thread::Current
181 mov r3, sp @ pass SP
182 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
183 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
184 cmp r0, #0 @ success?
185 moveq pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700186 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700187
188 .global art_lock_object_from_code
189 .extern artLockObjectFromCode
190 /*
191 * Entry from managed code that calls artLockObjectFromCode, may block for GC
192 */
193art_lock_object_from_code:
194 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
195 mov r1, r9 @ pass Thread::Current
196 mov r2, sp @ pass SP
197 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
198 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700199
200 .global art_unlock_object_from_code
201 .extern artUnlockObjectFromCode
202 /*
203 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
204 */
205art_unlock_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700206 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
207 mov r1, r9 @ pass Thread::Current
208 mov r2, sp @ pass SP
209 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
210 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
211 cmp r0, #0 @ success?
212 moveq pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700213 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700214
215 .global art_check_cast_from_code
216 .extern artCheckCastFromCode
217 /*
218 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
219 */
220art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700221 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
222 mov r2, r9 @ pass Thread::Current
223 mov r3, sp @ pass SP
224 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
225 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
226 cmp r0, #0 @ success?
227 moveq pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700228 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700229
Ian Rogerse51a5112011-09-23 14:16:35 -0700230 .global art_can_put_array_element_from_code
231 .extern artCanPutArrayElementFromCode
232 /*
233 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
234 * failure.
235 */
236art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700237 cmp r0, #0 @ return if element == NULL
Ian Rogerse51a5112011-09-23 14:16:35 -0700238 moveq pc, lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700239 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
240 mov r2, r9 @ pass Thread::Current
241 mov r3, sp @ pass SP
242 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
243 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
244 cmp r0, #0 @ success?
245 moveq pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700246 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700247
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700248 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700249 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700250 /*
251 * Entry from managed code when uninitialized static storage, this stub will run the class
252 * initializer and deliver the exception on error. On success the static storage base is
253 * returned.
254 */
255art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700256 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
257 mov r2, r9 @ pass Thread::Current
258 mov r3, sp @ pass SP
259 @ ClassLinker::InitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
260 bl artInitializeStaticStorageFromCode
261 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
262 cmp r0, #0 @ success if result is non-null
263 movne pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700264 DELIVER_PENDING_EXCEPTION
265
266 .global art_find_instance_field_from_code
267 .extern artFindInstanceFieldFromCode
268 /*
269 * Called by managed code to resolve a field of an object
270 */
271art_find_instance_field_from_code:
272 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
273 mov r2, r9 @ pass Thread::Current
274 mov r3, sp @ pass SP
275 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
276 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
277 cmp r0, #0 @ success if result is non-null
278 movne pc, lr @ return on success
279 DELIVER_PENDING_EXCEPTION
280
281 .global art_get32_static_from_code
282 .extern artGet32StaticFromCode
283 /*
284 * Called by managed code to resolve a static field and load a 32-bit primitive value
285 */
286art_get32_static_from_code:
287 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
288 mov r2, r9 @ pass Thread::Current
289 mov r3, sp @ pass SP
290 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
291 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
292 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
293 cmp r12, #0 @ success if no exception is pending
294 moveq pc, lr @ return on success
295 DELIVER_PENDING_EXCEPTION
296
297 .global art_get64_static_from_code
298 .extern artGet64StaticFromCode
299 /*
300 * Called by managed code to resolve a static field and load a 64-bit primitive value
301 */
302art_get64_static_from_code:
303 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
304 mov r2, r9 @ pass Thread::Current
305 mov r3, sp @ pass SP
306 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
307 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
308 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
309 cmp r12, #0 @ success if no exception is pending
310 moveq pc, lr @ return on success
311 DELIVER_PENDING_EXCEPTION
312
313 .global art_get_obj_static_from_code
314 .extern artGetObjStaticFromCode
315 /*
316 * Called by managed code to resolve a static field and load an object reference
317 */
318art_get_obj_static_from_code:
319 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
320 mov r2, r9 @ pass Thread::Current
321 mov r3, sp @ pass SP
322 bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
323 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
324 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
325 cmp r12, #0 @ success if no exception is pending
326 moveq pc, lr @ return on success
327 DELIVER_PENDING_EXCEPTION
328
329 .global art_set32_static_from_code
330 .extern artSet32StaticFromCode
331 /*
332 * Called by managed code to resolve a static field and store a 32-bit primitive value
333 */
334art_set32_static_from_code:
335 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
336 mov r3, r9 @ pass Thread::Current
337 str sp, [sp, #0] @ pass SP
338 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
339 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
340 cmp r0, #0 @ success if result is 0
341 moveq pc, lr @ return on success
342 DELIVER_PENDING_EXCEPTION
343
344 .global art_set64_static_from_code
345 .extern artSet32StaticFromCode
346 /*
347 * Called by managed code to resolve a static field and store a 64-bit primitive value
348 */
349art_set64_static_from_code:
350 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
351 mov r12, sp @ save SP
352 sub sp, #8 @ grow frame for alignment with stack args
353 push {r9, r12} @ pass Thread::Current and SP
354 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
355 add sp, #16 @ release out args
356 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
357 cmp r0, #0 @ success if result is 0
358 moveq pc, lr @ return on success
359 DELIVER_PENDING_EXCEPTION
360
361 .global art_set_obj_static_from_code
362 .extern artSetObjStaticFromCode
363 /*
364 * Called by managed code to resolve a static field and store an object reference
365 */
366art_set_obj_static_from_code:
367 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
368 mov r3, r9 @ pass Thread::Current
369 str sp, [sp, #0] @ pass SP
370 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
371 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
372 cmp r0, #0 @ success if result is 0
373 moveq pc, lr @ return on success
374 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700375
Ian Rogers21d9e832011-09-23 17:05:09 -0700376 .global art_alloc_object_from_code
377 .extern artAllocObjectFromCode
378 /*
379 * Called by managed code to allocate an object
380 */
381art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700382 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
383 mov r2, r9 @ pass Thread::Current
384 mov r3, sp @ pass SP
385 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
386 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
387 cmp r0, #0 @ success if result is non-null
388 movne pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700389 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700390
Elliott Hughesb408de72011-10-04 14:35:05 -0700391 .global art_alloc_array_from_code
392 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700393 /*
394 * Called by managed code to allocate an array
395 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700396art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700397 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
398 mov r3, r9 @ pass Thread::Current
399 str sp, [sp, #0] @ pass SP
400 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
401 bl artAllocArrayFromCode
402 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
403 cmp r0, #0 @ success if result is non-null
404 movne pc, lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700405 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700406
Elliott Hughesb408de72011-10-04 14:35:05 -0700407 .global art_check_and_alloc_array_from_code
408 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700409 /*
410 * Called by managed code to allocate an array
411 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700412art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700413 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
414 mov r3, r9 @ pass Thread::Current
415 str sp, [sp, #0] @ pass SP
416 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
417 bl artCheckAndAllocArrayFromCode
418 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700419 cmp r0, #0 @ success if result is non-null
420 movne pc, lr @ return on success
421 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700422
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700423 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700424 .extern artTestSuspendFromCode
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700425art_test_suspend:
426 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
427 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
428 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
429 bxeq rLR @ return if suspend_count_ == 0
430 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700431 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700432 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700433 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700434 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
435
buzbee54330722011-08-23 16:46:55 -0700436 .global art_shl_long
437art_shl_long:
438 /*
439 * Long integer shift. This is different from the generic 32/64-bit
440 * binary operations because vAA/vBB are 64-bit but vCC (the shift
441 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
442 * 6 bits.
443 * On entry:
444 * r0: low word
445 * r1: high word
446 * r2: shift count
447 */
448 /* shl-long vAA, vBB, vCC */
449 and r2, r2, #63 @ r2<- r2 & 0x3f
450 mov r1, r1, asl r2 @ r1<- r1 << r2
451 rsb r3, r2, #32 @ r3<- 32 - r2
452 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
453 subs ip, r2, #32 @ ip<- r2 - 32
454 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
455 mov r0, r0, asl r2 @ r0<- r0 << r2
456 bx lr
457
458 .balign 4
459 .global art_shr_long
460art_shr_long:
461 /*
462 * Long integer shift. This is different from the generic 32/64-bit
463 * binary operations because vAA/vBB are 64-bit but vCC (the shift
464 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
465 * 6 bits.
466 * On entry:
467 * r0: low word
468 * r1: high word
469 * r2: shift count
470 */
471 /* shr-long vAA, vBB, vCC */
472 and r2, r2, #63 @ r0<- r0 & 0x3f
473 mov r0, r0, lsr r2 @ r0<- r2 >> r2
474 rsb r3, r2, #32 @ r3<- 32 - r2
475 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
476 subs ip, r2, #32 @ ip<- r2 - 32
477 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
478 mov r1, r1, asr r2 @ r1<- r1 >> r2
479 bx lr
480
481 .balign 4
482 .global art_ushr_long
483art_ushr_long:
484 /*
485 * Long integer shift. This is different from the generic 32/64-bit
486 * binary operations because vAA/vBB are 64-bit but vCC (the shift
487 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
488 * 6 bits.
489 * On entry:
490 * r0: low word
491 * r1: high word
492 * r2: shift count
493 */
494 /* ushr-long vAA, vBB, vCC */
495 and r2, r2, #63 @ r0<- r0 & 0x3f
496 mov r0, r0, lsr r2 @ r0<- r2 >> r2
497 rsb r3, r2, #32 @ r3<- 32 - r2
498 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
499 subs ip, r2, #32 @ ip<- r2 - 32
500 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
501 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
502 bx lr
503
504#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700505
506#if defined(__i386__)
507
Ian Rogersff1ed472011-09-20 13:46:24 -0700508 .global art_deliver_exception_from_code
509 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700510 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700511 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700512 * that will place a mock Method* at the bottom of the stack.
513 * EAX holds the exception.
514 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700515art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700516 // Create frame
517 pushl %edi // Save callee saves
518 pushl %esi
519 pushl %ebp
520 pushl %ebx
521 pushl $0
522 pushl $0
523 pushl $0 // Will be clobbered to be Method*
524 mov %esp, %ecx
525 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700526 pushl $0 // Alignment padding
527 pushl %ecx // pass SP
528 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
529 pushl %eax // pass Throwable*
530 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700531 int3
532
533#endif