blob: cee90435d457cebcd4bea77faa7fba58811c8a77 [file] [log] [blame]
Ian Rogers9651f422011-09-19 20:26:07 -07001#include "asm_support.h"
2
buzbee54330722011-08-23 16:46:55 -07003 .balign 4
buzbee4a3164f2011-09-03 11:25:10 -07004
Ian Rogersff1ed472011-09-20 13:46:24 -07005 /* Deliver the given exception */
6 .extern artDeliverExceptionFromCode
7 /* Deliver an exception pending on a thread */
8 .extern artDeliverPendingException
9
Ian Rogers4f0d07c2011-10-06 23:38:47 -070010 /*
11 * Macro that sets up the callee save frame to conform with
12 * Runtime::CreateCalleeSaveMethod(kSaveAll)
13 */
Ian Rogers15fdb8c2011-09-25 15:45:07 -070014.macro SETUP_CALLEE_SAVE_FRAME
Ian Rogers4f0d07c2011-10-06 23:38:47 -070015 push {r4-r11, lr} @ 9 words of callee saves
Ian Rogers15fdb8c2011-09-25 15:45:07 -070016 vpush {s0-s31}
Ian Rogers4f0d07c2011-10-06 23:38:47 -070017 sub sp, #12 @ 3 words of space, bottom word will hold Method*
18.endm
19
20 /*
21 * Macro that sets up the callee save frame to conform with
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070022 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
Ian Rogers4f0d07c2011-10-06 23:38:47 -070023 */
24.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
25 push {r5-r8, r10-r11, lr} @ 7 words of callee saves
26 sub sp, #4 @ bottom word will hold Method*
27.endm
28
29.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070030 ldr lr, [sp, #28] @ restore lr for return
31 add sp, #32 @ unwind stack
Ian Rogers4f0d07c2011-10-06 23:38:47 -070032.endm
33
34.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070035 ldr lr, [sp, #28] @ restore lr for return
36 add sp, #32 @ unwind stack
37 bx lr @ return
Ian Rogers4f0d07c2011-10-06 23:38:47 -070038.endm
39
40 /*
41 * Macro that sets up the callee save frame to conform with
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070042 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Ian Rogers4f0d07c2011-10-06 23:38:47 -070043 */
44.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070045 push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
46 sub sp, #8 @ 2 words of space, bottom word will hold Method*
Ian Rogers4f0d07c2011-10-06 23:38:47 -070047.endm
48
49.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070050 ldr r1, [sp, #8] @ restore non-callee save r1
51 ldrd r2, [sp, #12] @ restore non-callee saves r2-r3
52 ldr lr, [sp, #44] @ restore lr
53 add sp, #48 @ rewind sp
Ian Rogers15fdb8c2011-09-25 15:45:07 -070054.endm
55
Ian Rogersce9eca62011-10-07 17:11:03 -070056 /*
57 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
58 * exception is Thread::Current()->exception_
59 */
60.macro DELIVER_PENDING_EXCEPTION
61 SETUP_CALLEE_SAVE_FRAME @ save callee saves for throw
62 mov r0, r9 @ pass Thread::Current
63 mov r1, sp @ pass SP
64 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
65.endm
66
Brian Carlstrom6f495f22011-10-10 15:05:03 -070067 .global art_do_long_jump
Brian Carlstrom6f495f22011-10-10 15:05:03 -070068 /*
69 * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_
70 */
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070071art_do_long_jump:
Brian Carlstrom6f495f22011-10-10 15:05:03 -070072 vldm r1, {s0-s31} @ load all fprs from argument fprs_
73 ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15)
74 add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3
75 ldm r0, {r3-r14} @ load remaining gprs from argument gprs_
76 mov r0, #0 @ clear result registers r0 and r1
77 mov r1, #0
78 bx r2 @ do long jump
79
Ian Rogersff1ed472011-09-20 13:46:24 -070080 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070081 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070082 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
83 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
84 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070085 */
Ian Rogersff1ed472011-09-20 13:46:24 -070086art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070087 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070088 mov r1, r9 @ pass Thread::Current
89 mov r2, sp @ pass SP
90 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070091
92 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070093 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070094 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070095 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070096 */
97art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070098 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070099 mov r0, r9 @ pass Thread::Current
100 mov r1, sp @ pass SP
101 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700102
103 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700104 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700105 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700106 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -0700107 */
108art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700109 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700110 mov r0, r9 @ pass Thread::Current
111 mov r1, sp @ pass SP
112 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700113
114 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700115 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700116 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700117 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -0700118 */
119art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700120 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700121 mov r2, r9 @ pass Thread::Current
122 mov r3, sp @ pass SP
123 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -0700124
Ian Rogers932746a2011-09-22 18:57:50 -0700125 .global art_throw_stack_overflow_from_code
126 .extern artThrowStackOverflowFromCode
127art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700128 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700129 mov r1, r9 @ pass Thread::Current
130 mov r2, sp @ pass SP
131 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
132
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700133 .global art_throw_neg_array_size_from_code
134 .extern artThrowNegArraySizeFromCode
135art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700136 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700137 mov r1, r9 @ pass Thread::Current
138 mov r2, sp @ pass SP
139 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
140
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700141 .global art_throw_no_such_method_from_code
142 .extern artThrowNoSuchMethodFromCode
143art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700144 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700145 mov r1, r9 @ pass Thread::Current
146 mov r2, sp @ pass SP
147 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
148
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700149 .global art_throw_verification_error_from_code
150 .extern artThrowVerificationErrorFromCode
151art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700152 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700153 mov r2, r9 @ pass Thread::Current
154 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700155 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700156
buzbee4a3164f2011-09-03 11:25:10 -0700157 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700158 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700159 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700160 * All generated callsites for interface invokes will load arguments as usual - except instead
161 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
162 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
163 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
164 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700165 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700166 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
167 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700168 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700169 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
170 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700171 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700172 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
173 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700174 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700175art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700176 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
Ian Rogerscaab8c42011-10-12 12:11:18 -0700177 ldr r2, [sp, #48] @ pass caller Method*
178 mov r3, r9 @ pass Thread::Current
179 str sp, [sp, #0] @ pass SP
180 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, caller, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700181 mov r12, r1 @ save r0->code_
182 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
183 cmp r0, #0 @ did we find the target?
184 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700185 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700186
187 .global art_handle_fill_data_from_code
188 .extern artHandleFillArrayDataFromCode
189 /*
190 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
191 * failure.
192 */
193art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700194 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
195 mov r2, r9 @ pass Thread::Current
196 mov r3, sp @ pass SP
197 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
198 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
199 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700200 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700201 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700202
203 .global art_lock_object_from_code
204 .extern artLockObjectFromCode
205 /*
206 * Entry from managed code that calls artLockObjectFromCode, may block for GC
207 */
208art_lock_object_from_code:
209 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
210 mov r1, r9 @ pass Thread::Current
211 mov r2, sp @ pass SP
212 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
213 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700214
215 .global art_unlock_object_from_code
216 .extern artUnlockObjectFromCode
217 /*
218 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
219 */
220art_unlock_object_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 r1, r9 @ pass Thread::Current
223 mov r2, sp @ pass SP
224 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
225 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
226 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700227 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700228 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700229
230 .global art_check_cast_from_code
231 .extern artCheckCastFromCode
232 /*
233 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
234 */
235art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700236 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
237 mov r2, r9 @ pass Thread::Current
238 mov r3, sp @ pass SP
239 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
240 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
241 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700242 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700243 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700244
Ian Rogerse51a5112011-09-23 14:16:35 -0700245 .global art_can_put_array_element_from_code
246 .extern artCanPutArrayElementFromCode
247 /*
248 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
249 * failure.
250 */
251art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700252 cmp r0, #0 @ return if element == NULL
Ian Rogersae675992011-10-09 17:10:22 -0700253 bxeq lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700254 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
255 mov r2, r9 @ pass Thread::Current
256 mov r3, sp @ pass SP
257 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
258 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
259 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700260 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700261 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700262
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700263 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700264 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700265 /*
266 * Entry from managed code when uninitialized static storage, this stub will run the class
267 * initializer and deliver the exception on error. On success the static storage base is
268 * returned.
269 */
270art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700271 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
272 mov r2, r9 @ pass Thread::Current
273 mov r3, sp @ pass SP
Brian Carlstromaded5f72011-10-07 17:15:04 -0700274 @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700275 bl artInitializeStaticStorageFromCode
276 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
277 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700278 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700279 DELIVER_PENDING_EXCEPTION
280
Ian Rogers28ad40d2011-10-27 15:19:26 -0700281 .global art_initialize_type_from_code
282 .extern artInitializeTypeFromCode
283 /*
284 * Entry from managed code when dex cache misses for a type_idx
285 */
286art_initialize_type_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 @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
291 bl artInitializeTypeFromCode
292 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
293 cmp r0, #0 @ success if result is non-null
294 bxne lr @ return on success
295 DELIVER_PENDING_EXCEPTION
296
Ian Rogersb093c6b2011-10-31 16:19:55 -0700297 .global art_initialize_type_and_verify_access_from_code
298 .extern artInitializeTypeAndVerifyAccessFromCode
299 /*
300 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
301 * miss
302 */
303art_initialize_type_and_verify_access_from_code:
304 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
305 mov r2, r9 @ pass Thread::Current
306 mov r3, sp @ pass SP
307 @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
308 bl artInitializeTypeAndVerifyAccessFromCode
309 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
310 cmp r0, #0 @ success if result is non-null
311 bxne lr @ return on success
312 DELIVER_PENDING_EXCEPTION
313
Ian Rogersce9eca62011-10-07 17:11:03 -0700314 .global art_find_instance_field_from_code
315 .extern artFindInstanceFieldFromCode
316 /*
317 * Called by managed code to resolve a field of an object
318 */
319art_find_instance_field_from_code:
320 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
321 mov r2, r9 @ pass Thread::Current
322 mov r3, sp @ pass SP
323 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
324 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
325 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700326 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700327 DELIVER_PENDING_EXCEPTION
328
329 .global art_get32_static_from_code
330 .extern artGet32StaticFromCode
331 /*
332 * Called by managed code to resolve a static field and load a 32-bit primitive value
333 */
334art_get32_static_from_code:
335 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
336 mov r2, r9 @ pass Thread::Current
337 mov r3, sp @ pass SP
338 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
339 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
340 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
341 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700342 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700343 DELIVER_PENDING_EXCEPTION
344
345 .global art_get64_static_from_code
346 .extern artGet64StaticFromCode
347 /*
348 * Called by managed code to resolve a static field and load a 64-bit primitive value
349 */
350art_get64_static_from_code:
351 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
352 mov r2, r9 @ pass Thread::Current
353 mov r3, sp @ pass SP
354 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
355 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
356 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
357 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700358 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700359 DELIVER_PENDING_EXCEPTION
360
361 .global art_get_obj_static_from_code
362 .extern artGetObjStaticFromCode
363 /*
364 * Called by managed code to resolve a static field and load an object reference
365 */
366art_get_obj_static_from_code:
367 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
368 mov r2, r9 @ pass Thread::Current
369 mov r3, sp @ pass SP
370 bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
371 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
372 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
373 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700374 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700375 DELIVER_PENDING_EXCEPTION
376
377 .global art_set32_static_from_code
378 .extern artSet32StaticFromCode
379 /*
380 * Called by managed code to resolve a static field and store a 32-bit primitive value
381 */
382art_set32_static_from_code:
383 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
384 mov r3, r9 @ pass Thread::Current
385 str sp, [sp, #0] @ pass SP
386 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
387 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
388 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700389 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700390 DELIVER_PENDING_EXCEPTION
391
392 .global art_set64_static_from_code
393 .extern artSet32StaticFromCode
394 /*
395 * Called by managed code to resolve a static field and store a 64-bit primitive value
396 */
397art_set64_static_from_code:
398 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
399 mov r12, sp @ save SP
400 sub sp, #8 @ grow frame for alignment with stack args
401 push {r9, r12} @ pass Thread::Current and SP
402 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
403 add sp, #16 @ release out args
404 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
405 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700406 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700407 DELIVER_PENDING_EXCEPTION
408
409 .global art_set_obj_static_from_code
410 .extern artSetObjStaticFromCode
411 /*
412 * Called by managed code to resolve a static field and store an object reference
413 */
414art_set_obj_static_from_code:
415 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
416 mov r3, r9 @ pass Thread::Current
417 str sp, [sp, #0] @ pass SP
418 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
419 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
420 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700421 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700422 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700423
buzbee48d72222012-01-11 15:19:51 -0800424 .global art_resolve_method_from_code
425 .extern artResolveMethodFromCode
426 /*
427 * Entry from managed code to resolve a method.
428 */
429art_resolve_method_from_code:
430 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
431 mov r3, r9 @ pass Thread::Current
432 str sp, [sp, #0] @ pass SP
433 @ artResolveMethodFromCode(Method* referrer, uint32_t method_idx, bool is_direct, Thread*, SP)
434 bl artResolveMethodFromCode
435 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
436 cmp r0, #0 @ success if result is non-null
437 bxne lr @ return on success
438 DELIVER_PENDING_EXCEPTION
439
Brian Carlstromaded5f72011-10-07 17:15:04 -0700440 .global art_resolve_string_from_code
441 .extern artResolveStringFromCode
442 /*
Ian Rogerscaab8c42011-10-12 12:11:18 -0700443 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
444 * exception on error. On success the String is returned. R0 holds the referring method,
445 * R1 holds the string index. The fast path check for hit in strings cache has already been
446 * performed.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700447 */
Brian Carlstrom6f495f22011-10-10 15:05:03 -0700448art_resolve_string_from_code:
Ian Rogerscaab8c42011-10-12 12:11:18 -0700449 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
450 mov r2, r9 @ pass Thread::Current
451 mov r3, sp @ pass SP
452 @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP)
Brian Carlstromaded5f72011-10-07 17:15:04 -0700453 bl artResolveStringFromCode
454 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogerscaab8c42011-10-12 12:11:18 -0700455 cmp r0, #0 @ success if result is non-null
456 bxne lr @ return on success
Brian Carlstromaded5f72011-10-07 17:15:04 -0700457 DELIVER_PENDING_EXCEPTION
458
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -0700459 .global art_object_init_from_code
460 .extern artObjectInitFromCode
461 /*
462 * Entry from managed code to perform Object.<init> string. R0 holds the object to initialize.
463 * On success, 0 is returned. Otherwise there is a pending exception to deliver.
464 */
465art_object_init_from_code:
466 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
467 mov r1, r9 @ pass Thread::Current
468 mov r2, sp @ pass SP
469 @ artObjectInitFromCode(Object* o, Thread*, SP)
470 bl artObjectInitFromCode
471 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
472 cmp r0, #0 @ success if result is zero
473 bxeq lr @ return on success
474 DELIVER_PENDING_EXCEPTION
475
Ian Rogers21d9e832011-09-23 17:05:09 -0700476 .global art_alloc_object_from_code
477 .extern artAllocObjectFromCode
478 /*
479 * Called by managed code to allocate an object
480 */
481art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700482 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
483 mov r2, r9 @ pass Thread::Current
484 mov r3, sp @ pass SP
485 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
486 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
487 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700488 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700489 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700490
Ian Rogers28ad40d2011-10-27 15:19:26 -0700491 .global art_alloc_object_from_code_with_access_check
492 .extern artAllocObjectFromCodeWithAccessCheck
buzbeecc4540e2011-10-27 13:06:03 -0700493 /*
Ian Rogers28ad40d2011-10-27 15:19:26 -0700494 * Called by managed code to allocate an object when the caller doesn't know whether it has
495 * access to the created type
buzbeecc4540e2011-10-27 13:06:03 -0700496 */
Ian Rogers28ad40d2011-10-27 15:19:26 -0700497art_alloc_object_from_code_with_access_check:
buzbeecc4540e2011-10-27 13:06:03 -0700498 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
499 mov r2, r9 @ pass Thread::Current
500 mov r3, sp @ pass SP
Ian Rogers28ad40d2011-10-27 15:19:26 -0700501 bl artAllocObjectFromCodeWithAccessCheck @ (uint32_t type_idx, Method* method, Thread*, SP)
buzbeecc4540e2011-10-27 13:06:03 -0700502 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
503 cmp r0, #0 @ success if result is non-null
504 bxne lr @ return on success
505 DELIVER_PENDING_EXCEPTION
506
Elliott Hughesb408de72011-10-04 14:35:05 -0700507 .global art_alloc_array_from_code
508 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700509 /*
510 * Called by managed code to allocate an array
511 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700512art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700513 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
514 mov r3, r9 @ pass Thread::Current
515 str sp, [sp, #0] @ pass SP
516 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
517 bl artAllocArrayFromCode
518 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
519 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700520 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700521 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700522
Ian Rogers0eb7d7e2012-01-31 21:12:32 -0800523 .global art_alloc_array_from_code_with_access_check
524 .extern artAllocArrayFromCodeWithAccessCheck
525 /*
526 * Called by managed code to allocate an array when the caller doesn't know whether it has
527 * access to the created type
528 */
529art_alloc_array_from_code_with_access_check:
530 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
531 mov r3, r9 @ pass Thread::Current
532 str sp, [sp, #0] @ pass SP
533 @ artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, SP)
534 bl artAllocArrayFromCodeWithAccessCheck
535 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
536 cmp r0, #0 @ success if result is non-null
537 bxne lr @ return on success
538 DELIVER_PENDING_EXCEPTION
539
Elliott Hughesb408de72011-10-04 14:35:05 -0700540 .global art_check_and_alloc_array_from_code
541 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700542 /*
Ian Rogers0eb7d7e2012-01-31 21:12:32 -0800543 * Called by managed code to allocate an array in a special case for OP_FILLED_NEW_ARRAY
Ian Rogersb886da82011-09-23 16:27:54 -0700544 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700545art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700546 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
547 mov r3, r9 @ pass Thread::Current
548 str sp, [sp, #0] @ pass SP
549 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
550 bl artCheckAndAllocArrayFromCode
551 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700552 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700553 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700554 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700555
Ian Rogers0eb7d7e2012-01-31 21:12:32 -0800556 .global art_check_and_alloc_array_from_code_with_access_check
557 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
558 /*
559 * Called by managed code to allocate an array in a special case for OP_FILLED_NEW_ARRAY
560 */
561art_check_and_alloc_array_from_code_with_access_check:
562 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
563 mov r3, r9 @ pass Thread::Current
564 str sp, [sp, #0] @ pass SP
565 @ artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , SP)
566 bl artCheckAndAllocArrayFromCodeWithAccessCheck
567 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
568 cmp r0, #0 @ success if result is non-null
569 bxne lr @ return on success
570 DELIVER_PENDING_EXCEPTION
571
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700572 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700573 .extern artTestSuspendFromCode
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700574 /*
575 * Called by managed code when the value in rSUSPEND has been decremented to 0
576 */
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700577art_test_suspend:
578 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
579 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
580 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
581 bxeq rLR @ return if suspend_count_ == 0
582 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700583 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700584 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700585 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700586 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
587
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700588 .global art_proxy_invoke_handler
589 .extern artProxyInvokeHandler
590 /*
591 * Called by managed code that is attempting to call a method on a proxy class. On entry
592 * r0 holds the proxy method; r1, r2 and r3 may contain arguments
593 */
594art_proxy_invoke_handler:
595 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
596 str r0, [sp, #0] @ place proxy method at bottom of frame
597 mov r2, r9 @ pass Thread::Current
598 add r3, sp, #12 @ pointer to r2/r3/LR/caller's Method**/out-args as second arg
599 blx artProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, args...)
600 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Ian Rogers466bb252011-10-14 03:29:56 -0700601 ldr lr, [sp, #44] @ restore lr
602 ldrd r0, [sp, #12] @ load r0/r1 from r2/r3 that were overwritten with the out args
603 add sp, #48 @ pop frame
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700604 cmp r12, #0 @ success if no exception is pending
605 bxeq lr @ return on success
606 DELIVER_PENDING_EXCEPTION
607
jeffhaoe343b762011-12-05 16:36:44 -0800608 .global art_trace_entry_from_code
609 .extern artTraceMethodEntryFromCode
610 /*
611 * Routine that intercepts method calls
612 */
613art_trace_entry_from_code:
614 push {r0-r3} @ save arguments (4 words)
615 mov r1, r9 @ pass Thread::Current
616 mov r2, lr @ pass LR
617 blx artTraceMethodEntryFromCode @ (Method*, Thread*, LR)
618 mov r12, r0 @ r12 holds reference to code
619 pop {r0-r3} @ restore arguments
620 blx r12 @ call method
621 /* intentional fallthrough */
622
623 .global art_trace_exit_from_code
624 .extern artTraceMethodExitFromCode
625 /*
626 * Routine that intercepts method returns
627 */
628art_trace_exit_from_code:
629 push {r0-r1} @ save return value
630 blx artTraceMethodExitFromCode @ ()
631 mov lr, r0 @ restore link register
632 pop {r0, r1} @ restore return value
633 bx lr @ return
634
buzbee54330722011-08-23 16:46:55 -0700635 .global art_shl_long
636art_shl_long:
637 /*
638 * Long integer shift. This is different from the generic 32/64-bit
639 * binary operations because vAA/vBB are 64-bit but vCC (the shift
640 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
641 * 6 bits.
642 * On entry:
643 * r0: low word
644 * r1: high word
645 * r2: shift count
646 */
647 /* shl-long vAA, vBB, vCC */
648 and r2, r2, #63 @ r2<- r2 & 0x3f
649 mov r1, r1, asl r2 @ r1<- r1 << r2
650 rsb r3, r2, #32 @ r3<- 32 - r2
651 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
652 subs ip, r2, #32 @ ip<- r2 - 32
653 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
654 mov r0, r0, asl r2 @ r0<- r0 << r2
655 bx lr
656
657 .balign 4
658 .global art_shr_long
659art_shr_long:
660 /*
661 * Long integer shift. This is different from the generic 32/64-bit
662 * binary operations because vAA/vBB are 64-bit but vCC (the shift
663 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
664 * 6 bits.
665 * On entry:
666 * r0: low word
667 * r1: high word
668 * r2: shift count
669 */
670 /* shr-long vAA, vBB, vCC */
671 and r2, r2, #63 @ r0<- r0 & 0x3f
672 mov r0, r0, lsr r2 @ r0<- r2 >> r2
673 rsb r3, r2, #32 @ r3<- 32 - r2
674 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
675 subs ip, r2, #32 @ ip<- r2 - 32
676 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
677 mov r1, r1, asr r2 @ r1<- r1 >> r2
678 bx lr
679
680 .balign 4
681 .global art_ushr_long
682art_ushr_long:
683 /*
684 * Long integer shift. This is different from the generic 32/64-bit
685 * binary operations because vAA/vBB are 64-bit but vCC (the shift
686 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
687 * 6 bits.
688 * On entry:
689 * r0: low word
690 * r1: high word
691 * r2: shift count
692 */
693 /* ushr-long vAA, vBB, vCC */
694 and r2, r2, #63 @ r0<- r0 & 0x3f
695 mov r0, r0, lsr r2 @ r0<- r2 >> r2
696 rsb r3, r2, #32 @ r3<- 32 - r2
697 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
698 subs ip, r2, #32 @ ip<- r2 - 32
699 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
700 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
701 bx lr