blob: cc854e9a31ce12e383ef1616ed8d96c4d777220f [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
179 mov r2, r9 @ pass Thread::Current
180 mov r3, sp @ pass SP
181 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, Thread*, SP)
182 mov r12, r1 @ save r0->code_
183 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
184 cmp r0, #0 @ did we find the target?
185 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700186 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700187
188 .global art_handle_fill_data_from_code
189 .extern artHandleFillArrayDataFromCode
190 /*
191 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
192 * failure.
193 */
194art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700195 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
196 mov r2, r9 @ pass Thread::Current
197 mov r3, sp @ pass SP
198 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
199 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
200 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700201 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700202 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700203
204 .global art_lock_object_from_code
205 .extern artLockObjectFromCode
206 /*
207 * Entry from managed code that calls artLockObjectFromCode, may block for GC
208 */
209art_lock_object_from_code:
210 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
211 mov r1, r9 @ pass Thread::Current
212 mov r2, sp @ pass SP
213 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
214 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700215
216 .global art_unlock_object_from_code
217 .extern artUnlockObjectFromCode
218 /*
219 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
220 */
221art_unlock_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700222 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
223 mov r1, r9 @ pass Thread::Current
224 mov r2, sp @ pass SP
225 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
226 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
227 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700228 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700229 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700230
231 .global art_check_cast_from_code
232 .extern artCheckCastFromCode
233 /*
234 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
235 */
236art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700237 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
238 mov r2, r9 @ pass Thread::Current
239 mov r3, sp @ pass SP
240 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
241 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
242 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700243 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700244 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700245
Ian Rogerse51a5112011-09-23 14:16:35 -0700246 .global art_can_put_array_element_from_code
247 .extern artCanPutArrayElementFromCode
248 /*
249 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
250 * failure.
251 */
252art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700253 cmp r0, #0 @ return if element == NULL
Ian Rogersae675992011-10-09 17:10:22 -0700254 bxeq lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700255 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
256 mov r2, r9 @ pass Thread::Current
257 mov r3, sp @ pass SP
258 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
259 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
260 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700261 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700262 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700263
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700264 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700265 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700266 /*
267 * Entry from managed code when uninitialized static storage, this stub will run the class
268 * initializer and deliver the exception on error. On success the static storage base is
269 * returned.
270 */
271art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700272 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
273 mov r2, r9 @ pass Thread::Current
274 mov r3, sp @ pass SP
Brian Carlstromaded5f72011-10-07 17:15:04 -0700275 @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700276 bl artInitializeStaticStorageFromCode
277 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
278 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700279 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700280 DELIVER_PENDING_EXCEPTION
281
282 .global art_find_instance_field_from_code
283 .extern artFindInstanceFieldFromCode
284 /*
285 * Called by managed code to resolve a field of an object
286 */
287art_find_instance_field_from_code:
288 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
289 mov r2, r9 @ pass Thread::Current
290 mov r3, sp @ pass SP
291 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
292 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
293 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700294 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700295 DELIVER_PENDING_EXCEPTION
296
297 .global art_get32_static_from_code
298 .extern artGet32StaticFromCode
299 /*
300 * Called by managed code to resolve a static field and load a 32-bit primitive value
301 */
302art_get32_static_from_code:
303 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
304 mov r2, r9 @ pass Thread::Current
305 mov r3, sp @ pass SP
306 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
307 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
308 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
309 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700310 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700311 DELIVER_PENDING_EXCEPTION
312
313 .global art_get64_static_from_code
314 .extern artGet64StaticFromCode
315 /*
316 * Called by managed code to resolve a static field and load a 64-bit primitive value
317 */
318art_get64_static_from_code:
319 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
320 mov r2, r9 @ pass Thread::Current
321 mov r3, sp @ pass SP
322 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
323 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
324 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
325 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700326 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700327 DELIVER_PENDING_EXCEPTION
328
329 .global art_get_obj_static_from_code
330 .extern artGetObjStaticFromCode
331 /*
332 * Called by managed code to resolve a static field and load an object reference
333 */
334art_get_obj_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 artGetObjStaticFromCode @ (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_set32_static_from_code
346 .extern artSet32StaticFromCode
347 /*
348 * Called by managed code to resolve a static field and store a 32-bit primitive value
349 */
350art_set32_static_from_code:
351 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
352 mov r3, r9 @ pass Thread::Current
353 str sp, [sp, #0] @ pass SP
354 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
355 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
356 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700357 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700358 DELIVER_PENDING_EXCEPTION
359
360 .global art_set64_static_from_code
361 .extern artSet32StaticFromCode
362 /*
363 * Called by managed code to resolve a static field and store a 64-bit primitive value
364 */
365art_set64_static_from_code:
366 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
367 mov r12, sp @ save SP
368 sub sp, #8 @ grow frame for alignment with stack args
369 push {r9, r12} @ pass Thread::Current and SP
370 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
371 add sp, #16 @ release out args
372 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
373 cmp r0, #0 @ success if result is 0
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_set_obj_static_from_code
378 .extern artSetObjStaticFromCode
379 /*
380 * Called by managed code to resolve a static field and store an object reference
381 */
382art_set_obj_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 artSetObjStaticFromCode @ (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
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700391
Brian Carlstromaded5f72011-10-07 17:15:04 -0700392 .global art_resolve_string_from_code
393 .extern artResolveStringFromCode
394 /*
395 * Entry from managed code to resolve a string, this stub will
396 * allocate a String and deliver an exception on error. On
397 * success the String is returned.
398 */
Brian Carlstrom6f495f22011-10-10 15:05:03 -0700399art_resolve_string_from_code:
Brian Carlstromaded5f72011-10-07 17:15:04 -0700400 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
401 mov r2, r9 @ pass Thread::Current
402 mov r3, sp @ pass SP
403 @ artResolveStringFromCode(Method* referrer, uint32_t type_idx, Thread*, SP)
404 bl artResolveStringFromCode
405 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
406 cmp r0, #0 @ success if result is non-null
407 bxne lr @ return on success
408 DELIVER_PENDING_EXCEPTION
409
Ian Rogers21d9e832011-09-23 17:05:09 -0700410 .global art_alloc_object_from_code
411 .extern artAllocObjectFromCode
412 /*
413 * Called by managed code to allocate an object
414 */
415art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700416 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
417 mov r2, r9 @ pass Thread::Current
418 mov r3, sp @ pass SP
419 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
420 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
421 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700422 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700423 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700424
Elliott Hughesb408de72011-10-04 14:35:05 -0700425 .global art_alloc_array_from_code
426 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700427 /*
428 * Called by managed code to allocate an array
429 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700430art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700431 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
432 mov r3, r9 @ pass Thread::Current
433 str sp, [sp, #0] @ pass SP
434 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
435 bl artAllocArrayFromCode
436 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
437 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700438 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700439 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700440
Elliott Hughesb408de72011-10-04 14:35:05 -0700441 .global art_check_and_alloc_array_from_code
442 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700443 /*
444 * Called by managed code to allocate an array
445 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700446art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700447 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
448 mov r3, r9 @ pass Thread::Current
449 str sp, [sp, #0] @ pass SP
450 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
451 bl artCheckAndAllocArrayFromCode
452 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700453 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700454 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700455 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700456
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700457 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700458 .extern artTestSuspendFromCode
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700459 /*
460 * Called by managed code when the value in rSUSPEND has been decremented to 0
461 */
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700462art_test_suspend:
463 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
464 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
465 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
466 bxeq rLR @ return if suspend_count_ == 0
467 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700468 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700469 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700470 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700471 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
472
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700473 .global art_proxy_invoke_handler
474 .extern artProxyInvokeHandler
475 /*
476 * Called by managed code that is attempting to call a method on a proxy class. On entry
477 * r0 holds the proxy method; r1, r2 and r3 may contain arguments
478 */
479art_proxy_invoke_handler:
480 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
481 str r0, [sp, #0] @ place proxy method at bottom of frame
482 mov r2, r9 @ pass Thread::Current
483 add r3, sp, #12 @ pointer to r2/r3/LR/caller's Method**/out-args as second arg
484 blx artProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, args...)
485 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
486 ldrd r0, [sp, #12] @ load r0/r1 from r2/r3 that were overwritten with the out args
487 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
488 cmp r12, #0 @ success if no exception is pending
489 bxeq lr @ return on success
490 DELIVER_PENDING_EXCEPTION
491
buzbee54330722011-08-23 16:46:55 -0700492 .global art_shl_long
493art_shl_long:
494 /*
495 * Long integer shift. This is different from the generic 32/64-bit
496 * binary operations because vAA/vBB are 64-bit but vCC (the shift
497 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
498 * 6 bits.
499 * On entry:
500 * r0: low word
501 * r1: high word
502 * r2: shift count
503 */
504 /* shl-long vAA, vBB, vCC */
505 and r2, r2, #63 @ r2<- r2 & 0x3f
506 mov r1, r1, asl r2 @ r1<- r1 << r2
507 rsb r3, r2, #32 @ r3<- 32 - r2
508 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
509 subs ip, r2, #32 @ ip<- r2 - 32
510 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
511 mov r0, r0, asl r2 @ r0<- r0 << r2
512 bx lr
513
514 .balign 4
515 .global art_shr_long
516art_shr_long:
517 /*
518 * Long integer shift. This is different from the generic 32/64-bit
519 * binary operations because vAA/vBB are 64-bit but vCC (the shift
520 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
521 * 6 bits.
522 * On entry:
523 * r0: low word
524 * r1: high word
525 * r2: shift count
526 */
527 /* shr-long vAA, vBB, vCC */
528 and r2, r2, #63 @ r0<- r0 & 0x3f
529 mov r0, r0, lsr r2 @ r0<- r2 >> r2
530 rsb r3, r2, #32 @ r3<- 32 - r2
531 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
532 subs ip, r2, #32 @ ip<- r2 - 32
533 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
534 mov r1, r1, asr r2 @ r1<- r1 >> r2
535 bx lr
536
537 .balign 4
538 .global art_ushr_long
539art_ushr_long:
540 /*
541 * Long integer shift. This is different from the generic 32/64-bit
542 * binary operations because vAA/vBB are 64-bit but vCC (the shift
543 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
544 * 6 bits.
545 * On entry:
546 * r0: low word
547 * r1: high word
548 * r2: shift count
549 */
550 /* ushr-long vAA, vBB, vCC */
551 and r2, r2, #63 @ r0<- r0 & 0x3f
552 mov r0, r0, lsr r2 @ r0<- r2 >> r2
553 rsb r3, r2, #32 @ r3<- 32 - r2
554 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
555 subs ip, r2, #32 @ ip<- r2 - 32
556 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
557 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
558 bx lr
559
560#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700561
562#if defined(__i386__)
563
Ian Rogersff1ed472011-09-20 13:46:24 -0700564 .global art_deliver_exception_from_code
565 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700566 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700567 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700568 * that will place a mock Method* at the bottom of the stack.
569 * EAX holds the exception.
570 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700571art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700572 // Create frame
573 pushl %edi // Save callee saves
574 pushl %esi
575 pushl %ebp
576 pushl %ebx
577 pushl $0
578 pushl $0
579 pushl $0 // Will be clobbered to be Method*
580 mov %esp, %ecx
581 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700582 pushl $0 // Alignment padding
583 pushl %ecx // pass SP
584 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
585 pushl %eax // pass Throwable*
586 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700587 int3
588
589#endif