blob: 8ef3da8109b85d4bb0c4194484f003c839a546ff [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
283 .global art_find_instance_field_from_code
284 .extern artFindInstanceFieldFromCode
285 /*
286 * Called by managed code to resolve a field of an object
287 */
288art_find_instance_field_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 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
293 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
294 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700295 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700296 DELIVER_PENDING_EXCEPTION
297
298 .global art_get32_static_from_code
299 .extern artGet32StaticFromCode
300 /*
301 * Called by managed code to resolve a static field and load a 32-bit primitive value
302 */
303art_get32_static_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 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
308 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
309 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
310 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700311 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700312 DELIVER_PENDING_EXCEPTION
313
314 .global art_get64_static_from_code
315 .extern artGet64StaticFromCode
316 /*
317 * Called by managed code to resolve a static field and load a 64-bit primitive value
318 */
319art_get64_static_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 artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
324 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
325 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
326 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700327 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700328 DELIVER_PENDING_EXCEPTION
329
330 .global art_get_obj_static_from_code
331 .extern artGetObjStaticFromCode
332 /*
333 * Called by managed code to resolve a static field and load an object reference
334 */
335art_get_obj_static_from_code:
336 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
337 mov r2, r9 @ pass Thread::Current
338 mov r3, sp @ pass SP
339 bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
340 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
341 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
342 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700343 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700344 DELIVER_PENDING_EXCEPTION
345
346 .global art_set32_static_from_code
347 .extern artSet32StaticFromCode
348 /*
349 * Called by managed code to resolve a static field and store a 32-bit primitive value
350 */
351art_set32_static_from_code:
352 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
353 mov r3, r9 @ pass Thread::Current
354 str sp, [sp, #0] @ pass SP
355 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
356 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
357 cmp r0, #0 @ success if result is 0
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_set64_static_from_code
362 .extern artSet32StaticFromCode
363 /*
364 * Called by managed code to resolve a static field and store a 64-bit primitive value
365 */
366art_set64_static_from_code:
367 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
368 mov r12, sp @ save SP
369 sub sp, #8 @ grow frame for alignment with stack args
370 push {r9, r12} @ pass Thread::Current and SP
371 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
372 add sp, #16 @ release out args
373 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
374 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700375 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700376 DELIVER_PENDING_EXCEPTION
377
378 .global art_set_obj_static_from_code
379 .extern artSetObjStaticFromCode
380 /*
381 * Called by managed code to resolve a static field and store an object reference
382 */
383art_set_obj_static_from_code:
384 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
385 mov r3, r9 @ pass Thread::Current
386 str sp, [sp, #0] @ pass SP
387 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
388 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
389 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700390 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700391 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700392
Brian Carlstromaded5f72011-10-07 17:15:04 -0700393 .global art_resolve_string_from_code
394 .extern artResolveStringFromCode
395 /*
Ian Rogerscaab8c42011-10-12 12:11:18 -0700396 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
397 * exception on error. On success the String is returned. R0 holds the referring method,
398 * R1 holds the string index. The fast path check for hit in strings cache has already been
399 * performed.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700400 */
Brian Carlstrom6f495f22011-10-10 15:05:03 -0700401art_resolve_string_from_code:
Ian Rogerscaab8c42011-10-12 12:11:18 -0700402 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
403 mov r2, r9 @ pass Thread::Current
404 mov r3, sp @ pass SP
405 @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP)
Brian Carlstromaded5f72011-10-07 17:15:04 -0700406 bl artResolveStringFromCode
407 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogerscaab8c42011-10-12 12:11:18 -0700408 cmp r0, #0 @ success if result is non-null
409 bxne lr @ return on success
Brian Carlstromaded5f72011-10-07 17:15:04 -0700410 DELIVER_PENDING_EXCEPTION
411
Ian Rogers21d9e832011-09-23 17:05:09 -0700412 .global art_alloc_object_from_code
413 .extern artAllocObjectFromCode
414 /*
415 * Called by managed code to allocate an object
416 */
417art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700418 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
419 mov r2, r9 @ pass Thread::Current
420 mov r3, sp @ pass SP
421 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
422 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
423 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700424 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700425 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700426
Elliott Hughesb408de72011-10-04 14:35:05 -0700427 .global art_alloc_array_from_code
428 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700429 /*
430 * Called by managed code to allocate an array
431 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700432art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700433 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
434 mov r3, r9 @ pass Thread::Current
435 str sp, [sp, #0] @ pass SP
436 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
437 bl artAllocArrayFromCode
438 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
439 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700440 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700441 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700442
Elliott Hughesb408de72011-10-04 14:35:05 -0700443 .global art_check_and_alloc_array_from_code
444 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700445 /*
446 * Called by managed code to allocate an array
447 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700448art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700449 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
450 mov r3, r9 @ pass Thread::Current
451 str sp, [sp, #0] @ pass SP
452 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
453 bl artCheckAndAllocArrayFromCode
454 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700455 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700456 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700457 DELIVER_PENDING_EXCEPTION
Ian Rogersb886da82011-09-23 16:27:54 -0700458
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700459 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700460 .extern artTestSuspendFromCode
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700461 /*
462 * Called by managed code when the value in rSUSPEND has been decremented to 0
463 */
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700464art_test_suspend:
465 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
466 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
467 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
468 bxeq rLR @ return if suspend_count_ == 0
469 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700470 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700471 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700472 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700473 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
474
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700475 .global art_proxy_invoke_handler
476 .extern artProxyInvokeHandler
477 /*
478 * Called by managed code that is attempting to call a method on a proxy class. On entry
479 * r0 holds the proxy method; r1, r2 and r3 may contain arguments
480 */
481art_proxy_invoke_handler:
482 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
483 str r0, [sp, #0] @ place proxy method at bottom of frame
484 mov r2, r9 @ pass Thread::Current
485 add r3, sp, #12 @ pointer to r2/r3/LR/caller's Method**/out-args as second arg
486 blx artProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, args...)
487 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Ian Rogers466bb252011-10-14 03:29:56 -0700488 ldr lr, [sp, #44] @ restore lr
489 ldrd r0, [sp, #12] @ load r0/r1 from r2/r3 that were overwritten with the out args
490 add sp, #48 @ pop frame
Ian Rogersdfcdf1a2011-10-10 17:50:35 -0700491 cmp r12, #0 @ success if no exception is pending
492 bxeq lr @ return on success
493 DELIVER_PENDING_EXCEPTION
494
buzbee54330722011-08-23 16:46:55 -0700495 .global art_shl_long
496art_shl_long:
497 /*
498 * Long integer shift. This is different from the generic 32/64-bit
499 * binary operations because vAA/vBB are 64-bit but vCC (the shift
500 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
501 * 6 bits.
502 * On entry:
503 * r0: low word
504 * r1: high word
505 * r2: shift count
506 */
507 /* shl-long vAA, vBB, vCC */
508 and r2, r2, #63 @ r2<- r2 & 0x3f
509 mov r1, r1, asl r2 @ r1<- r1 << r2
510 rsb r3, r2, #32 @ r3<- 32 - r2
511 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
512 subs ip, r2, #32 @ ip<- r2 - 32
513 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
514 mov r0, r0, asl r2 @ r0<- r0 << r2
515 bx lr
516
517 .balign 4
518 .global art_shr_long
519art_shr_long:
520 /*
521 * Long integer shift. This is different from the generic 32/64-bit
522 * binary operations because vAA/vBB are 64-bit but vCC (the shift
523 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
524 * 6 bits.
525 * On entry:
526 * r0: low word
527 * r1: high word
528 * r2: shift count
529 */
530 /* shr-long vAA, vBB, vCC */
531 and r2, r2, #63 @ r0<- r0 & 0x3f
532 mov r0, r0, lsr r2 @ r0<- r2 >> r2
533 rsb r3, r2, #32 @ r3<- 32 - r2
534 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
535 subs ip, r2, #32 @ ip<- r2 - 32
536 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
537 mov r1, r1, asr r2 @ r1<- r1 >> r2
538 bx lr
539
540 .balign 4
541 .global art_ushr_long
542art_ushr_long:
543 /*
544 * Long integer shift. This is different from the generic 32/64-bit
545 * binary operations because vAA/vBB are 64-bit but vCC (the shift
546 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
547 * 6 bits.
548 * On entry:
549 * r0: low word
550 * r1: high word
551 * r2: shift count
552 */
553 /* ushr-long vAA, vBB, vCC */
554 and r2, r2, #63 @ r0<- r0 & 0x3f
555 mov r0, r0, lsr r2 @ r0<- r2 >> r2
556 rsb r3, r2, #32 @ r3<- 32 - r2
557 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
558 subs ip, r2, #32 @ ip<- r2 - 32
559 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
560 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
561 bx lr
562
563#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700564
565#if defined(__i386__)
566
Ian Rogersff1ed472011-09-20 13:46:24 -0700567 .global art_deliver_exception_from_code
568 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700569 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700570 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700571 * that will place a mock Method* at the bottom of the stack.
572 * EAX holds the exception.
573 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700574art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700575 // Create frame
576 pushl %edi // Save callee saves
577 pushl %esi
578 pushl %ebp
579 pushl %ebx
580 pushl $0
581 pushl $0
582 pushl $0 // Will be clobbered to be Method*
583 mov %esp, %ecx
584 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700585 pushl $0 // Alignment padding
586 pushl %ecx // pass SP
587 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
588 pushl %eax // pass Throwable*
589 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700590 int3
591
Ian Rogers466bb252011-10-14 03:29:56 -0700592 // TODO
593 .global art_proxy_invoke_handler
594art_proxy_invoke_handler:
595 int3
596
Ian Rogers67375ac2011-09-14 00:55:44 -0700597#endif