blob: f65f70309c9eaf436d011bd36f462b92481d4a4b [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
Brian Carlstrom6f495f22011-10-10 15:05:03 -070066 .global art_do_long_jump
67art_do_long_jump:
68 /*
69 * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_
70 */
71 vldm r1, {s0-s31} @ load all fprs from argument fprs_
72 ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15)
73 add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3
74 ldm r0, {r3-r14} @ load remaining gprs from argument gprs_
75 mov r0, #0 @ clear result registers r0 and r1
76 mov r1, #0
77 bx r2 @ do long jump
78
Ian Rogersff1ed472011-09-20 13:46:24 -070079 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070080 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070081 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
82 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
83 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070084 */
Ian Rogersff1ed472011-09-20 13:46:24 -070085art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070086 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070087 mov r1, r9 @ pass Thread::Current
88 mov r2, sp @ pass SP
89 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070090
91 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070092 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070093 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070094 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070095 */
96art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070097 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070098 mov r0, r9 @ pass Thread::Current
99 mov r1, sp @ pass SP
100 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700101
102 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700103 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700104 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700105 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -0700106 */
107art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700108 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700109 mov r0, r9 @ pass Thread::Current
110 mov r1, sp @ pass SP
111 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700112
113 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700114 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700115 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700116 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -0700117 */
118art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700119 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700120 mov r2, r9 @ pass Thread::Current
121 mov r3, sp @ pass SP
122 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -0700123
Ian Rogers932746a2011-09-22 18:57:50 -0700124 .global art_throw_stack_overflow_from_code
125 .extern artThrowStackOverflowFromCode
126art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700127 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700128 mov r1, r9 @ pass Thread::Current
129 mov r2, sp @ pass SP
130 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
131
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700132 .global art_throw_neg_array_size_from_code
133 .extern artThrowNegArraySizeFromCode
134art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700135 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700136 mov r1, r9 @ pass Thread::Current
137 mov r2, sp @ pass SP
138 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
139
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700140 .global art_throw_no_such_method_from_code
141 .extern artThrowNoSuchMethodFromCode
142art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700143 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700144 mov r1, r9 @ pass Thread::Current
145 mov r2, sp @ pass SP
146 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
147
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700148 .global art_throw_verification_error_from_code
149 .extern artThrowVerificationErrorFromCode
150art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700151 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700152 mov r2, r9 @ pass Thread::Current
153 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700154 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700155
buzbee4a3164f2011-09-03 11:25:10 -0700156 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700157 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700158 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700159 * All generated callsites for interface invokes will load arguments as usual - except instead
160 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
161 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
162 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
163 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700164 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700165 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
166 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700167 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700168 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
169 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700170 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700171 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
172 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700173 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700174art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700175 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
176 mov r2, r9 @ pass Thread::Current
177 mov r3, sp @ pass SP
178 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, Thread*, SP)
179 mov r12, r1 @ save r0->code_
180 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
181 cmp r0, #0 @ did we find the target?
182 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700183 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700184
185 .global art_handle_fill_data_from_code
186 .extern artHandleFillArrayDataFromCode
187 /*
188 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
189 * failure.
190 */
191art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700192 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
193 mov r2, r9 @ pass Thread::Current
194 mov r3, sp @ pass SP
195 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
196 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
197 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700198 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700199 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700200
201 .global art_lock_object_from_code
202 .extern artLockObjectFromCode
203 /*
204 * Entry from managed code that calls artLockObjectFromCode, may block for GC
205 */
206art_lock_object_from_code:
207 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
208 mov r1, r9 @ pass Thread::Current
209 mov r2, sp @ pass SP
210 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
211 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700212
213 .global art_unlock_object_from_code
214 .extern artUnlockObjectFromCode
215 /*
216 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
217 */
218art_unlock_object_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 r1, r9 @ pass Thread::Current
221 mov r2, sp @ pass SP
222 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
223 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
224 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700225 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700226 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700227
228 .global art_check_cast_from_code
229 .extern artCheckCastFromCode
230 /*
231 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
232 */
233art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700234 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
235 mov r2, r9 @ pass Thread::Current
236 mov r3, sp @ pass SP
237 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
238 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
239 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700240 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700241 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700242
Ian Rogerse51a5112011-09-23 14:16:35 -0700243 .global art_can_put_array_element_from_code
244 .extern artCanPutArrayElementFromCode
245 /*
246 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
247 * failure.
248 */
249art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700250 cmp r0, #0 @ return if element == NULL
Ian Rogersae675992011-10-09 17:10:22 -0700251 bxeq lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700252 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
253 mov r2, r9 @ pass Thread::Current
254 mov r3, sp @ pass SP
255 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
256 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
257 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700258 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700259 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700260
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700261 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700262 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700263 /*
264 * Entry from managed code when uninitialized static storage, this stub will run the class
265 * initializer and deliver the exception on error. On success the static storage base is
266 * returned.
267 */
268art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700269 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
270 mov r2, r9 @ pass Thread::Current
271 mov r3, sp @ pass SP
Brian Carlstromaded5f72011-10-07 17:15:04 -0700272 @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700273 bl artInitializeStaticStorageFromCode
274 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
275 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700276 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700277 DELIVER_PENDING_EXCEPTION
278
279 .global art_find_instance_field_from_code
280 .extern artFindInstanceFieldFromCode
281 /*
282 * Called by managed code to resolve a field of an object
283 */
284art_find_instance_field_from_code:
285 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
286 mov r2, r9 @ pass Thread::Current
287 mov r3, sp @ pass SP
288 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
289 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
290 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700291 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700292 DELIVER_PENDING_EXCEPTION
293
294 .global art_get32_static_from_code
295 .extern artGet32StaticFromCode
296 /*
297 * Called by managed code to resolve a static field and load a 32-bit primitive value
298 */
299art_get32_static_from_code:
300 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
301 mov r2, r9 @ pass Thread::Current
302 mov r3, sp @ pass SP
303 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
304 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
305 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
306 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700307 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700308 DELIVER_PENDING_EXCEPTION
309
310 .global art_get64_static_from_code
311 .extern artGet64StaticFromCode
312 /*
313 * Called by managed code to resolve a static field and load a 64-bit primitive value
314 */
315art_get64_static_from_code:
316 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
317 mov r2, r9 @ pass Thread::Current
318 mov r3, sp @ pass SP
319 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
320 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
321 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
322 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700323 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700324 DELIVER_PENDING_EXCEPTION
325
326 .global art_get_obj_static_from_code
327 .extern artGetObjStaticFromCode
328 /*
329 * Called by managed code to resolve a static field and load an object reference
330 */
331art_get_obj_static_from_code:
332 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
333 mov r2, r9 @ pass Thread::Current
334 mov r3, sp @ pass SP
335 bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
336 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
337 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
338 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700339 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700340 DELIVER_PENDING_EXCEPTION
341
342 .global art_set32_static_from_code
343 .extern artSet32StaticFromCode
344 /*
345 * Called by managed code to resolve a static field and store a 32-bit primitive value
346 */
347art_set32_static_from_code:
348 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
349 mov r3, r9 @ pass Thread::Current
350 str sp, [sp, #0] @ pass SP
351 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
352 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
353 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700354 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700355 DELIVER_PENDING_EXCEPTION
356
357 .global art_set64_static_from_code
358 .extern artSet32StaticFromCode
359 /*
360 * Called by managed code to resolve a static field and store a 64-bit primitive value
361 */
362art_set64_static_from_code:
363 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
364 mov r12, sp @ save SP
365 sub sp, #8 @ grow frame for alignment with stack args
366 push {r9, r12} @ pass Thread::Current and SP
367 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
368 add sp, #16 @ release out args
369 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
370 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700371 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700372 DELIVER_PENDING_EXCEPTION
373
374 .global art_set_obj_static_from_code
375 .extern artSetObjStaticFromCode
376 /*
377 * Called by managed code to resolve a static field and store an object reference
378 */
379art_set_obj_static_from_code:
380 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
381 mov r3, r9 @ pass Thread::Current
382 str sp, [sp, #0] @ pass SP
383 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
384 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
385 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700386 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700387 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700388
Brian Carlstromaded5f72011-10-07 17:15:04 -0700389 .global art_resolve_string_from_code
390 .extern artResolveStringFromCode
391 /*
392 * Entry from managed code to resolve a string, this stub will
393 * allocate a String and deliver an exception on error. On
394 * success the String is returned.
395 */
Brian Carlstrom6f495f22011-10-10 15:05:03 -0700396art_resolve_string_from_code:
Brian Carlstromaded5f72011-10-07 17:15:04 -0700397 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
398 mov r2, r9 @ pass Thread::Current
399 mov r3, sp @ pass SP
400 @ artResolveStringFromCode(Method* referrer, uint32_t type_idx, Thread*, SP)
401 bl artResolveStringFromCode
402 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
403 cmp r0, #0 @ success if result is non-null
404 bxne lr @ return on success
405 DELIVER_PENDING_EXCEPTION
406
Ian Rogers21d9e832011-09-23 17:05:09 -0700407 .global art_alloc_object_from_code
408 .extern artAllocObjectFromCode
409 /*
410 * Called by managed code to allocate an object
411 */
412art_alloc_object_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 r2, r9 @ pass Thread::Current
415 mov r3, sp @ pass SP
416 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
417 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
418 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700419 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700420 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700421
Elliott Hughesb408de72011-10-04 14:35:05 -0700422 .global art_alloc_array_from_code
423 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700424 /*
425 * Called by managed code to allocate an array
426 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700427art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700428 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
429 mov r3, r9 @ pass Thread::Current
430 str sp, [sp, #0] @ pass SP
431 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
432 bl artAllocArrayFromCode
433 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
434 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700435 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700436 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700437
Elliott Hughesb408de72011-10-04 14:35:05 -0700438 .global art_check_and_alloc_array_from_code
439 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700440 /*
441 * Called by managed code to allocate an array
442 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700443art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700444 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
445 mov r3, r9 @ pass Thread::Current
446 str sp, [sp, #0] @ pass SP
447 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
448 bl artCheckAndAllocArrayFromCode
449 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700450 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700451 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700452 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700453
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700454 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700455 .extern artTestSuspendFromCode
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700456art_test_suspend:
457 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
458 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
459 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
460 bxeq rLR @ return if suspend_count_ == 0
461 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700462 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700463 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700464 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700465 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
466
buzbee54330722011-08-23 16:46:55 -0700467 .global art_shl_long
468art_shl_long:
469 /*
470 * Long integer shift. This is different from the generic 32/64-bit
471 * binary operations because vAA/vBB are 64-bit but vCC (the shift
472 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
473 * 6 bits.
474 * On entry:
475 * r0: low word
476 * r1: high word
477 * r2: shift count
478 */
479 /* shl-long vAA, vBB, vCC */
480 and r2, r2, #63 @ r2<- r2 & 0x3f
481 mov r1, r1, asl r2 @ r1<- r1 << r2
482 rsb r3, r2, #32 @ r3<- 32 - r2
483 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
484 subs ip, r2, #32 @ ip<- r2 - 32
485 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
486 mov r0, r0, asl r2 @ r0<- r0 << r2
487 bx lr
488
489 .balign 4
490 .global art_shr_long
491art_shr_long:
492 /*
493 * Long integer shift. This is different from the generic 32/64-bit
494 * binary operations because vAA/vBB are 64-bit but vCC (the shift
495 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
496 * 6 bits.
497 * On entry:
498 * r0: low word
499 * r1: high word
500 * r2: shift count
501 */
502 /* shr-long vAA, vBB, vCC */
503 and r2, r2, #63 @ r0<- r0 & 0x3f
504 mov r0, r0, lsr r2 @ r0<- r2 >> r2
505 rsb r3, r2, #32 @ r3<- 32 - r2
506 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
507 subs ip, r2, #32 @ ip<- r2 - 32
508 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
509 mov r1, r1, asr r2 @ r1<- r1 >> r2
510 bx lr
511
512 .balign 4
513 .global art_ushr_long
514art_ushr_long:
515 /*
516 * Long integer shift. This is different from the generic 32/64-bit
517 * binary operations because vAA/vBB are 64-bit but vCC (the shift
518 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
519 * 6 bits.
520 * On entry:
521 * r0: low word
522 * r1: high word
523 * r2: shift count
524 */
525 /* ushr-long vAA, vBB, vCC */
526 and r2, r2, #63 @ r0<- r0 & 0x3f
527 mov r0, r0, lsr r2 @ r0<- r2 >> r2
528 rsb r3, r2, #32 @ r3<- 32 - r2
529 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
530 subs ip, r2, #32 @ ip<- r2 - 32
531 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
532 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
533 bx lr
534
535#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700536
537#if defined(__i386__)
538
Ian Rogersff1ed472011-09-20 13:46:24 -0700539 .global art_deliver_exception_from_code
540 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700541 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700542 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700543 * that will place a mock Method* at the bottom of the stack.
544 * EAX holds the exception.
545 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700546art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700547 // Create frame
548 pushl %edi // Save callee saves
549 pushl %esi
550 pushl %ebp
551 pushl %ebx
552 pushl $0
553 pushl $0
554 pushl $0 // Will be clobbered to be Method*
555 mov %esp, %ecx
556 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700557 pushl $0 // Alignment padding
558 pushl %ecx // pass SP
559 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
560 pushl %eax // pass Throwable*
561 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700562 int3
563
564#endif