blob: 305e73201e8d777c6bc5edf662ce7d71a4cdd98f [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
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070024 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
Ian Rogers4f0d07c2011-10-06 23:38:47 -070025 */
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
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070032 ldr lr, [sp, #28] @ restore lr for return
33 add sp, #32 @ unwind stack
Ian Rogers4f0d07c2011-10-06 23:38:47 -070034.endm
35
36.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070037 ldr lr, [sp, #28] @ restore lr for return
38 add sp, #32 @ unwind stack
39 bx lr @ return
Ian Rogers4f0d07c2011-10-06 23:38:47 -070040.endm
41
42 /*
43 * Macro that sets up the callee save frame to conform with
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070044 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Ian Rogers4f0d07c2011-10-06 23:38:47 -070045 */
46.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070047 push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
48 sub sp, #8 @ 2 words of space, bottom word will hold Method*
Ian Rogers4f0d07c2011-10-06 23:38:47 -070049.endm
50
51.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070052 ldr r1, [sp, #8] @ restore non-callee save r1
53 ldrd r2, [sp, #12] @ restore non-callee saves r2-r3
54 ldr lr, [sp, #44] @ restore lr
55 add sp, #48 @ rewind sp
Ian Rogers15fdb8c2011-09-25 15:45:07 -070056.endm
57
Ian Rogersce9eca62011-10-07 17:11:03 -070058 /*
59 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
60 * exception is Thread::Current()->exception_
61 */
62.macro DELIVER_PENDING_EXCEPTION
63 SETUP_CALLEE_SAVE_FRAME @ save callee saves for throw
64 mov r0, r9 @ pass Thread::Current
65 mov r1, sp @ pass SP
66 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
67.endm
68
Brian Carlstrom6f495f22011-10-10 15:05:03 -070069 .global art_do_long_jump
Brian Carlstrom6f495f22011-10-10 15:05:03 -070070 /*
71 * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_
72 */
Ian Rogersdfcdf1a2011-10-10 17:50:35 -070073art_do_long_jump:
Brian Carlstrom6f495f22011-10-10 15:05:03 -070074 vldm r1, {s0-s31} @ load all fprs from argument fprs_
75 ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15)
76 add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3
77 ldm r0, {r3-r14} @ load remaining gprs from argument gprs_
78 mov r0, #0 @ clear result registers r0 and r1
79 mov r1, #0
80 bx r2 @ do long jump
81
Ian Rogersff1ed472011-09-20 13:46:24 -070082 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070083 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070084 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
85 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
86 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070087 */
Ian Rogersff1ed472011-09-20 13:46:24 -070088art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070089 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070090 mov r1, r9 @ pass Thread::Current
91 mov r2, sp @ pass SP
92 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070093
94 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070095 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070096 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070097 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070098 */
99art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700100 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700101 mov r0, r9 @ pass Thread::Current
102 mov r1, sp @ pass SP
103 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700104
105 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700106 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700107 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700108 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -0700109 */
110art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700111 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700112 mov r0, r9 @ pass Thread::Current
113 mov r1, sp @ pass SP
114 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -0700115
116 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700117 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700118 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700119 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -0700120 */
121art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700122 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700123 mov r2, r9 @ pass Thread::Current
124 mov r3, sp @ pass SP
125 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -0700126
Ian Rogers932746a2011-09-22 18:57:50 -0700127 .global art_throw_stack_overflow_from_code
128 .extern artThrowStackOverflowFromCode
129art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700130 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700131 mov r1, r9 @ pass Thread::Current
132 mov r2, sp @ pass SP
133 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
134
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700135 .global art_throw_neg_array_size_from_code
136 .extern artThrowNegArraySizeFromCode
137art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700138 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700139 mov r1, r9 @ pass Thread::Current
140 mov r2, sp @ pass SP
141 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
142
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700143 .global art_throw_no_such_method_from_code
144 .extern artThrowNoSuchMethodFromCode
145art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700146 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700147 mov r1, r9 @ pass Thread::Current
148 mov r2, sp @ pass SP
149 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
150
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700151 .global art_throw_verification_error_from_code
152 .extern artThrowVerificationErrorFromCode
153art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700154 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700155 mov r2, r9 @ pass Thread::Current
156 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700157 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700158
buzbee4a3164f2011-09-03 11:25:10 -0700159 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700160 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700161 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700162 * All generated callsites for interface invokes will load arguments as usual - except instead
163 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
164 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
165 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
166 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700167 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700168 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
169 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700170 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700171 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
172 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700173 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700174 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
175 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700176 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700177art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700178 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
Ian Rogerscaab8c42011-10-12 12:11:18 -0700179 ldr r2, [sp, #48] @ pass caller Method*
180 mov r3, r9 @ pass Thread::Current
181 str sp, [sp, #0] @ pass SP
182 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, caller, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700183 mov r12, r1 @ save r0->code_
184 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
185 cmp r0, #0 @ did we find the target?
186 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700187 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700188
189 .global art_handle_fill_data_from_code
190 .extern artHandleFillArrayDataFromCode
191 /*
192 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
193 * failure.
194 */
195art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700196 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
197 mov r2, r9 @ pass Thread::Current
198 mov r3, sp @ pass SP
199 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
200 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
201 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700202 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700203 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700204
205 .global art_lock_object_from_code
206 .extern artLockObjectFromCode
207 /*
208 * Entry from managed code that calls artLockObjectFromCode, may block for GC
209 */
210art_lock_object_from_code:
211 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
212 mov r1, r9 @ pass Thread::Current
213 mov r2, sp @ pass SP
214 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
215 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700216
217 .global art_unlock_object_from_code
218 .extern artUnlockObjectFromCode
219 /*
220 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
221 */
222art_unlock_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700223 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
224 mov r1, r9 @ pass Thread::Current
225 mov r2, sp @ pass SP
226 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
227 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
228 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700229 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700230 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700231
232 .global art_check_cast_from_code
233 .extern artCheckCastFromCode
234 /*
235 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
236 */
237art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700238 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
239 mov r2, r9 @ pass Thread::Current
240 mov r3, sp @ pass SP
241 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
242 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
243 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700244 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700245 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700246
Ian Rogerse51a5112011-09-23 14:16:35 -0700247 .global art_can_put_array_element_from_code
248 .extern artCanPutArrayElementFromCode
249 /*
250 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
251 * failure.
252 */
253art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700254 cmp r0, #0 @ return if element == NULL
Ian Rogersae675992011-10-09 17:10:22 -0700255 bxeq lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700256 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
257 mov r2, r9 @ pass Thread::Current
258 mov r3, sp @ pass SP
259 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
260 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
261 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700262 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700263 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700264
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700265 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700266 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700267 /*
268 * Entry from managed code when uninitialized static storage, this stub will run the class
269 * initializer and deliver the exception on error. On success the static storage base is
270 * returned.
271 */
272art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700273 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
274 mov r2, r9 @ pass Thread::Current
275 mov r3, sp @ pass SP
Brian Carlstromaded5f72011-10-07 17:15:04 -0700276 @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700277 bl artInitializeStaticStorageFromCode
278 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
279 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700280 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700281 DELIVER_PENDING_EXCEPTION
282
Ian Rogers28ad40d2011-10-27 15:19:26 -0700283 .global art_initialize_type_from_code
284 .extern artInitializeTypeFromCode
285 /*
286 * Entry from managed code when dex cache misses for a type_idx
287 */
288art_initialize_type_from_code:
289 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
290 mov r2, r9 @ pass Thread::Current
291 mov r3, sp @ pass SP
292 @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
293 bl artInitializeTypeFromCode
294 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
295 cmp r0, #0 @ success if result is non-null
296 bxne lr @ return on success
297 DELIVER_PENDING_EXCEPTION
298
Ian Rogersb093c6b2011-10-31 16:19:55 -0700299 .global art_initialize_type_and_verify_access_from_code
300 .extern artInitializeTypeAndVerifyAccessFromCode
301 /*
302 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
303 * miss
304 */
305art_initialize_type_and_verify_access_from_code:
306 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
307 mov r2, r9 @ pass Thread::Current
308 mov r3, sp @ pass SP
309 @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
310 bl artInitializeTypeAndVerifyAccessFromCode
311 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
312 cmp r0, #0 @ success if result is non-null
313 bxne lr @ return on success
314 DELIVER_PENDING_EXCEPTION
315
Ian Rogersce9eca62011-10-07 17:11:03 -0700316 .global art_find_instance_field_from_code
317 .extern artFindInstanceFieldFromCode
318 /*
319 * Called by managed code to resolve a field of an object
320 */
321art_find_instance_field_from_code:
322 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
323 mov r2, r9 @ pass Thread::Current
324 mov r3, sp @ pass SP
325 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
326 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
327 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700328 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700329 DELIVER_PENDING_EXCEPTION
330
331 .global art_get32_static_from_code
332 .extern artGet32StaticFromCode
333 /*
334 * Called by managed code to resolve a static field and load a 32-bit primitive value
335 */
336art_get32_static_from_code:
337 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
338 mov r2, r9 @ pass Thread::Current
339 mov r3, sp @ pass SP
340 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
341 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
342 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
343 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700344 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700345 DELIVER_PENDING_EXCEPTION
346
347 .global art_get64_static_from_code
348 .extern artGet64StaticFromCode
349 /*
350 * Called by managed code to resolve a static field and load a 64-bit primitive value
351 */
352art_get64_static_from_code:
353 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
354 mov r2, r9 @ pass Thread::Current
355 mov r3, sp @ pass SP
356 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
357 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
358 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
359 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700360 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700361 DELIVER_PENDING_EXCEPTION
362
363 .global art_get_obj_static_from_code
364 .extern artGetObjStaticFromCode
365 /*
366 * Called by managed code to resolve a static field and load an object reference
367 */
368art_get_obj_static_from_code:
369 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
370 mov r2, r9 @ pass Thread::Current
371 mov r3, sp @ pass SP
372 bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
373 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
374 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
375 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700376 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700377 DELIVER_PENDING_EXCEPTION
378
379 .global art_set32_static_from_code
380 .extern artSet32StaticFromCode
381 /*
382 * Called by managed code to resolve a static field and store a 32-bit primitive value
383 */
384art_set32_static_from_code:
385 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
386 mov r3, r9 @ pass Thread::Current
387 str sp, [sp, #0] @ pass SP
388 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
389 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
390 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700391 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700392 DELIVER_PENDING_EXCEPTION
393
394 .global art_set64_static_from_code
395 .extern artSet32StaticFromCode
396 /*
397 * Called by managed code to resolve a static field and store a 64-bit primitive value
398 */
399art_set64_static_from_code:
400 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
401 mov r12, sp @ save SP
402 sub sp, #8 @ grow frame for alignment with stack args
403 push {r9, r12} @ pass Thread::Current and SP
404 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
405 add sp, #16 @ release out args
406 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
407 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700408 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700409 DELIVER_PENDING_EXCEPTION
410
411 .global art_set_obj_static_from_code
412 .extern artSetObjStaticFromCode
413 /*
414 * Called by managed code to resolve a static field and store an object reference
415 */
416art_set_obj_static_from_code:
417 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
418 mov r3, r9 @ pass Thread::Current
419 str sp, [sp, #0] @ pass SP
420 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
421 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
422 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700423 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700424 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700425
Brian Carlstromaded5f72011-10-07 17:15:04 -0700426 .global art_resolve_string_from_code
427 .extern artResolveStringFromCode
428 /*
Ian Rogerscaab8c42011-10-12 12:11:18 -0700429 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
430 * exception on error. On success the String is returned. R0 holds the referring method,
431 * R1 holds the string index. The fast path check for hit in strings cache has already been
432 * performed.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700433 */
Brian Carlstrom6f495f22011-10-10 15:05:03 -0700434art_resolve_string_from_code:
Ian Rogerscaab8c42011-10-12 12:11:18 -0700435 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
436 mov r2, r9 @ pass Thread::Current
437 mov r3, sp @ pass SP
438 @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP)
Brian Carlstromaded5f72011-10-07 17:15:04 -0700439 bl artResolveStringFromCode
440 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogerscaab8c42011-10-12 12:11:18 -0700441 cmp r0, #0 @ success if result is non-null
442 bxne lr @ return on success
Brian Carlstromaded5f72011-10-07 17:15:04 -0700443 DELIVER_PENDING_EXCEPTION
444
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -0700445 .global art_object_init_from_code
446 .extern artObjectInitFromCode
447 /*
448 * Entry from managed code to perform Object.<init> string. R0 holds the object to initialize.
449 * On success, 0 is returned. Otherwise there is a pending exception to deliver.
450 */
451art_object_init_from_code:
452 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
453 mov r1, r9 @ pass Thread::Current
454 mov r2, sp @ pass SP
455 @ artObjectInitFromCode(Object* o, Thread*, SP)
456 bl artObjectInitFromCode
457 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
458 cmp r0, #0 @ success if result is zero
459 bxeq lr @ return on success
460 DELIVER_PENDING_EXCEPTION
461
Ian Rogers21d9e832011-09-23 17:05:09 -0700462 .global art_alloc_object_from_code
463 .extern artAllocObjectFromCode
464 /*
465 * Called by managed code to allocate an object
466 */
467art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700468 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
469 mov r2, r9 @ pass Thread::Current
470 mov r3, sp @ pass SP
471 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
472 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
473 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700474 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700475 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700476
Ian Rogers28ad40d2011-10-27 15:19:26 -0700477 .global art_alloc_object_from_code_with_access_check
478 .extern artAllocObjectFromCodeWithAccessCheck
buzbeecc4540e2011-10-27 13:06:03 -0700479 /*
Ian Rogers28ad40d2011-10-27 15:19:26 -0700480 * Called by managed code to allocate an object when the caller doesn't know whether it has
481 * access to the created type
buzbeecc4540e2011-10-27 13:06:03 -0700482 */
Ian Rogers28ad40d2011-10-27 15:19:26 -0700483art_alloc_object_from_code_with_access_check:
buzbeecc4540e2011-10-27 13:06:03 -0700484 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
485 mov r2, r9 @ pass Thread::Current
486 mov r3, sp @ pass SP
Ian Rogers28ad40d2011-10-27 15:19:26 -0700487 bl artAllocObjectFromCodeWithAccessCheck @ (uint32_t type_idx, Method* method, Thread*, SP)
buzbeecc4540e2011-10-27 13:06:03 -0700488 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
489 cmp r0, #0 @ success if result is non-null
490 bxne lr @ return on success
491 DELIVER_PENDING_EXCEPTION
492
Elliott Hughesb408de72011-10-04 14:35:05 -0700493 .global art_alloc_array_from_code
494 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700495 /*
496 * Called by managed code to allocate an array
497 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700498art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700499 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
500 mov r3, r9 @ pass Thread::Current
501 str sp, [sp, #0] @ pass SP
502 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
503 bl artAllocArrayFromCode
504 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
505 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700506 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700507 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700508
Elliott Hughesb408de72011-10-04 14:35:05 -0700509 .global art_check_and_alloc_array_from_code
510 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700511 /*
512 * Called by managed code to allocate an array
513 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700514art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700515 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
516 mov r3, r9 @ pass Thread::Current
517 str sp, [sp, #0] @ pass SP
518 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
519 bl artCheckAndAllocArrayFromCode
520 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700521 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700522 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700523 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700524
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700525 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700526 .extern artTestSuspendFromCode
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700527 /*
528 * Called by managed code when the value in rSUSPEND has been decremented to 0
529 */
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700530art_test_suspend:
531 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
532 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
533 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
534 bxeq rLR @ return if suspend_count_ == 0
535 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700536 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700537 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700538 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700539 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
540
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700541 .global art_proxy_invoke_handler
542 .extern artProxyInvokeHandler
543 /*
544 * Called by managed code that is attempting to call a method on a proxy class. On entry
545 * r0 holds the proxy method; r1, r2 and r3 may contain arguments
546 */
547art_proxy_invoke_handler:
548 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
549 str r0, [sp, #0] @ place proxy method at bottom of frame
550 mov r2, r9 @ pass Thread::Current
551 add r3, sp, #12 @ pointer to r2/r3/LR/caller's Method**/out-args as second arg
552 blx artProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, args...)
553 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Ian Rogers466bb252011-10-14 03:29:56 -0700554 ldr lr, [sp, #44] @ restore lr
555 ldrd r0, [sp, #12] @ load r0/r1 from r2/r3 that were overwritten with the out args
556 add sp, #48 @ pop frame
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700557 cmp r12, #0 @ success if no exception is pending
558 bxeq lr @ return on success
559 DELIVER_PENDING_EXCEPTION
560
jeffhaoe343b762011-12-05 16:36:44 -0800561 .global art_trace_entry_from_code
562 .extern artTraceMethodEntryFromCode
563 /*
564 * Routine that intercepts method calls
565 */
566art_trace_entry_from_code:
567 push {r0-r3} @ save arguments (4 words)
568 mov r1, r9 @ pass Thread::Current
569 mov r2, lr @ pass LR
570 blx artTraceMethodEntryFromCode @ (Method*, Thread*, LR)
571 mov r12, r0 @ r12 holds reference to code
572 pop {r0-r3} @ restore arguments
573 blx r12 @ call method
574 /* intentional fallthrough */
575
576 .global art_trace_exit_from_code
577 .extern artTraceMethodExitFromCode
578 /*
579 * Routine that intercepts method returns
580 */
581art_trace_exit_from_code:
582 push {r0-r1} @ save return value
583 blx artTraceMethodExitFromCode @ ()
584 mov lr, r0 @ restore link register
585 pop {r0, r1} @ restore return value
586 bx lr @ return
587
buzbee54330722011-08-23 16:46:55 -0700588 .global art_shl_long
589art_shl_long:
590 /*
591 * Long integer shift. This is different from the generic 32/64-bit
592 * binary operations because vAA/vBB are 64-bit but vCC (the shift
593 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
594 * 6 bits.
595 * On entry:
596 * r0: low word
597 * r1: high word
598 * r2: shift count
599 */
600 /* shl-long vAA, vBB, vCC */
601 and r2, r2, #63 @ r2<- r2 & 0x3f
602 mov r1, r1, asl r2 @ r1<- r1 << r2
603 rsb r3, r2, #32 @ r3<- 32 - r2
604 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
605 subs ip, r2, #32 @ ip<- r2 - 32
606 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
607 mov r0, r0, asl r2 @ r0<- r0 << r2
608 bx lr
609
610 .balign 4
611 .global art_shr_long
612art_shr_long:
613 /*
614 * Long integer shift. This is different from the generic 32/64-bit
615 * binary operations because vAA/vBB are 64-bit but vCC (the shift
616 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
617 * 6 bits.
618 * On entry:
619 * r0: low word
620 * r1: high word
621 * r2: shift count
622 */
623 /* shr-long vAA, vBB, vCC */
624 and r2, r2, #63 @ r0<- r0 & 0x3f
625 mov r0, r0, lsr r2 @ r0<- r2 >> r2
626 rsb r3, r2, #32 @ r3<- 32 - r2
627 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
628 subs ip, r2, #32 @ ip<- r2 - 32
629 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
630 mov r1, r1, asr r2 @ r1<- r1 >> r2
631 bx lr
632
633 .balign 4
634 .global art_ushr_long
635art_ushr_long:
636 /*
637 * Long integer shift. This is different from the generic 32/64-bit
638 * binary operations because vAA/vBB are 64-bit but vCC (the shift
639 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
640 * 6 bits.
641 * On entry:
642 * r0: low word
643 * r1: high word
644 * r2: shift count
645 */
646 /* ushr-long vAA, vBB, vCC */
647 and r2, r2, #63 @ r0<- r0 & 0x3f
648 mov r0, r0, lsr r2 @ r0<- r2 >> r2
649 rsb r3, r2, #32 @ r3<- 32 - r2
650 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
651 subs ip, r2, #32 @ ip<- r2 - 32
652 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
653 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
654 bx lr
655
656#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700657
658#if defined(__i386__)
659
Ian Rogersff1ed472011-09-20 13:46:24 -0700660 .global art_deliver_exception_from_code
661 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700662 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700663 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700664 * that will place a mock Method* at the bottom of the stack.
665 * EAX holds the exception.
666 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700667art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700668 // Create frame
669 pushl %edi // Save callee saves
670 pushl %esi
671 pushl %ebp
672 pushl %ebx
673 pushl $0
674 pushl $0
675 pushl $0 // Will be clobbered to be Method*
676 mov %esp, %ecx
677 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700678 pushl $0 // Alignment padding
679 pushl %ecx // pass SP
680 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
681 pushl %eax // pass Throwable*
682 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700683 int3
684
Ian Rogers466bb252011-10-14 03:29:56 -0700685 // TODO
686 .global art_proxy_invoke_handler
687art_proxy_invoke_handler:
688 int3
689
Ian Rogers67375ac2011-09-14 00:55:44 -0700690#endif