Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Ian Rogers | 9651f42 | 2011-09-19 20:26:07 -0700 | [diff] [blame] | 17 | #include "asm_support.h" |
| 18 | |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 19 | /* Deliver the given exception */ |
| 20 | .extern artDeliverExceptionFromCode |
| 21 | /* Deliver an exception pending on a thread */ |
| 22 | .extern artDeliverPendingException |
| 23 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 24 | /* Cache alignment for function entry */ |
| 25 | .macro ALIGN_FUNCTION_ENTRY |
| 26 | .balign 16 |
| 27 | .endm |
| 28 | |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 29 | /* |
| 30 | * Macro that sets up the callee save frame to conform with |
| 31 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
| 32 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 33 | .macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 34 | push {r4-r11, lr} @ 9 words of callee saves |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 35 | vpush {s0-s31} |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 36 | sub sp, #12 @ 3 words of space, bottom word will hold Method* |
| 37 | .endm |
| 38 | |
| 39 | /* |
| 40 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 41 | * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC. |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 42 | */ |
| 43 | .macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME |
| 44 | push {r5-r8, r10-r11, lr} @ 7 words of callee saves |
| 45 | sub sp, #4 @ bottom word will hold Method* |
| 46 | .endm |
| 47 | |
| 48 | .macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 49 | ldr lr, [sp, #28] @ restore lr for return |
| 50 | add sp, #32 @ unwind stack |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 51 | .endm |
| 52 | |
| 53 | .macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 54 | ldr lr, [sp, #28] @ restore lr for return |
| 55 | add sp, #32 @ unwind stack |
| 56 | bx lr @ return |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 57 | .endm |
| 58 | |
| 59 | /* |
| 60 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 61 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC. |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 62 | */ |
| 63 | .macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 64 | push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves |
| 65 | sub sp, #8 @ 2 words of space, bottom word will hold Method* |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 66 | .endm |
| 67 | |
| 68 | .macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 69 | ldr r1, [sp, #8] @ restore non-callee save r1 |
| 70 | ldrd r2, [sp, #12] @ restore non-callee saves r2-r3 |
| 71 | ldr lr, [sp, #44] @ restore lr |
| 72 | add sp, #48 @ rewind sp |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 73 | .endm |
| 74 | |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 75 | /* |
| 76 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 77 | * exception is Thread::Current()->exception_ |
| 78 | */ |
| 79 | .macro DELIVER_PENDING_EXCEPTION |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 80 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME @ save callee saves for throw |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 81 | mov r0, r9 @ pass Thread::Current |
| 82 | mov r1, sp @ pass SP |
| 83 | b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP) |
| 84 | .endm |
| 85 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 86 | .macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 87 | .global \c_name |
| 88 | .extern \cxx_name |
| 89 | ALIGN_FUNCTION_ENTRY |
| 90 | \c_name: |
| 91 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 92 | mov r0, r9 @ pass Thread::Current |
| 93 | mov r1, sp @ pass SP |
| 94 | b \cxx_name @ \cxx_name(Thread*, SP) |
| 95 | .endm |
buzbee | 44b412b | 2012-02-04 08:50:53 -0800 | [diff] [blame] | 96 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 97 | .macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 98 | .global \c_name |
| 99 | .extern \cxx_name |
| 100 | ALIGN_FUNCTION_ENTRY |
| 101 | \c_name: |
| 102 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 103 | mov r1, r9 @ pass Thread::Current |
| 104 | mov r2, sp @ pass SP |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 105 | b \cxx_name @ \cxx_name(Thread*, SP) |
| 106 | .endm |
Ian Rogers | 9651f42 | 2011-09-19 20:26:07 -0700 | [diff] [blame] | 107 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 108 | .macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 109 | .global \c_name |
| 110 | .extern \cxx_name |
| 111 | ALIGN_FUNCTION_ENTRY |
| 112 | \c_name: |
| 113 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 114 | mov r2, r9 @ pass Thread::Current |
| 115 | mov r3, sp @ pass SP |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 116 | b \cxx_name @ \cxx_name(Thread*, SP) |
| 117 | .endm |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 118 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 119 | /* |
| 120 | * Called by managed code, saves callee saves and then calls artThrowException |
| 121 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 122 | */ |
| 123 | ONE_ARG_RUNTIME_EXCEPTION art_deliver_exception_from_code, artDeliverExceptionFromCode |
Ian Rogers | 932746a | 2011-09-22 18:57:50 -0700 | [diff] [blame] | 124 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 125 | /* |
| 126 | * Called by managed code to create and deliver a NullPointerException. |
| 127 | */ |
| 128 | NO_ARG_RUNTIME_EXCEPTION art_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode |
Ian Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 129 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 130 | /* |
| 131 | * Called by managed code to create and deliver an ArithmeticException. |
| 132 | */ |
| 133 | NO_ARG_RUNTIME_EXCEPTION art_throw_div_zero_from_code, artThrowDivZeroFromCode |
Ian Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 134 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 135 | /* |
| 136 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 137 | * index, arg2 holds limit. |
| 138 | */ |
| 139 | TWO_ARG_RUNTIME_EXCEPTION art_throw_array_bounds_from_code, artThrowArrayBoundsFromCode |
| 140 | |
| 141 | /* |
| 142 | * Called by managed code to create and deliver a StackOverflowError. |
| 143 | */ |
| 144 | NO_ARG_RUNTIME_EXCEPTION art_throw_stack_overflow_from_code, artThrowStackOverflowFromCode |
| 145 | |
| 146 | /* |
| 147 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 148 | */ |
| 149 | ONE_ARG_RUNTIME_EXCEPTION art_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode |
| 150 | |
| 151 | /* |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 152 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 153 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 154 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 155 | * stack and call the appropriate C helper. |
Elliott Hughes | 634eb2e | 2012-03-22 16:06:28 -0700 | [diff] [blame] | 156 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 157 | * |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 158 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 159 | * of the target Method* in r0 and method->code_ in r1. |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 160 | * |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 161 | * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the |
| 162 | * thread and we branch to another stub to deliver it. |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 163 | * |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 164 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 165 | * pointing back to the original caller. |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 166 | */ |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 167 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 168 | .global \c_name |
| 169 | .extern \cxx_name |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 170 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 171 | \c_name: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 172 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 173 | ldr r2, [sp, #48] @ pass caller Method* |
| 174 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 175 | mov r12, sp |
| 176 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 177 | bl \cxx_name @ (method_idx, this, caller, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 178 | add sp, #16 @ strip the extra frame |
Elliott Hughes | 634eb2e | 2012-03-22 16:06:28 -0700 | [diff] [blame] | 179 | mov r12, r1 @ save Method*->code_ |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 180 | RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 181 | cmp r0, #0 @ did we find the target? |
| 182 | bxne r12 @ tail call to target if so |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 183 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 184 | .endm |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 185 | |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 186 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 187 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 188 | |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 189 | INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 190 | INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 191 | INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 192 | INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 193 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 194 | .global art_update_debugger |
| 195 | .extern artUpdateDebuggerFromCode |
| 196 | /* |
| 197 | * On entry, r0 and r1 must be preserved, r2 is dex PC |
| 198 | */ |
| 199 | ALIGN_FUNCTION_ENTRY |
| 200 | art_update_debugger: |
| 201 | mov r3, r0 @ stash away r0 so that it's saved as if it were an argument |
| 202 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME |
| 203 | mov r0, r2 @ arg0 is dex PC |
| 204 | mov r1, rSELF @ arg1 is Thread* |
| 205 | mov r2, sp @ arg2 is sp |
| 206 | bl artUpdateDebuggerFromCode @ artUpdateDebuggerFromCode(int32_t, Thread*, Method**) |
| 207 | RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME |
| 208 | mov r0, r3 @ restore original r0 |
| 209 | bx lr |
| 210 | |
| 211 | .global art_do_long_jump |
| 212 | /* |
| 213 | * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_ |
| 214 | */ |
| 215 | ALIGN_FUNCTION_ENTRY |
| 216 | art_do_long_jump: |
| 217 | vldm r1, {s0-s31} @ load all fprs from argument fprs_ |
| 218 | ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15) |
| 219 | add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3 |
| 220 | ldm r0, {r3-r14} @ load remaining gprs from argument gprs_ |
| 221 | mov r0, #0 @ clear result registers r0 and r1 |
| 222 | mov r1, #0 |
| 223 | bx r2 @ do long jump |
| 224 | |
Ian Rogers | 60db5ab | 2012-02-20 17:02:00 -0800 | [diff] [blame] | 225 | .global art_work_around_app_jni_bugs |
| 226 | .extern artWorkAroundAppJniBugs |
| 227 | /* |
| 228 | * Entry point of native methods when JNI bug compatibility is enabled. |
| 229 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 230 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 60db5ab | 2012-02-20 17:02:00 -0800 | [diff] [blame] | 231 | art_work_around_app_jni_bugs: |
| 232 | @ save registers that may contain arguments and LR that will be crushed by a call |
| 233 | push {r0-r3, lr} |
| 234 | sub sp, #12 @ 3 words of space for alignment |
| 235 | mov r0, r9 @ pass Thread::Current |
| 236 | mov r1, sp @ pass SP |
| 237 | bl artWorkAroundAppJniBugs @ (Thread*, SP) |
| 238 | add sp, #12 @ rewind stack |
| 239 | mov r12, r0 @ save target address |
| 240 | pop {r0-r3, lr} @ restore possibly modified argument registers |
| 241 | bx r12 @ tail call into JNI routine |
| 242 | |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 243 | .global art_handle_fill_data_from_code |
| 244 | .extern artHandleFillArrayDataFromCode |
| 245 | /* |
| 246 | * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on |
| 247 | * failure. |
| 248 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 249 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 250 | art_handle_fill_data_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 251 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC |
| 252 | mov r2, r9 @ pass Thread::Current |
| 253 | mov r3, sp @ pass SP |
Elliott Hughes | af778e6 | 2012-05-01 18:45:31 -0700 | [diff] [blame] | 254 | bl artHandleFillArrayDataFromCode @ (Array*, const DexFile::Payload*, Thread*, SP) |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 255 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 256 | cmp r0, #0 @ success? |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 257 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 258 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 259 | |
| 260 | .global art_lock_object_from_code |
| 261 | .extern artLockObjectFromCode |
| 262 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 263 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 264 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 265 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 266 | art_lock_object_from_code: |
| 267 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block |
| 268 | mov r1, r9 @ pass Thread::Current |
| 269 | mov r2, sp @ pass SP |
| 270 | bl artLockObjectFromCode @ (Object* obj, Thread*, SP) |
| 271 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 272 | |
| 273 | .global art_unlock_object_from_code |
| 274 | .extern artUnlockObjectFromCode |
| 275 | /* |
| 276 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 277 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 278 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 279 | art_unlock_object_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 280 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC |
| 281 | mov r1, r9 @ pass Thread::Current |
| 282 | mov r2, sp @ pass SP |
| 283 | bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP) |
| 284 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 285 | cmp r0, #0 @ success? |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 286 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 287 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 288 | |
| 289 | .global art_check_cast_from_code |
| 290 | .extern artCheckCastFromCode |
| 291 | /* |
| 292 | * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. |
| 293 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 294 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 295 | art_check_cast_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 296 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC |
| 297 | mov r2, r9 @ pass Thread::Current |
| 298 | mov r3, sp @ pass SP |
| 299 | bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP) |
| 300 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 301 | cmp r0, #0 @ success? |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 302 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 303 | DELIVER_PENDING_EXCEPTION |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 304 | |
Ian Rogers | e51a511 | 2011-09-23 14:16:35 -0700 | [diff] [blame] | 305 | .global art_can_put_array_element_from_code |
| 306 | .extern artCanPutArrayElementFromCode |
| 307 | /* |
| 308 | * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on |
| 309 | * failure. |
| 310 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 311 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | e51a511 | 2011-09-23 14:16:35 -0700 | [diff] [blame] | 312 | art_can_put_array_element_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 313 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC |
| 314 | mov r2, r9 @ pass Thread::Current |
| 315 | mov r3, sp @ pass SP |
| 316 | bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP) |
| 317 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 318 | cmp r0, #0 @ success? |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 319 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 320 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | e51a511 | 2011-09-23 14:16:35 -0700 | [diff] [blame] | 321 | |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 322 | .global art_initialize_static_storage_from_code |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 323 | .extern artInitializeStaticStorageFromCode |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 324 | /* |
| 325 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 326 | * initializer and deliver the exception on error. On success the static storage base is |
| 327 | * returned. |
| 328 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 329 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 330 | art_initialize_static_storage_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 331 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 332 | mov r2, r9 @ pass Thread::Current |
| 333 | mov r3, sp @ pass SP |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 334 | @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 335 | bl artInitializeStaticStorageFromCode |
| 336 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 337 | cmp r0, #0 @ success if result is non-null |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 338 | bxne lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 339 | DELIVER_PENDING_EXCEPTION |
| 340 | |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 341 | .global art_initialize_type_from_code |
| 342 | .extern artInitializeTypeFromCode |
| 343 | /* |
| 344 | * Entry from managed code when dex cache misses for a type_idx |
| 345 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 346 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 347 | art_initialize_type_from_code: |
| 348 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 349 | mov r2, r9 @ pass Thread::Current |
| 350 | mov r3, sp @ pass SP |
| 351 | @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) |
| 352 | bl artInitializeTypeFromCode |
| 353 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 354 | cmp r0, #0 @ success if result is non-null |
| 355 | bxne lr @ return on success |
| 356 | DELIVER_PENDING_EXCEPTION |
| 357 | |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 358 | .global art_initialize_type_and_verify_access_from_code |
| 359 | .extern artInitializeTypeAndVerifyAccessFromCode |
| 360 | /* |
| 361 | * Entry from managed code when type_idx needs to be checked for access and dex cache may also |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 362 | * miss. |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 363 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 364 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 365 | art_initialize_type_and_verify_access_from_code: |
| 366 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 367 | mov r2, r9 @ pass Thread::Current |
| 368 | mov r3, sp @ pass SP |
Elliott Hughes | 8a1ea9f | 2012-04-16 20:41:17 -0700 | [diff] [blame] | 369 | @ artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 370 | bl artInitializeTypeAndVerifyAccessFromCode |
| 371 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 372 | cmp r0, #0 @ success if result is non-null |
| 373 | bxne lr @ return on success |
| 374 | DELIVER_PENDING_EXCEPTION |
| 375 | |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 376 | .global art_get32_static_from_code |
| 377 | .extern artGet32StaticFromCode |
| 378 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 379 | * Called by managed code to resolve a static field and load a 32-bit primitive value. |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 380 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 381 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 382 | art_get32_static_from_code: |
| 383 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 384 | ldr r1, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 385 | mov r2, r9 @ pass Thread::Current |
| 386 | mov r3, sp @ pass SP |
| 387 | bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) |
| 388 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 389 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 390 | cmp r12, #0 @ success if no exception is pending |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 391 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 392 | DELIVER_PENDING_EXCEPTION |
| 393 | |
| 394 | .global art_get64_static_from_code |
| 395 | .extern artGet64StaticFromCode |
| 396 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 397 | * Called by managed code to resolve a static field and load a 64-bit primitive value. |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 398 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 399 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 400 | art_get64_static_from_code: |
| 401 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 402 | ldr r1, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 403 | mov r2, r9 @ pass Thread::Current |
| 404 | mov r3, sp @ pass SP |
| 405 | bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) |
| 406 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 407 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 408 | cmp r12, #0 @ success if no exception is pending |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 409 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 410 | DELIVER_PENDING_EXCEPTION |
| 411 | |
| 412 | .global art_get_obj_static_from_code |
| 413 | .extern artGetObjStaticFromCode |
| 414 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 415 | * Called by managed code to resolve a static field and load an object reference. |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 416 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 417 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 418 | art_get_obj_static_from_code: |
| 419 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 420 | ldr r1, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 421 | mov r2, r9 @ pass Thread::Current |
| 422 | mov r3, sp @ pass SP |
| 423 | bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) |
| 424 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 425 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 426 | cmp r12, #0 @ success if no exception is pending |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 427 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 428 | DELIVER_PENDING_EXCEPTION |
| 429 | |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 430 | .global art_get32_instance_from_code |
| 431 | .extern artGet32InstanceFromCode |
| 432 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 433 | * Called by managed code to resolve an instance field and load a 32-bit primitive value. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 434 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 435 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 436 | art_get32_instance_from_code: |
| 437 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 438 | ldr r2, [sp, #32] @ pass referrer |
| 439 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 440 | mov r12, sp |
| 441 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 442 | bl artGet32InstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 443 | add sp, #16 @ strip the extra frame |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 444 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 445 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 446 | cmp r12, #0 @ success if no exception is pending |
| 447 | bxeq lr @ return on success |
| 448 | DELIVER_PENDING_EXCEPTION |
| 449 | |
| 450 | .global art_get64_instance_from_code |
| 451 | .extern artGet64InstanceFromCode |
| 452 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 453 | * Called by managed code to resolve an instance field and load a 64-bit primitive value. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 454 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 455 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 456 | art_get64_instance_from_code: |
| 457 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 458 | ldr r2, [sp, #32] @ pass referrer |
| 459 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 460 | mov r12, sp |
| 461 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 462 | bl artGet64InstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 463 | add sp, #16 @ strip the extra frame |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 464 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 465 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 466 | cmp r12, #0 @ success if no exception is pending |
| 467 | bxeq lr @ return on success |
| 468 | DELIVER_PENDING_EXCEPTION |
| 469 | |
| 470 | .global art_get_obj_instance_from_code |
| 471 | .extern artGetObjInstanceFromCode |
| 472 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 473 | * Called by managed code to resolve an instance field and load an object reference. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 474 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 475 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 476 | art_get_obj_instance_from_code: |
| 477 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 478 | ldr r2, [sp, #32] @ pass referrer |
| 479 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 480 | mov r12, sp |
| 481 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 482 | bl artGetObjInstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 483 | add sp, #16 @ strip the extra frame |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 484 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
| 485 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 486 | cmp r12, #0 @ success if no exception is pending |
| 487 | bxeq lr @ return on success |
| 488 | DELIVER_PENDING_EXCEPTION |
| 489 | |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 490 | .global art_set32_static_from_code |
| 491 | .extern artSet32StaticFromCode |
| 492 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 493 | * Called by managed code to resolve a static field and store a 32-bit primitive value. |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 494 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 495 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 496 | art_set32_static_from_code: |
| 497 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 498 | ldr r2, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 499 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 500 | mov r12, sp |
| 501 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 502 | bl artSet32StaticFromCode @ (field_idx, new_val, referrer, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 503 | add sp, #16 @ strip the extra frame |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 504 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 505 | cmp r0, #0 @ success if result is 0 |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 506 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 507 | DELIVER_PENDING_EXCEPTION |
| 508 | |
| 509 | .global art_set64_static_from_code |
Brian Carlstrom | 19abfb4 | 2012-04-01 16:58:53 -0700 | [diff] [blame] | 510 | .extern artSet64StaticFromCode |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 511 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 512 | * Called by managed code to resolve a static field and store a 64-bit primitive value. |
Brian Carlstrom | 19abfb4 | 2012-04-01 16:58:53 -0700 | [diff] [blame] | 513 | * On entry r0 holds field index, r1:r2 hold new_val |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 514 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 515 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 516 | art_set64_static_from_code: |
| 517 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Brian Carlstrom | 19abfb4 | 2012-04-01 16:58:53 -0700 | [diff] [blame] | 518 | mov r3, r2 @ pass one half of wide argument |
| 519 | mov r2, r1 @ pass other half of wide argument |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 520 | ldr r1, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 521 | mov r12, sp @ save SP |
| 522 | sub sp, #8 @ grow frame for alignment with stack args |
| 523 | push {r9, r12} @ pass Thread::Current and SP |
| 524 | bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP) |
| 525 | add sp, #16 @ release out args |
| 526 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here |
| 527 | cmp r0, #0 @ success if result is 0 |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 528 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 529 | DELIVER_PENDING_EXCEPTION |
| 530 | |
| 531 | .global art_set_obj_static_from_code |
| 532 | .extern artSetObjStaticFromCode |
| 533 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 534 | * Called by managed code to resolve a static field and store an object reference. |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 535 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 536 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 537 | art_set_obj_static_from_code: |
| 538 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 539 | ldr r2, [sp, #32] @ pass referrer |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 540 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 541 | mov r12, sp |
| 542 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 543 | bl artSetObjStaticFromCode @ (field_idx, new_val, referrer, Thread*, SP) |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 544 | add sp, #16 @ strip the extra frame |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 545 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 546 | cmp r0, #0 @ success if result is 0 |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 547 | bxeq lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 548 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 549 | |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 550 | .global art_set32_instance_from_code |
| 551 | .extern artSet32InstanceFromCode |
| 552 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 553 | * Called by managed code to resolve an instance field and store a 32-bit primitive value. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 554 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 555 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 556 | art_set32_instance_from_code: |
| 557 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 558 | ldr r3, [sp, #32] @ pass referrer |
| 559 | mov r12, sp @ save SP |
| 560 | sub sp, #8 @ grow frame for alignment with stack args |
| 561 | push {r9, r12} @ pass Thread::Current and SP |
| 562 | bl artSet32InstanceFromCode @ (field_idx, Object*, new_val, referrer, Thread*, SP) |
| 563 | add sp, #16 @ release out args |
| 564 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here |
| 565 | cmp r0, #0 @ success if result is 0 |
| 566 | bxeq lr @ return on success |
| 567 | DELIVER_PENDING_EXCEPTION |
| 568 | |
| 569 | .global art_set64_instance_from_code |
| 570 | .extern artSet32InstanceFromCode |
| 571 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 572 | * Called by managed code to resolve an instance field and store a 64-bit primitive value. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 573 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 574 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 575 | art_set64_instance_from_code: |
| 576 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 577 | mov r12, sp @ save SP |
| 578 | sub sp, #8 @ grow frame for alignment with stack args |
| 579 | push {r9, r12} @ pass Thread::Current and SP |
| 580 | bl artSet64InstanceFromCode @ (field_idx, Object*, new_val, Thread*, SP) |
| 581 | add sp, #16 @ release out args |
| 582 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here |
| 583 | cmp r0, #0 @ success if result is 0 |
| 584 | bxeq lr @ return on success |
| 585 | DELIVER_PENDING_EXCEPTION |
| 586 | |
| 587 | .global art_set_obj_instance_from_code |
| 588 | .extern artSetObjInstanceFromCode |
| 589 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 590 | * Called by managed code to resolve an instance field and store an object reference. |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 591 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 592 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 593 | art_set_obj_instance_from_code: |
| 594 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 595 | ldr r3, [sp, #32] @ pass referrer |
| 596 | mov r12, sp @ save SP |
| 597 | sub sp, #8 @ grow frame for alignment with stack args |
| 598 | push {r9, r12} @ pass Thread::Current and SP |
| 599 | bl artSetObjInstanceFromCode @ (field_idx, Object*, new_val, referrer, Thread*, SP) |
| 600 | add sp, #16 @ release out args |
| 601 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here |
| 602 | cmp r0, #0 @ success if result is 0 |
| 603 | bxeq lr @ return on success |
| 604 | DELIVER_PENDING_EXCEPTION |
| 605 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 606 | .global art_resolve_string_from_code |
| 607 | .extern artResolveStringFromCode |
| 608 | /* |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 609 | * Entry from managed code to resolve a string, this stub will allocate a String and deliver an |
| 610 | * exception on error. On success the String is returned. R0 holds the referring method, |
| 611 | * R1 holds the string index. The fast path check for hit in strings cache has already been |
| 612 | * performed. |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 613 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 614 | ALIGN_FUNCTION_ENTRY |
Brian Carlstrom | 6f495f2 | 2011-10-10 15:05:03 -0700 | [diff] [blame] | 615 | art_resolve_string_from_code: |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 616 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 617 | mov r2, r9 @ pass Thread::Current |
| 618 | mov r3, sp @ pass SP |
| 619 | @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP) |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 620 | bl artResolveStringFromCode |
| 621 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 622 | cmp r0, #0 @ success if result is non-null |
| 623 | bxne lr @ return on success |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 624 | DELIVER_PENDING_EXCEPTION |
| 625 | |
Ian Rogers | 21d9e83 | 2011-09-23 17:05:09 -0700 | [diff] [blame] | 626 | .global art_alloc_object_from_code |
| 627 | .extern artAllocObjectFromCode |
| 628 | /* |
| 629 | * Called by managed code to allocate an object |
| 630 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 631 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 21d9e83 | 2011-09-23 17:05:09 -0700 | [diff] [blame] | 632 | art_alloc_object_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 633 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 634 | mov r2, r9 @ pass Thread::Current |
| 635 | mov r3, sp @ pass SP |
| 636 | bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP) |
| 637 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 638 | cmp r0, #0 @ success if result is non-null |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 639 | bxne lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 640 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | 21d9e83 | 2011-09-23 17:05:09 -0700 | [diff] [blame] | 641 | |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 642 | .global art_alloc_object_from_code_with_access_check |
| 643 | .extern artAllocObjectFromCodeWithAccessCheck |
buzbee | cc4540e | 2011-10-27 13:06:03 -0700 | [diff] [blame] | 644 | /* |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 645 | * Called by managed code to allocate an object when the caller doesn't know whether it has |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 646 | * access to the created type. |
buzbee | cc4540e | 2011-10-27 13:06:03 -0700 | [diff] [blame] | 647 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 648 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 649 | art_alloc_object_from_code_with_access_check: |
buzbee | cc4540e | 2011-10-27 13:06:03 -0700 | [diff] [blame] | 650 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 651 | mov r2, r9 @ pass Thread::Current |
| 652 | mov r3, sp @ pass SP |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 653 | bl artAllocObjectFromCodeWithAccessCheck @ (uint32_t type_idx, Method* method, Thread*, SP) |
buzbee | cc4540e | 2011-10-27 13:06:03 -0700 | [diff] [blame] | 654 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 655 | cmp r0, #0 @ success if result is non-null |
| 656 | bxne lr @ return on success |
| 657 | DELIVER_PENDING_EXCEPTION |
| 658 | |
Elliott Hughes | b408de7 | 2011-10-04 14:35:05 -0700 | [diff] [blame] | 659 | .global art_alloc_array_from_code |
| 660 | .extern artAllocArrayFromCode |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 661 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 662 | * Called by managed code to allocate an array. |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 663 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 664 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | b408de7 | 2011-10-04 14:35:05 -0700 | [diff] [blame] | 665 | art_alloc_array_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 666 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 667 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 668 | mov r12, sp |
| 669 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 670 | @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP) |
| 671 | bl artAllocArrayFromCode |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 672 | add sp, #16 @ strip the extra frame |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 673 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 674 | cmp r0, #0 @ success if result is non-null |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 675 | bxne lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 676 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 677 | |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 678 | .global art_alloc_array_from_code_with_access_check |
| 679 | .extern artAllocArrayFromCodeWithAccessCheck |
| 680 | /* |
| 681 | * Called by managed code to allocate an array when the caller doesn't know whether it has |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 682 | * access to the created type. |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 683 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 684 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 685 | art_alloc_array_from_code_with_access_check: |
| 686 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 687 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 688 | mov r12, sp |
| 689 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 690 | @ artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, SP) |
| 691 | bl artAllocArrayFromCodeWithAccessCheck |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 692 | add sp, #16 @ strip the extra frame |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 693 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 694 | cmp r0, #0 @ success if result is non-null |
| 695 | bxne lr @ return on success |
| 696 | DELIVER_PENDING_EXCEPTION |
| 697 | |
Elliott Hughes | b408de7 | 2011-10-04 14:35:05 -0700 | [diff] [blame] | 698 | .global art_check_and_alloc_array_from_code |
| 699 | .extern artCheckAndAllocArrayFromCode |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 700 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 701 | * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 702 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 703 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | b408de7 | 2011-10-04 14:35:05 -0700 | [diff] [blame] | 704 | art_check_and_alloc_array_from_code: |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 705 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 706 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 707 | mov r12, sp |
| 708 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 709 | @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP) |
| 710 | bl artCheckAndAllocArrayFromCode |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 711 | add sp, #16 @ strip the extra frame |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 712 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 713 | cmp r0, #0 @ success if result is non-null |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 714 | bxne lr @ return on success |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 715 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | b886da8 | 2011-09-23 16:27:54 -0700 | [diff] [blame] | 716 | |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 717 | .global art_check_and_alloc_array_from_code_with_access_check |
| 718 | .extern artCheckAndAllocArrayFromCodeWithAccessCheck |
| 719 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 720 | * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 721 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 722 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 723 | art_check_and_alloc_array_from_code_with_access_check: |
| 724 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC |
| 725 | mov r3, r9 @ pass Thread::Current |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 726 | mov r12, sp |
| 727 | str r12, [sp, #-16]! @ expand the frame and pass SP |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 728 | @ artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , SP) |
| 729 | bl artCheckAndAllocArrayFromCodeWithAccessCheck |
buzbee | 865e6e0 | 2012-08-14 15:09:57 -0700 | [diff] [blame] | 730 | add sp, #16 @ strip the extra frame |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 731 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 732 | cmp r0, #0 @ success if result is non-null |
| 733 | bxne lr @ return on success |
| 734 | DELIVER_PENDING_EXCEPTION |
| 735 | |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 736 | .global art_test_suspend |
Ian Rogers | 4a510d8 | 2011-10-09 14:30:24 -0700 | [diff] [blame] | 737 | .extern artTestSuspendFromCode |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 738 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 739 | * Called by managed code when the value in rSUSPEND has been decremented to 0. |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 740 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 741 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 742 | art_test_suspend: |
Ian Rogers | 474b6da | 2012-09-25 00:20:38 -0700 | [diff] [blame] | 743 | ldrh r0, [rSELF, #THREAD_FLAGS_OFFSET] |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 744 | mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 745 | cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0 |
| 746 | bxeq rLR @ return if suspend_count_ == 0 |
| 747 | mov r0, rSELF |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 748 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl |
buzbee | c10717a | 2011-10-09 14:40:13 -0700 | [diff] [blame] | 749 | mov r1, sp |
Ian Rogers | 4a510d8 | 2011-10-09 14:30:24 -0700 | [diff] [blame] | 750 | bl artTestSuspendFromCode @ (Thread*, SP) |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 751 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 752 | |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 753 | .global art_proxy_invoke_handler |
| 754 | .extern artProxyInvokeHandler |
| 755 | /* |
| 756 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 757 | * r0 holds the proxy method; r1, r2 and r3 may contain arguments. |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 758 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 759 | ALIGN_FUNCTION_ENTRY |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 760 | art_proxy_invoke_handler: |
| 761 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME |
| 762 | str r0, [sp, #0] @ place proxy method at bottom of frame |
| 763 | mov r2, r9 @ pass Thread::Current |
| 764 | add r3, sp, #12 @ pointer to r2/r3/LR/caller's Method**/out-args as second arg |
| 765 | blx artProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, args...) |
| 766 | ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 767 | ldr lr, [sp, #44] @ restore lr |
| 768 | ldrd r0, [sp, #12] @ load r0/r1 from r2/r3 that were overwritten with the out args |
| 769 | add sp, #48 @ pop frame |
Ian Rogers | dfcdf1a | 2011-10-10 17:50:35 -0700 | [diff] [blame] | 770 | cmp r12, #0 @ success if no exception is pending |
| 771 | bxeq lr @ return on success |
| 772 | DELIVER_PENDING_EXCEPTION |
| 773 | |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 774 | .global art_instrumentation_entry_from_code |
| 775 | .global art_instrumentation_exit_from_code |
| 776 | .extern artInstrumentationMethodEntryFromCode |
| 777 | .extern artInstrumentationMethodExitFromCode |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 778 | /* |
jeffhao | 0791adc | 2012-04-04 11:14:32 -0700 | [diff] [blame] | 779 | * Routine that intercepts method calls and returns. |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 780 | */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 781 | ALIGN_FUNCTION_ENTRY |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 782 | art_instrumentation_entry_from_code: |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 783 | push {r0-r3} @ save arguments (4 words) |
| 784 | mov r1, r9 @ pass Thread::Current |
| 785 | mov r2, lr @ pass LR |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 786 | blx artInstrumentationMethodEntryFromCode @ (Method*, Thread*, LR) |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 787 | mov r12, r0 @ r12 holds reference to code |
| 788 | pop {r0-r3} @ restore arguments |
| 789 | blx r12 @ call method |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 790 | art_instrumentation_exit_from_code: |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 791 | push {r0-r1} @ save return value |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 792 | blx artInstrumentationMethodExitFromCode @ () |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 793 | mov lr, r0 @ restore link register |
| 794 | pop {r0, r1} @ restore return value |
| 795 | bx lr @ return |
| 796 | |
Ian Rogers | 324e190 | 2012-09-09 12:17:52 -0700 | [diff] [blame] | 797 | .global art_mul_long |
| 798 | /* |
| 799 | * Signed 64-bit integer multiply. |
| 800 | * |
| 801 | * Consider WXxYZ (r1r0 x r3r2) with a long multiply: |
| 802 | * WX |
| 803 | * x YZ |
| 804 | * -------- |
| 805 | * ZW ZX |
| 806 | * YW YX |
| 807 | * |
| 808 | * The low word of the result holds ZX, the high word holds |
| 809 | * (ZW+YX) + (the high overflow from ZX). YW doesn't matter because |
| 810 | * it doesn't fit in the low 64 bits. |
| 811 | * |
| 812 | * Unlike most ARM math operations, multiply instructions have |
| 813 | * restrictions on using the same register more than once (Rd and Rm |
| 814 | * cannot be the same). |
| 815 | */ |
| 816 | /* mul-long vAA, vBB, vCC */ |
| 817 | ALIGN_FUNCTION_ENTRY |
| 818 | art_mul_long: |
| 819 | push {r9 - r10} |
| 820 | mul ip, r2, r1 @ ip<- ZxW |
| 821 | umull r9, r10, r2, r0 @ r9/r10 <- ZxX |
| 822 | mla r2, r0, r3, ip @ r2<- YxX + (ZxW) |
| 823 | add r10, r2, r10 @ r10<- r10 + low(ZxW + (YxX)) |
| 824 | mov r0,r9 |
| 825 | mov r1,r10 |
| 826 | pop {r9 - r10} |
| 827 | bx lr |
| 828 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 829 | .global art_shl_long |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 830 | /* |
| 831 | * Long integer shift. This is different from the generic 32/64-bit |
| 832 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 833 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 834 | * 6 bits. |
| 835 | * On entry: |
| 836 | * r0: low word |
| 837 | * r1: high word |
| 838 | * r2: shift count |
| 839 | */ |
| 840 | /* shl-long vAA, vBB, vCC */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 841 | ALIGN_FUNCTION_ENTRY |
| 842 | art_shl_long: |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 843 | and r2, r2, #63 @ r2<- r2 & 0x3f |
| 844 | mov r1, r1, asl r2 @ r1<- r1 << r2 |
| 845 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 846 | orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2)) |
| 847 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 848 | movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32) |
| 849 | mov r0, r0, asl r2 @ r0<- r0 << r2 |
| 850 | bx lr |
| 851 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 852 | .global art_shr_long |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 853 | /* |
| 854 | * Long integer shift. This is different from the generic 32/64-bit |
| 855 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 856 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 857 | * 6 bits. |
| 858 | * On entry: |
| 859 | * r0: low word |
| 860 | * r1: high word |
| 861 | * r2: shift count |
| 862 | */ |
| 863 | /* shr-long vAA, vBB, vCC */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 864 | ALIGN_FUNCTION_ENTRY |
| 865 | art_shr_long: |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 866 | and r2, r2, #63 @ r0<- r0 & 0x3f |
| 867 | mov r0, r0, lsr r2 @ r0<- r2 >> r2 |
| 868 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 869 | orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) |
| 870 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 871 | movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32) |
| 872 | mov r1, r1, asr r2 @ r1<- r1 >> r2 |
| 873 | bx lr |
| 874 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 875 | .global art_ushr_long |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 876 | /* |
| 877 | * Long integer shift. This is different from the generic 32/64-bit |
| 878 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 879 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 880 | * 6 bits. |
| 881 | * On entry: |
| 882 | * r0: low word |
| 883 | * r1: high word |
| 884 | * r2: shift count |
| 885 | */ |
| 886 | /* ushr-long vAA, vBB, vCC */ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 887 | ALIGN_FUNCTION_ENTRY |
| 888 | art_ushr_long: |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 889 | and r2, r2, #63 @ r0<- r0 & 0x3f |
| 890 | mov r0, r0, lsr r2 @ r0<- r2 >> r2 |
| 891 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 892 | orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) |
| 893 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 894 | movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32) |
| 895 | mov r1, r1, lsr r2 @ r1<- r1 >>> r2 |
| 896 | bx lr |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 897 | |
| 898 | .balign 4 |
| 899 | .global art_indexof |
| 900 | art_indexof: |
| 901 | /* |
| 902 | * String's indexOf. |
| 903 | * |
| 904 | * On entry: |
| 905 | * r0: string object (known non-null) |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 906 | * r1: char to match (known <= 0xFFFF) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 907 | * r2: Starting offset in string data |
| 908 | */ |
| 909 | |
| 910 | push {r4, r10-r11, lr} @ 4 words of callee saves |
| 911 | ldr r3, [r0, #STRING_COUNT_OFFSET] |
| 912 | ldr r12, [r0, #STRING_OFFSET_OFFSET] |
| 913 | ldr r0, [r0, #STRING_VALUE_OFFSET] |
| 914 | |
| 915 | /* Clamp start to [0..count] */ |
| 916 | cmp r2, #0 |
| 917 | movlt r2, #0 |
| 918 | cmp r2, r3 |
| 919 | movgt r2, r3 |
| 920 | |
| 921 | /* Build a pointer to the start of string data */ |
| 922 | add r0, #STRING_DATA_OFFSET |
| 923 | add r0, r0, r12, lsl #1 |
| 924 | |
| 925 | /* Save a copy in r12 to later compute result */ |
| 926 | mov r12, r0 |
| 927 | |
| 928 | /* Build pointer to start of data to compare and pre-bias */ |
| 929 | add r0, r0, r2, lsl #1 |
| 930 | sub r0, #2 |
| 931 | |
| 932 | /* Compute iteration count */ |
| 933 | sub r2, r3, r2 |
| 934 | |
| 935 | /* |
| 936 | * At this point we have: |
| 937 | * r0: start of data to test |
| 938 | * r1: char to compare |
| 939 | * r2: iteration count |
| 940 | * r12: original start of string data |
| 941 | * r3, r4, r10, r11 available for loading string data |
| 942 | */ |
| 943 | |
| 944 | subs r2, #4 |
| 945 | blt indexof_remainder |
| 946 | |
| 947 | indexof_loop4: |
| 948 | ldrh r3, [r0, #2]! |
| 949 | ldrh r4, [r0, #2]! |
| 950 | ldrh r10, [r0, #2]! |
| 951 | ldrh r11, [r0, #2]! |
| 952 | cmp r3, r1 |
| 953 | beq match_0 |
| 954 | cmp r4, r1 |
| 955 | beq match_1 |
| 956 | cmp r10, r1 |
| 957 | beq match_2 |
| 958 | cmp r11, r1 |
| 959 | beq match_3 |
| 960 | subs r2, #4 |
| 961 | bge indexof_loop4 |
| 962 | |
| 963 | indexof_remainder: |
| 964 | adds r2, #4 |
| 965 | beq indexof_nomatch |
| 966 | |
| 967 | indexof_loop1: |
| 968 | ldrh r3, [r0, #2]! |
| 969 | cmp r3, r1 |
| 970 | beq match_3 |
| 971 | subs r2, #1 |
| 972 | bne indexof_loop1 |
| 973 | |
| 974 | indexof_nomatch: |
| 975 | mov r0, #-1 |
| 976 | pop {r4, r10-r11, pc} |
| 977 | |
| 978 | match_0: |
| 979 | sub r0, #6 |
| 980 | sub r0, r12 |
| 981 | asr r0, r0, #1 |
| 982 | pop {r4, r10-r11, pc} |
| 983 | match_1: |
| 984 | sub r0, #4 |
| 985 | sub r0, r12 |
| 986 | asr r0, r0, #1 |
| 987 | pop {r4, r10-r11, pc} |
| 988 | match_2: |
| 989 | sub r0, #2 |
| 990 | sub r0, r12 |
| 991 | asr r0, r0, #1 |
| 992 | pop {r4, r10-r11, pc} |
| 993 | match_3: |
| 994 | sub r0, r12 |
| 995 | asr r0, r0, #1 |
| 996 | pop {r4, r10-r11, pc} |
| 997 | |
| 998 | |
| 999 | /* |
| 1000 | * String's compareTo. |
| 1001 | * |
| 1002 | * Requires rARG0/rARG1 to have been previously checked for null. Will |
| 1003 | * return negative if this's string is < comp, 0 if they are the |
| 1004 | * same and positive if >. |
| 1005 | * |
| 1006 | * On entry: |
| 1007 | * r0: this object pointer |
| 1008 | * r1: comp object pointer |
| 1009 | * |
| 1010 | */ |
| 1011 | |
| 1012 | .balign 4 |
| 1013 | .global art_string_compareto |
| 1014 | .extern __memcmp16 |
| 1015 | art_string_compareto: |
| 1016 | mov r2, r0 @ this to r2, opening up r0 for return value |
| 1017 | subs r0, r2, r1 @ Same? |
| 1018 | bxeq lr |
| 1019 | |
| 1020 | push {r4, r7-r12, lr} @ 8 words - keep alignment |
| 1021 | |
| 1022 | ldr r4, [r2, #STRING_OFFSET_OFFSET] |
| 1023 | ldr r9, [r1, #STRING_OFFSET_OFFSET] |
| 1024 | ldr r7, [r2, #STRING_COUNT_OFFSET] |
| 1025 | ldr r10, [r1, #STRING_COUNT_OFFSET] |
| 1026 | ldr r2, [r2, #STRING_VALUE_OFFSET] |
| 1027 | ldr r1, [r1, #STRING_VALUE_OFFSET] |
| 1028 | |
| 1029 | /* |
| 1030 | * At this point, we have: |
| 1031 | * value: r2/r1 |
| 1032 | * offset: r4/r9 |
| 1033 | * count: r7/r10 |
| 1034 | * We're going to compute |
| 1035 | * r11 <- countDiff |
| 1036 | * r10 <- minCount |
| 1037 | */ |
| 1038 | subs r11, r7, r10 |
| 1039 | movls r10, r7 |
| 1040 | |
| 1041 | /* Now, build pointers to the string data */ |
| 1042 | add r2, r2, r4, lsl #1 |
| 1043 | add r1, r1, r9, lsl #1 |
| 1044 | /* |
| 1045 | * Note: data pointers point to previous element so we can use pre-index |
| 1046 | * mode with base writeback. |
| 1047 | */ |
| 1048 | add r2, #STRING_DATA_OFFSET-2 @ offset to contents[-1] |
| 1049 | add r1, #STRING_DATA_OFFSET-2 @ offset to contents[-1] |
| 1050 | |
| 1051 | /* |
| 1052 | * At this point we have: |
| 1053 | * r2: *this string data |
| 1054 | * r1: *comp string data |
| 1055 | * r10: iteration count for comparison |
| 1056 | * r11: value to return if the first part of the string is equal |
| 1057 | * r0: reserved for result |
| 1058 | * r3, r4, r7, r8, r9, r12 available for loading string data |
| 1059 | */ |
| 1060 | |
| 1061 | subs r10, #2 |
| 1062 | blt do_remainder2 |
| 1063 | |
| 1064 | /* |
| 1065 | * Unroll the first two checks so we can quickly catch early mismatch |
| 1066 | * on long strings (but preserve incoming alignment) |
| 1067 | */ |
| 1068 | |
| 1069 | ldrh r3, [r2, #2]! |
| 1070 | ldrh r4, [r1, #2]! |
| 1071 | ldrh r7, [r2, #2]! |
| 1072 | ldrh r8, [r1, #2]! |
| 1073 | subs r0, r3, r4 |
| 1074 | subeqs r0, r7, r8 |
| 1075 | bne done |
| 1076 | cmp r10, #28 |
| 1077 | bgt do_memcmp16 |
| 1078 | subs r10, #3 |
| 1079 | blt do_remainder |
| 1080 | |
| 1081 | loopback_triple: |
| 1082 | ldrh r3, [r2, #2]! |
| 1083 | ldrh r4, [r1, #2]! |
| 1084 | ldrh r7, [r2, #2]! |
| 1085 | ldrh r8, [r1, #2]! |
| 1086 | ldrh r9, [r2, #2]! |
| 1087 | ldrh r12,[r1, #2]! |
| 1088 | subs r0, r3, r4 |
| 1089 | subeqs r0, r7, r8 |
| 1090 | subeqs r0, r9, r12 |
| 1091 | bne done |
| 1092 | subs r10, #3 |
| 1093 | bge loopback_triple |
| 1094 | |
| 1095 | do_remainder: |
| 1096 | adds r10, #3 |
| 1097 | beq returnDiff |
| 1098 | |
| 1099 | loopback_single: |
| 1100 | ldrh r3, [r2, #2]! |
| 1101 | ldrh r4, [r1, #2]! |
| 1102 | subs r0, r3, r4 |
| 1103 | bne done |
| 1104 | subs r10, #1 |
| 1105 | bne loopback_single |
| 1106 | |
| 1107 | returnDiff: |
| 1108 | mov r0, r11 |
| 1109 | pop {r4, r7-r12, pc} |
| 1110 | |
| 1111 | do_remainder2: |
| 1112 | adds r10, #2 |
| 1113 | bne loopback_single |
| 1114 | mov r0, r11 |
| 1115 | pop {r4, r7-r12, pc} |
| 1116 | |
| 1117 | /* Long string case */ |
| 1118 | do_memcmp16: |
| 1119 | mov r7, r11 |
| 1120 | add r0, r2, #2 |
| 1121 | add r1, r1, #2 |
| 1122 | mov r2, r10 |
| 1123 | bl __memcmp16 |
| 1124 | cmp r0, #0 |
| 1125 | moveq r0, r7 |
| 1126 | done: |
| 1127 | pop {r4, r7-r12, pc} |