blob: f1a6d631b9863842c408071439615cd7a858a263 [file] [log] [blame]
Ian Rogers9651f422011-09-19 20:26:07 -07001#include "asm_support.h"
2
buzbee54330722011-08-23 16:46:55 -07003#if defined(__arm__)
4
5 .balign 4
buzbee4a3164f2011-09-03 11:25:10 -07006
Ian Rogersff1ed472011-09-20 13:46:24 -07007 /* Deliver the given exception */
8 .extern artDeliverExceptionFromCode
9 /* Deliver an exception pending on a thread */
10 .extern artDeliverPendingException
11
Ian Rogers4f0d07c2011-10-06 23:38:47 -070012 /*
13 * Macro that sets up the callee save frame to conform with
14 * Runtime::CreateCalleeSaveMethod(kSaveAll)
15 */
Ian Rogers15fdb8c2011-09-25 15:45:07 -070016.macro SETUP_CALLEE_SAVE_FRAME
Ian Rogers4f0d07c2011-10-06 23:38:47 -070017 push {r4-r11, lr} @ 9 words of callee saves
Ian Rogers15fdb8c2011-09-25 15:45:07 -070018 vpush {s0-s31}
Ian Rogers4f0d07c2011-10-06 23:38:47 -070019 sub sp, #12 @ 3 words of space, bottom word will hold Method*
20.endm
21
22 /*
23 * Macro that sets up the callee save frame to conform with
24 * Runtime::CreateCalleeSaveMethod(kRefsOnly)
25 */
26.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
27 push {r5-r8, r10-r11, lr} @ 7 words of callee saves
28 sub sp, #4 @ bottom word will hold Method*
29.endm
30
31.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
32 add sp, #4
33 pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
34.endm
35
36.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
37 add sp, #4
38 pop {r5-r8, r10-r11, pc} @ 7 words of callee saves
39.endm
40
41 /*
42 * Macro that sets up the callee save frame to conform with
43 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs)
44 */
45.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
46 push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
47 sub sp, #8 @ 2 words of space, bottom word will hold Method*
48.endm
49
50.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
51 add sp, #8
52 pop {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
Ian Rogers15fdb8c2011-09-25 15:45:07 -070053.endm
54
Ian Rogersce9eca62011-10-07 17:11:03 -070055 /*
56 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
57 * exception is Thread::Current()->exception_
58 */
59.macro DELIVER_PENDING_EXCEPTION
60 SETUP_CALLEE_SAVE_FRAME @ save callee saves for throw
61 mov r0, r9 @ pass Thread::Current
62 mov r1, sp @ pass SP
63 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
64.endm
65
Ian Rogersff1ed472011-09-20 13:46:24 -070066 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070067 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070068 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
69 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
70 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070071 */
Ian Rogersff1ed472011-09-20 13:46:24 -070072art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070073 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070074 mov r1, r9 @ pass Thread::Current
75 mov r2, sp @ pass SP
76 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070077
78 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070079 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070080 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070081 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070082 */
83art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070084 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070085 mov r0, r9 @ pass Thread::Current
86 mov r1, sp @ pass SP
87 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070088
89 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070090 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070091 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070092 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -070093 */
94art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070095 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070096 mov r0, r9 @ pass Thread::Current
97 mov r1, sp @ pass SP
98 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070099
100 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -0700101 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -0700102 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700103 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -0700104 */
105art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700106 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700107 mov r2, r9 @ pass Thread::Current
108 mov r3, sp @ pass SP
109 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -0700110
Ian Rogers932746a2011-09-22 18:57:50 -0700111 .global art_throw_stack_overflow_from_code
112 .extern artThrowStackOverflowFromCode
113art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700114 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700115 mov r1, r9 @ pass Thread::Current
116 mov r2, sp @ pass SP
117 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
118
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700119 .global art_throw_neg_array_size_from_code
120 .extern artThrowNegArraySizeFromCode
121art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700122 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700123 mov r1, r9 @ pass Thread::Current
124 mov r2, sp @ pass SP
125 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
126
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700127 .global art_throw_no_such_method_from_code
128 .extern artThrowNoSuchMethodFromCode
129art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700130 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700131 mov r1, r9 @ pass Thread::Current
132 mov r2, sp @ pass SP
133 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
134
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700135 .global art_throw_verification_error_from_code
136 .extern artThrowVerificationErrorFromCode
137art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700138 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700139 mov r2, r9 @ pass Thread::Current
140 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700141 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700142
buzbee4a3164f2011-09-03 11:25:10 -0700143 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700144 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700145 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700146 * All generated callsites for interface invokes will load arguments as usual - except instead
147 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
148 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
149 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
150 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700151 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700152 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
153 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700154 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700155 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
156 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700157 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700158 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
159 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700160 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700161art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700162 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
163 mov r2, r9 @ pass Thread::Current
164 mov r3, sp @ pass SP
165 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, Thread*, SP)
166 mov r12, r1 @ save r0->code_
167 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
168 cmp r0, #0 @ did we find the target?
169 bxne r12 @ tail call to target if so
Ian Rogersce9eca62011-10-07 17:11:03 -0700170 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700171
172 .global art_handle_fill_data_from_code
173 .extern artHandleFillArrayDataFromCode
174 /*
175 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
176 * failure.
177 */
178art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700179 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
180 mov r2, r9 @ pass Thread::Current
181 mov r3, sp @ pass SP
182 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
183 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
184 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700185 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700186 DELIVER_PENDING_EXCEPTION
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700187
188 .global art_lock_object_from_code
189 .extern artLockObjectFromCode
190 /*
191 * Entry from managed code that calls artLockObjectFromCode, may block for GC
192 */
193art_lock_object_from_code:
194 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
195 mov r1, r9 @ pass Thread::Current
196 mov r2, sp @ pass SP
197 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
198 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700199
200 .global art_unlock_object_from_code
201 .extern artUnlockObjectFromCode
202 /*
203 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
204 */
205art_unlock_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700206 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
207 mov r1, r9 @ pass Thread::Current
208 mov r2, sp @ pass SP
209 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
210 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
211 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700212 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700213 DELIVER_PENDING_EXCEPTION
Ian Rogersff1ed472011-09-20 13:46:24 -0700214
215 .global art_check_cast_from_code
216 .extern artCheckCastFromCode
217 /*
218 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
219 */
220art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700221 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
222 mov r2, r9 @ pass Thread::Current
223 mov r3, sp @ pass SP
224 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
225 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
226 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700227 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700228 DELIVER_PENDING_EXCEPTION
buzbee4a3164f2011-09-03 11:25:10 -0700229
Ian Rogerse51a5112011-09-23 14:16:35 -0700230 .global art_can_put_array_element_from_code
231 .extern artCanPutArrayElementFromCode
232 /*
233 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
234 * failure.
235 */
236art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700237 cmp r0, #0 @ return if element == NULL
Ian Rogersae675992011-10-09 17:10:22 -0700238 bxeq lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700239 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
240 mov r2, r9 @ pass Thread::Current
241 mov r3, sp @ pass SP
242 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
243 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
244 cmp r0, #0 @ success?
Ian Rogersae675992011-10-09 17:10:22 -0700245 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700246 DELIVER_PENDING_EXCEPTION
Ian Rogerse51a5112011-09-23 14:16:35 -0700247
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700248 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700249 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700250 /*
251 * Entry from managed code when uninitialized static storage, this stub will run the class
252 * initializer and deliver the exception on error. On success the static storage base is
253 * returned.
254 */
255art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700256 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
257 mov r2, r9 @ pass Thread::Current
258 mov r3, sp @ pass SP
Brian Carlstromaded5f72011-10-07 17:15:04 -0700259 @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700260 bl artInitializeStaticStorageFromCode
261 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
262 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700263 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700264 DELIVER_PENDING_EXCEPTION
265
266 .global art_find_instance_field_from_code
267 .extern artFindInstanceFieldFromCode
268 /*
269 * Called by managed code to resolve a field of an object
270 */
271art_find_instance_field_from_code:
272 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
275 bl artFindInstanceFieldFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
276 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
277 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700278 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700279 DELIVER_PENDING_EXCEPTION
280
281 .global art_get32_static_from_code
282 .extern artGet32StaticFromCode
283 /*
284 * Called by managed code to resolve a static field and load a 32-bit primitive value
285 */
286art_get32_static_from_code:
287 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
288 mov r2, r9 @ pass Thread::Current
289 mov r3, sp @ pass SP
290 bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
291 ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
292 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
293 cmp r12, #0 @ success if no exception is pending
Ian Rogersae675992011-10-09 17:10:22 -0700294 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700295 DELIVER_PENDING_EXCEPTION
296
297 .global art_get64_static_from_code
298 .extern artGet64StaticFromCode
299 /*
300 * Called by managed code to resolve a static field and load a 64-bit primitive value
301 */
302art_get64_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 artGet64StaticFromCode @ (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_get_obj_static_from_code
314 .extern artGetObjStaticFromCode
315 /*
316 * Called by managed code to resolve a static field and load an object reference
317 */
318art_get_obj_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 artGetObjStaticFromCode @ (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_set32_static_from_code
330 .extern artSet32StaticFromCode
331 /*
332 * Called by managed code to resolve a static field and store a 32-bit primitive value
333 */
334art_set32_static_from_code:
335 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
336 mov r3, r9 @ pass Thread::Current
337 str sp, [sp, #0] @ pass SP
338 bl artSet32StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
339 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
340 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700341 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700342 DELIVER_PENDING_EXCEPTION
343
344 .global art_set64_static_from_code
345 .extern artSet32StaticFromCode
346 /*
347 * Called by managed code to resolve a static field and store a 64-bit primitive value
348 */
349art_set64_static_from_code:
350 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
351 mov r12, sp @ save SP
352 sub sp, #8 @ grow frame for alignment with stack args
353 push {r9, r12} @ pass Thread::Current and SP
354 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
355 add sp, #16 @ release out args
356 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here
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_set_obj_static_from_code
362 .extern artSetObjStaticFromCode
363 /*
364 * Called by managed code to resolve a static field and store an object reference
365 */
366art_set_obj_static_from_code:
367 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
368 mov r3, r9 @ pass Thread::Current
369 str sp, [sp, #0] @ pass SP
370 bl artSetObjStaticFromCode @ (field_idx, referrer, new_val, Thread*, SP)
371 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
372 cmp r0, #0 @ success if result is 0
Ian Rogersae675992011-10-09 17:10:22 -0700373 bxeq lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700374 DELIVER_PENDING_EXCEPTION
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700375
Brian Carlstromaded5f72011-10-07 17:15:04 -0700376 .global art_resolve_string_from_code
377 .extern artResolveStringFromCode
378 /*
379 * Entry from managed code to resolve a string, this stub will
380 * allocate a String and deliver an exception on error. On
381 * success the String is returned.
382 */
383 art_resolve_string_from_code:
384 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
385 mov r2, r9 @ pass Thread::Current
386 mov r3, sp @ pass SP
387 @ artResolveStringFromCode(Method* referrer, uint32_t type_idx, Thread*, SP)
388 bl artResolveStringFromCode
389 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
390 cmp r0, #0 @ success if result is non-null
391 bxne lr @ return on success
392 DELIVER_PENDING_EXCEPTION
393
Ian Rogers21d9e832011-09-23 17:05:09 -0700394 .global art_alloc_object_from_code
395 .extern artAllocObjectFromCode
396 /*
397 * Called by managed code to allocate an object
398 */
399art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -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 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
404 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
405 cmp r0, #0 @ success if result is non-null
Ian Rogersae675992011-10-09 17:10:22 -0700406 bxne lr @ return on success
Ian Rogersce9eca62011-10-07 17:11:03 -0700407 DELIVER_PENDING_EXCEPTION
Ian Rogers21d9e832011-09-23 17:05:09 -0700408
Elliott Hughesb408de72011-10-04 14:35:05 -0700409 .global art_alloc_array_from_code
410 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700411 /*
412 * Called by managed code to allocate an array
413 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700414art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700415 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
416 mov r3, r9 @ pass Thread::Current
417 str sp, [sp, #0] @ pass SP
418 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
419 bl artAllocArrayFromCode
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 Rogersb886da82011-09-23 16:27:54 -0700424
Elliott Hughesb408de72011-10-04 14:35:05 -0700425 .global art_check_and_alloc_array_from_code
426 .extern artCheckAndAllocArrayFromCode
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_check_and_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 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
435 bl artCheckAndAllocArrayFromCode
436 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersce9eca62011-10-07 17:11:03 -0700437 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
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700441 .global art_test_suspend
Ian Rogers4a510d82011-10-09 14:30:24 -0700442 .extern artTestSuspendFromCode
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700443art_test_suspend:
444 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
445 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
446 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
447 bxeq rLR @ return if suspend_count_ == 0
448 mov r0, rSELF
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700449 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
buzbeec10717a2011-10-09 14:40:13 -0700450 mov r1, sp
Ian Rogers4a510d82011-10-09 14:30:24 -0700451 bl artTestSuspendFromCode @ (Thread*, SP)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700452 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
453
buzbee54330722011-08-23 16:46:55 -0700454 .global art_shl_long
455art_shl_long:
456 /*
457 * Long integer shift. This is different from the generic 32/64-bit
458 * binary operations because vAA/vBB are 64-bit but vCC (the shift
459 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
460 * 6 bits.
461 * On entry:
462 * r0: low word
463 * r1: high word
464 * r2: shift count
465 */
466 /* shl-long vAA, vBB, vCC */
467 and r2, r2, #63 @ r2<- r2 & 0x3f
468 mov r1, r1, asl r2 @ r1<- r1 << r2
469 rsb r3, r2, #32 @ r3<- 32 - r2
470 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
471 subs ip, r2, #32 @ ip<- r2 - 32
472 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
473 mov r0, r0, asl r2 @ r0<- r0 << r2
474 bx lr
475
476 .balign 4
477 .global art_shr_long
478art_shr_long:
479 /*
480 * Long integer shift. This is different from the generic 32/64-bit
481 * binary operations because vAA/vBB are 64-bit but vCC (the shift
482 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
483 * 6 bits.
484 * On entry:
485 * r0: low word
486 * r1: high word
487 * r2: shift count
488 */
489 /* shr-long vAA, vBB, vCC */
490 and r2, r2, #63 @ r0<- r0 & 0x3f
491 mov r0, r0, lsr r2 @ r0<- r2 >> r2
492 rsb r3, r2, #32 @ r3<- 32 - r2
493 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
494 subs ip, r2, #32 @ ip<- r2 - 32
495 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
496 mov r1, r1, asr r2 @ r1<- r1 >> r2
497 bx lr
498
499 .balign 4
500 .global art_ushr_long
501art_ushr_long:
502 /*
503 * Long integer shift. This is different from the generic 32/64-bit
504 * binary operations because vAA/vBB are 64-bit but vCC (the shift
505 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
506 * 6 bits.
507 * On entry:
508 * r0: low word
509 * r1: high word
510 * r2: shift count
511 */
512 /* ushr-long vAA, vBB, vCC */
513 and r2, r2, #63 @ r0<- r0 & 0x3f
514 mov r0, r0, lsr r2 @ r0<- r2 >> r2
515 rsb r3, r2, #32 @ r3<- 32 - r2
516 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
517 subs ip, r2, #32 @ ip<- r2 - 32
518 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
519 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
520 bx lr
521
522#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700523
524#if defined(__i386__)
525
Ian Rogersff1ed472011-09-20 13:46:24 -0700526 .global art_deliver_exception_from_code
527 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700528 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700529 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700530 * that will place a mock Method* at the bottom of the stack.
531 * EAX holds the exception.
532 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700533art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700534 // Create frame
535 pushl %edi // Save callee saves
536 pushl %esi
537 pushl %ebp
538 pushl %ebx
539 pushl $0
540 pushl $0
541 pushl $0 // Will be clobbered to be Method*
542 mov %esp, %ecx
543 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700544 pushl $0 // Alignment padding
545 pushl %ecx // pass SP
546 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
547 pushl %eax // pass Throwable*
548 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700549 int3
550
551#endif