Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
| 17 | #include "asm_support_mips64.S" |
| 18 | |
| 19 | #include "arch/quick_alloc_entrypoints.S" |
| 20 | |
| 21 | .set noreorder |
| 22 | .balign 16 |
| 23 | |
| 24 | /* Deliver the given exception */ |
| 25 | .extern artDeliverExceptionFromCode |
| 26 | /* Deliver an exception pending on a thread */ |
| 27 | .extern artDeliverPendingExceptionFromCode |
| 28 | |
| 29 | /* |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 30 | * Macro that sets up $gp and stores the previous $gp value to $t8. |
| 31 | * This macro modifies v1 and t8. |
| 32 | */ |
| 33 | .macro SETUP_GP |
| 34 | move $v1, $ra |
| 35 | bal 1f |
| 36 | nop |
| 37 | 1: |
| 38 | .cpsetup $ra, $t8, 1b |
| 39 | move $ra, $v1 |
| 40 | .endm |
| 41 | |
| 42 | /* |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 43 | * Macro that sets up the callee save frame to conform with |
| 44 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
| 45 | * callee-save: padding + $f24-$f31 + $s0-$s7 + $gp + $ra + $s8 = 19 total + 1x8 bytes padding |
| 46 | */ |
| 47 | .macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 48 | daddiu $sp, $sp, -160 |
| 49 | .cfi_adjust_cfa_offset 160 |
| 50 | |
| 51 | // Ugly compile-time check, but we only have the preprocessor. |
| 52 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 160) |
| 53 | #error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 54 | #endif |
| 55 | |
| 56 | sd $ra, 152($sp) |
| 57 | .cfi_rel_offset 31, 152 |
| 58 | sd $s8, 144($sp) |
| 59 | .cfi_rel_offset 30, 144 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 60 | sd $t8, 136($sp) # t8 holds caller's gp, now save it to the stack. |
| 61 | .cfi_rel_offset 28, 136 # Value from gp is pushed, so set the cfi offset accordingly. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 62 | sd $s7, 128($sp) |
| 63 | .cfi_rel_offset 23, 128 |
| 64 | sd $s6, 120($sp) |
| 65 | .cfi_rel_offset 22, 120 |
| 66 | sd $s5, 112($sp) |
| 67 | .cfi_rel_offset 21, 112 |
| 68 | sd $s4, 104($sp) |
| 69 | .cfi_rel_offset 20, 104 |
| 70 | sd $s3, 96($sp) |
| 71 | .cfi_rel_offset 19, 96 |
| 72 | sd $s2, 88($sp) |
| 73 | .cfi_rel_offset 18, 88 |
| 74 | sd $s1, 80($sp) |
| 75 | .cfi_rel_offset 17, 80 |
| 76 | sd $s0, 72($sp) |
| 77 | .cfi_rel_offset 16, 72 |
| 78 | |
| 79 | // FP callee-saves |
| 80 | s.d $f31, 64($sp) |
| 81 | s.d $f30, 56($sp) |
| 82 | s.d $f29, 48($sp) |
| 83 | s.d $f28, 40($sp) |
| 84 | s.d $f27, 32($sp) |
| 85 | s.d $f26, 24($sp) |
| 86 | s.d $f25, 16($sp) |
| 87 | s.d $f24, 8($sp) |
| 88 | |
| 89 | # load appropriate callee-save-method |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 90 | ld $t1, %got(_ZN3art7Runtime9instance_E)($gp) |
| 91 | ld $t1, 0($t1) |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 92 | ld $t1, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t1) |
| 93 | sd $t1, 0($sp) # Place ArtMethod* at bottom of stack. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 94 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 95 | .endm |
| 96 | |
| 97 | /* |
| 98 | * Macro that sets up the callee save frame to conform with |
| 99 | * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes |
| 100 | * non-moving GC. |
| 101 | * Does not include rSUSPEND or rSELF |
| 102 | * callee-save: padding + $s2-$s7 + $gp + $ra + $s8 = 9 total + 1x8 bytes padding |
| 103 | */ |
| 104 | .macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
| 105 | daddiu $sp, $sp, -80 |
| 106 | .cfi_adjust_cfa_offset 80 |
| 107 | |
| 108 | // Ugly compile-time check, but we only have the preprocessor. |
| 109 | #if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 80) |
| 110 | #error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 111 | #endif |
| 112 | |
| 113 | sd $ra, 72($sp) |
| 114 | .cfi_rel_offset 31, 72 |
| 115 | sd $s8, 64($sp) |
| 116 | .cfi_rel_offset 30, 64 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 117 | sd $t8, 56($sp) # t8 holds caller's gp, now save it to the stack. |
| 118 | .cfi_rel_offset 28, 56 # Value from gp is pushed, so set the cfi offset accordingly. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 119 | sd $s7, 48($sp) |
| 120 | .cfi_rel_offset 23, 48 |
| 121 | sd $s6, 40($sp) |
| 122 | .cfi_rel_offset 22, 40 |
| 123 | sd $s5, 32($sp) |
| 124 | .cfi_rel_offset 21, 32 |
| 125 | sd $s4, 24($sp) |
| 126 | .cfi_rel_offset 20, 24 |
| 127 | sd $s3, 16($sp) |
| 128 | .cfi_rel_offset 19, 16 |
| 129 | sd $s2, 8($sp) |
| 130 | .cfi_rel_offset 18, 8 |
| 131 | # load appropriate callee-save-method |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 132 | ld $t1, %got(_ZN3art7Runtime9instance_E)($gp) |
| 133 | ld $t1, 0($t1) |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 134 | ld $t1, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t1) |
| 135 | sd $t1, 0($sp) # Place Method* at bottom of stack. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 136 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 137 | .endm |
| 138 | |
| 139 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 140 | ld $ra, 72($sp) |
| 141 | .cfi_restore 31 |
| 142 | ld $s8, 64($sp) |
| 143 | .cfi_restore 30 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 144 | ld $t8, 56($sp) # Restore gp back to it's temp storage. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 145 | .cfi_restore 28 |
| 146 | ld $s7, 48($sp) |
| 147 | .cfi_restore 23 |
| 148 | ld $s6, 40($sp) |
| 149 | .cfi_restore 22 |
| 150 | ld $s5, 32($sp) |
| 151 | .cfi_restore 21 |
| 152 | ld $s4, 24($sp) |
| 153 | .cfi_restore 20 |
| 154 | ld $s3, 16($sp) |
| 155 | .cfi_restore 19 |
| 156 | ld $s2, 8($sp) |
| 157 | .cfi_restore 18 |
| 158 | daddiu $sp, $sp, 80 |
| 159 | .cfi_adjust_cfa_offset -80 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 160 | .cpreturn |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 161 | .endm |
| 162 | |
| 163 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 164 | ld $ra, 72($sp) |
| 165 | .cfi_restore 31 |
| 166 | ld $s8, 64($sp) |
| 167 | .cfi_restore 30 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 168 | ld $t8, 56($sp) # Restore gp back to it's temp storage. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 169 | .cfi_restore 28 |
| 170 | ld $s7, 48($sp) |
| 171 | .cfi_restore 23 |
| 172 | ld $s6, 40($sp) |
| 173 | .cfi_restore 22 |
| 174 | ld $s5, 32($sp) |
| 175 | .cfi_restore 21 |
| 176 | ld $s4, 24($sp) |
| 177 | .cfi_restore 20 |
| 178 | ld $s3, 16($sp) |
| 179 | .cfi_restore 19 |
| 180 | ld $s2, 8($sp) |
| 181 | .cfi_restore 18 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 182 | .cpreturn |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 183 | jalr $zero, $ra |
| 184 | daddiu $sp, $sp, 80 |
| 185 | .cfi_adjust_cfa_offset -80 |
| 186 | .endm |
| 187 | |
| 188 | // This assumes the top part of these stack frame types are identical. |
| 189 | #define REFS_AND_ARGS_MINUS_REFS_SIZE (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE - FRAME_SIZE_REFS_ONLY_CALLEE_SAVE) |
| 190 | |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 191 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 192 | daddiu $sp, $sp, -208 |
| 193 | .cfi_adjust_cfa_offset 208 |
| 194 | |
| 195 | // Ugly compile-time check, but we only have the preprocessor. |
| 196 | #if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 208) |
| 197 | #error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 198 | #endif |
| 199 | |
| 200 | sd $ra, 200($sp) # = kQuickCalleeSaveFrame_RefAndArgs_LrOffset |
| 201 | .cfi_rel_offset 31, 200 |
| 202 | sd $s8, 192($sp) |
| 203 | .cfi_rel_offset 30, 192 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 204 | sd $t8, 184($sp) # t8 holds caller's gp, now save it to the stack. |
| 205 | .cfi_rel_offset 28, 184 # Value from gp is pushed, so set the cfi offset accordingly. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 206 | sd $s7, 176($sp) |
| 207 | .cfi_rel_offset 23, 176 |
| 208 | sd $s6, 168($sp) |
| 209 | .cfi_rel_offset 22, 168 |
| 210 | sd $s5, 160($sp) |
| 211 | .cfi_rel_offset 21, 160 |
| 212 | sd $s4, 152($sp) |
| 213 | .cfi_rel_offset 20, 152 |
| 214 | sd $s3, 144($sp) |
| 215 | .cfi_rel_offset 19, 144 |
| 216 | sd $s2, 136($sp) |
| 217 | .cfi_rel_offset 18, 136 |
| 218 | |
| 219 | sd $a7, 128($sp) |
| 220 | .cfi_rel_offset 11, 128 |
| 221 | sd $a6, 120($sp) |
| 222 | .cfi_rel_offset 10, 120 |
| 223 | sd $a5, 112($sp) |
| 224 | .cfi_rel_offset 9, 112 |
| 225 | sd $a4, 104($sp) |
| 226 | .cfi_rel_offset 8, 104 |
| 227 | sd $a3, 96($sp) |
| 228 | .cfi_rel_offset 7, 96 |
| 229 | sd $a2, 88($sp) |
| 230 | .cfi_rel_offset 6, 88 |
| 231 | sd $a1, 80($sp) # = kQuickCalleeSaveFrame_RefAndArgs_Gpr1Offset |
| 232 | .cfi_rel_offset 5, 80 |
| 233 | |
| 234 | s.d $f19, 72($sp) |
| 235 | s.d $f18, 64($sp) |
| 236 | s.d $f17, 56($sp) |
| 237 | s.d $f16, 48($sp) |
| 238 | s.d $f15, 40($sp) |
| 239 | s.d $f14, 32($sp) |
| 240 | s.d $f13, 24($sp) # = kQuickCalleeSaveFrame_RefAndArgs_Fpr1Offset |
| 241 | s.d $f12, 16($sp) # This isn't necessary to store. |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 242 | # 1x8 bytes padding + Method* |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 243 | .endm |
| 244 | |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 245 | /* |
| 246 | * Macro that sets up the callee save frame to conform with |
| 247 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes |
| 248 | * non-moving GC. |
| 249 | * callee-save: padding + $f12-$f19 + $a1-$a7 + $s2-$s7 + $gp + $ra + $s8 = 24 total + 1 words padding + Method* |
| 250 | */ |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 251 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 252 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 253 | # load appropriate callee-save-method |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 254 | ld $t1, %got(_ZN3art7Runtime9instance_E)($gp) |
| 255 | ld $t1, 0($t1) |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 256 | ld $t1, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t1) |
| 257 | sd $t1, 0($sp) # Place Method* at bottom of stack. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 258 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 259 | .endm |
| 260 | |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 261 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0 |
| 262 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 263 | sd $a0, 0($sp) # Place Method* at bottom of stack. |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 264 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 265 | .endm |
| 266 | |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 267 | .macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 268 | ld $ra, 200($sp) |
| 269 | .cfi_restore 31 |
| 270 | ld $s8, 192($sp) |
| 271 | .cfi_restore 30 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 272 | ld $t8, 184($sp) # Restore gp back to it's temp storage. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 273 | .cfi_restore 28 |
| 274 | ld $s7, 176($sp) |
| 275 | .cfi_restore 23 |
| 276 | ld $s6, 168($sp) |
| 277 | .cfi_restore 22 |
| 278 | ld $s5, 160($sp) |
| 279 | .cfi_restore 21 |
| 280 | ld $s4, 152($sp) |
| 281 | .cfi_restore 20 |
| 282 | ld $s3, 144($sp) |
| 283 | .cfi_restore 19 |
| 284 | ld $s2, 136($sp) |
| 285 | .cfi_restore 18 |
| 286 | |
| 287 | ld $a7, 128($sp) |
| 288 | .cfi_restore 11 |
| 289 | ld $a6, 120($sp) |
| 290 | .cfi_restore 10 |
| 291 | ld $a5, 112($sp) |
| 292 | .cfi_restore 9 |
| 293 | ld $a4, 104($sp) |
| 294 | .cfi_restore 8 |
| 295 | ld $a3, 96($sp) |
| 296 | .cfi_restore 7 |
| 297 | ld $a2, 88($sp) |
| 298 | .cfi_restore 6 |
| 299 | ld $a1, 80($sp) |
| 300 | .cfi_restore 5 |
| 301 | |
| 302 | l.d $f19, 72($sp) |
| 303 | l.d $f18, 64($sp) |
| 304 | l.d $f17, 56($sp) |
| 305 | l.d $f16, 48($sp) |
| 306 | l.d $f15, 40($sp) |
| 307 | l.d $f14, 32($sp) |
| 308 | l.d $f13, 24($sp) |
| 309 | l.d $f12, 16($sp) |
| 310 | |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 311 | .cpreturn |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 312 | daddiu $sp, $sp, 208 |
| 313 | .cfi_adjust_cfa_offset -208 |
| 314 | .endm |
| 315 | |
| 316 | /* |
| 317 | * Macro that set calls through to artDeliverPendingExceptionFromCode, |
| 318 | * where the pending |
| 319 | * exception is Thread::Current()->exception_ |
| 320 | */ |
| 321 | .macro DELIVER_PENDING_EXCEPTION |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 322 | SETUP_GP |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 323 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw |
| 324 | dla $t9, artDeliverPendingExceptionFromCode |
| 325 | jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*) |
| 326 | move $a0, rSELF # pass Thread::Current |
| 327 | .endm |
| 328 | |
| 329 | .macro RETURN_IF_NO_EXCEPTION |
| 330 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 331 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 332 | bne $t0, $zero, 1f # success if no exception is pending |
| 333 | nop |
| 334 | jalr $zero, $ra |
| 335 | nop |
| 336 | 1: |
| 337 | DELIVER_PENDING_EXCEPTION |
| 338 | .endm |
| 339 | |
| 340 | .macro RETURN_IF_ZERO |
| 341 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 342 | bne $v0, $zero, 1f # success? |
| 343 | nop |
| 344 | jalr $zero, $ra # return on success |
| 345 | nop |
| 346 | 1: |
| 347 | DELIVER_PENDING_EXCEPTION |
| 348 | .endm |
| 349 | |
| 350 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 351 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 352 | beq $v0, $zero, 1f # success? |
| 353 | nop |
| 354 | jalr $zero, $ra # return on success |
| 355 | nop |
| 356 | 1: |
| 357 | DELIVER_PENDING_EXCEPTION |
| 358 | .endm |
| 359 | |
| 360 | /* |
Goran Jakovljevic | 3bc1381 | 2016-03-22 17:16:05 +0100 | [diff] [blame^] | 361 | * On stack replacement stub. |
| 362 | * On entry: |
| 363 | * a0 = stack to copy |
| 364 | * a1 = size of stack |
| 365 | * a2 = pc to call |
| 366 | * a3 = JValue* result |
| 367 | * a4 = shorty |
| 368 | * a5 = thread |
| 369 | */ |
| 370 | ENTRY art_quick_osr_stub |
| 371 | move $t0, $sp # save stack pointer |
| 372 | daddiu $t1, $sp, -112 # reserve stack space |
| 373 | dsrl $t1, $t1, 4 # enforce 16 byte stack alignment |
| 374 | dsll $sp, $t1, 4 # update stack pointer |
| 375 | |
| 376 | // Save callee general purpose registers, SP, T8(GP), RA, A3, and A4 (8x14 bytes) |
| 377 | sd $ra, 104($sp) |
| 378 | .cfi_rel_offset 31, 104 |
| 379 | sd $s8, 96($sp) |
| 380 | .cfi_rel_offset 30, 96 |
| 381 | sd $t0, 88($sp) # save original stack pointer stored in t0 |
| 382 | .cfi_rel_offset 29, 88 |
| 383 | sd $t8, 80($sp) # t8 holds caller's gp, now save it to the stack. |
| 384 | .cfi_rel_offset 28, 80 # Value from gp is pushed, so set the cfi offset accordingly. |
| 385 | sd $s7, 72($sp) |
| 386 | .cfi_rel_offset 23, 72 |
| 387 | sd $s6, 64($sp) |
| 388 | .cfi_rel_offset 22, 64 |
| 389 | sd $s5, 56($sp) |
| 390 | .cfi_rel_offset 21, 56 |
| 391 | sd $s4, 48($sp) |
| 392 | .cfi_rel_offset 20, 48 |
| 393 | sd $s3, 40($sp) |
| 394 | .cfi_rel_offset 19, 40 |
| 395 | sd $s2, 32($sp) |
| 396 | .cfi_rel_offset 18, 32 |
| 397 | sd $s1, 24($sp) |
| 398 | .cfi_rel_offset 17, 24 |
| 399 | sd $s0, 16($sp) |
| 400 | .cfi_rel_offset 16, 16 |
| 401 | sd $a4, 8($sp) |
| 402 | .cfi_rel_offset 8, 8 |
| 403 | sd $a3, 0($sp) |
| 404 | .cfi_rel_offset 7, 0 |
| 405 | move rSELF, $a5 # Save managed thread pointer into rSELF |
| 406 | |
| 407 | daddiu $sp, $sp, -16 |
| 408 | jal .Losr_entry |
| 409 | sd $zero, 0($sp) # Store null for ArtMethod* at bottom of frame |
| 410 | daddiu $sp, $sp, 16 |
| 411 | |
| 412 | // Restore return value address and shorty address |
| 413 | ld $a4, 8($sp) # shorty address |
| 414 | .cfi_restore 8 |
| 415 | ld $a3, 0($sp) # result value address |
| 416 | .cfi_restore 7 |
| 417 | |
| 418 | lbu $t1, 0($a4) # load return type |
| 419 | li $t2, 'D' # put char 'D' into t2 |
| 420 | beq $t1, $t2, .Losr_fp_result # branch if result type char == 'D' |
| 421 | li $t2, 'F' # put char 'F' into t2 |
| 422 | beq $t1, $t2, .Losr_fp_result # branch if result type char == 'F' |
| 423 | nop |
| 424 | b .Losr_exit |
| 425 | dsrl $v1, $v0, 32 # put high half of result in v1 |
| 426 | .Losr_fp_result: |
| 427 | mfc1 $v0, $f0 |
| 428 | mfhc1 $v1, $f0 # put high half of FP result in v1 |
| 429 | .Losr_exit: |
| 430 | sw $v0, 0($a3) # store low half of result |
| 431 | sw $v1, 4($a3) # store high half of result |
| 432 | |
| 433 | // Restore callee registers |
| 434 | ld $ra, 104($sp) |
| 435 | .cfi_restore 31 |
| 436 | ld $s8, 96($sp) |
| 437 | .cfi_restore 30 |
| 438 | ld $t0, 88($sp) # save SP into t0 for now |
| 439 | .cfi_restore 29 |
| 440 | ld $t8, 80($sp) # Restore gp back to it's temp storage. |
| 441 | .cfi_restore 28 |
| 442 | ld $s7, 72($sp) |
| 443 | .cfi_restore 23 |
| 444 | ld $s6, 64($sp) |
| 445 | .cfi_restore 22 |
| 446 | ld $s5, 56($sp) |
| 447 | .cfi_restore 21 |
| 448 | ld $s4, 48($sp) |
| 449 | .cfi_restore 20 |
| 450 | ld $s3, 40($sp) |
| 451 | .cfi_restore 19 |
| 452 | ld $s2, 32($sp) |
| 453 | .cfi_restore 18 |
| 454 | ld $s1, 24($sp) |
| 455 | .cfi_restore 17 |
| 456 | ld $s0, 16($sp) |
| 457 | .cfi_restore 16 |
| 458 | jalr $zero, $ra |
| 459 | move $sp, $t0 |
| 460 | |
| 461 | .Losr_entry: |
| 462 | dsubu $sp, $sp, $a1 # Reserve space for callee stack |
| 463 | daddiu $a1, $a1, -8 |
| 464 | daddu $t0, $a1, $sp |
| 465 | sw $ra, 0($t0) # Store low half of RA per compiler ABI |
| 466 | dsrl $t1, $ra, 32 |
| 467 | sw $t1, 4($t0) # Store high half of RA per compiler ABI |
| 468 | |
| 469 | // Copy arguments into callee stack |
| 470 | // Use simple copy routine for now. |
| 471 | // 4 bytes per slot. |
| 472 | // a0 = source address |
| 473 | // a1 = args length in bytes (does not include 8 bytes for RA) |
| 474 | // sp = destination address |
| 475 | beqz $a1, .Losr_loop_exit |
| 476 | daddiu $a1, $a1, -4 |
| 477 | daddu $t1, $a0, $a1 |
| 478 | daddu $t2, $sp, $a1 |
| 479 | .Losr_loop_entry: |
| 480 | lw $t0, 0($t1) |
| 481 | daddiu $t1, $t1, -4 |
| 482 | sw $t0, 0($t2) |
| 483 | bne $sp, $t2, .Losr_loop_entry |
| 484 | daddiu $t2, $t2, -4 |
| 485 | |
| 486 | .Losr_loop_exit: |
| 487 | move $t9, $a2 |
| 488 | jalr $zero, $t9 # Jump to the OSR entry point. |
| 489 | nop |
| 490 | END art_quick_osr_stub |
| 491 | |
| 492 | /* |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 493 | * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_ |
| 494 | * FIXME: just guessing about the shape of the jmpbuf. Where will pc be? |
| 495 | */ |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 496 | ENTRY_NO_GP art_quick_do_long_jump |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 497 | l.d $f0, 0($a1) |
| 498 | l.d $f1, 8($a1) |
| 499 | l.d $f2, 16($a1) |
| 500 | l.d $f3, 24($a1) |
| 501 | l.d $f4, 32($a1) |
| 502 | l.d $f5, 40($a1) |
| 503 | l.d $f6, 48($a1) |
| 504 | l.d $f7, 56($a1) |
| 505 | l.d $f8, 64($a1) |
| 506 | l.d $f9, 72($a1) |
| 507 | l.d $f10, 80($a1) |
| 508 | l.d $f11, 88($a1) |
| 509 | l.d $f12, 96($a1) |
| 510 | l.d $f13, 104($a1) |
| 511 | l.d $f14, 112($a1) |
| 512 | l.d $f15, 120($a1) |
| 513 | l.d $f16, 128($a1) |
| 514 | l.d $f17, 136($a1) |
| 515 | l.d $f18, 144($a1) |
| 516 | l.d $f19, 152($a1) |
| 517 | l.d $f20, 160($a1) |
| 518 | l.d $f21, 168($a1) |
| 519 | l.d $f22, 176($a1) |
| 520 | l.d $f23, 184($a1) |
| 521 | l.d $f24, 192($a1) |
| 522 | l.d $f25, 200($a1) |
| 523 | l.d $f26, 208($a1) |
| 524 | l.d $f27, 216($a1) |
| 525 | l.d $f28, 224($a1) |
| 526 | l.d $f29, 232($a1) |
| 527 | l.d $f30, 240($a1) |
| 528 | l.d $f31, 248($a1) |
| 529 | .set push |
| 530 | .set nomacro |
| 531 | .set noat |
| 532 | # no need to load zero |
| 533 | ld $at, 8($a0) |
| 534 | .set pop |
| 535 | ld $v0, 16($a0) |
| 536 | ld $v1, 24($a0) |
| 537 | # a0 has to be loaded last |
| 538 | ld $a1, 40($a0) |
| 539 | ld $a2, 48($a0) |
| 540 | ld $a3, 56($a0) |
| 541 | ld $a4, 64($a0) |
| 542 | ld $a5, 72($a0) |
| 543 | ld $a6, 80($a0) |
| 544 | ld $a7, 88($a0) |
| 545 | ld $t0, 96($a0) |
| 546 | ld $t1, 104($a0) |
| 547 | ld $t2, 112($a0) |
| 548 | ld $t3, 120($a0) |
| 549 | ld $s0, 128($a0) |
| 550 | ld $s1, 136($a0) |
| 551 | ld $s2, 144($a0) |
| 552 | ld $s3, 152($a0) |
| 553 | ld $s4, 160($a0) |
| 554 | ld $s5, 168($a0) |
| 555 | ld $s6, 176($a0) |
| 556 | ld $s7, 184($a0) |
| 557 | ld $t8, 192($a0) |
| 558 | ld $t9, 200($a0) |
| 559 | # no need to load k0, k1 |
| 560 | ld $gp, 224($a0) |
| 561 | ld $sp, 232($a0) |
| 562 | ld $s8, 240($a0) |
| 563 | ld $ra, 248($a0) |
| 564 | ld $a0, 32($a0) |
| 565 | move $v0, $zero # clear result registers v0 and v1 |
Andreas Gampe | dbf056d | 2015-09-25 08:24:13 -0700 | [diff] [blame] | 566 | jalr $zero, $t9 # do long jump (do not use ra, it must not be clobbered) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 567 | move $v1, $zero |
| 568 | END art_quick_do_long_jump |
| 569 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 570 | /* |
| 571 | * Called by managed code, saves most registers (forms basis of long jump |
| 572 | * context) and passes the bottom of the stack. |
| 573 | * artDeliverExceptionFromCode will place the callee save Method* at |
Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 574 | * the bottom of the thread. On entry a0 holds Throwable* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 575 | */ |
| 576 | ENTRY art_quick_deliver_exception |
| 577 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 578 | dla $t9, artDeliverExceptionFromCode |
| 579 | jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*) |
| 580 | move $a1, rSELF # pass Thread::Current |
| 581 | END art_quick_deliver_exception |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 582 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 583 | /* |
| 584 | * Called by managed code to create and deliver a NullPointerException |
| 585 | */ |
| 586 | .extern artThrowNullPointerExceptionFromCode |
| 587 | ENTRY art_quick_throw_null_pointer_exception |
| 588 | .Lart_quick_throw_null_pointer_exception_gp_set: |
| 589 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 590 | dla $t9, artThrowNullPointerExceptionFromCode |
| 591 | jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*) |
| 592 | move $a0, rSELF # pass Thread::Current |
| 593 | END art_quick_throw_null_pointer_exception |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 594 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 595 | /* |
| 596 | * Called by managed code to create and deliver an ArithmeticException |
| 597 | */ |
| 598 | .extern artThrowDivZeroFromCode |
| 599 | ENTRY art_quick_throw_div_zero |
| 600 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 601 | dla $t9, artThrowDivZeroFromCode |
| 602 | jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*) |
| 603 | move $a0, rSELF # pass Thread::Current |
| 604 | END art_quick_throw_div_zero |
| 605 | |
| 606 | /* |
| 607 | * Called by managed code to create and deliver an |
| 608 | * ArrayIndexOutOfBoundsException |
| 609 | */ |
| 610 | .extern artThrowArrayBoundsFromCode |
| 611 | ENTRY art_quick_throw_array_bounds |
| 612 | .Lart_quick_throw_array_bounds_gp_set: |
| 613 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 614 | dla $t9, artThrowArrayBoundsFromCode |
| 615 | jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*) |
| 616 | move $a2, rSELF # pass Thread::Current |
| 617 | END art_quick_throw_array_bounds |
| 618 | |
| 619 | /* |
| 620 | * Called by managed code to create and deliver a StackOverflowError. |
| 621 | */ |
| 622 | .extern artThrowStackOverflowFromCode |
| 623 | ENTRY art_quick_throw_stack_overflow |
| 624 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 625 | dla $t9, artThrowStackOverflowFromCode |
| 626 | jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*) |
| 627 | move $a0, rSELF # pass Thread::Current |
| 628 | END art_quick_throw_stack_overflow |
| 629 | |
| 630 | /* |
| 631 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 632 | */ |
| 633 | .extern artThrowNoSuchMethodFromCode |
| 634 | ENTRY art_quick_throw_no_such_method |
| 635 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 636 | dla $t9, artThrowNoSuchMethodFromCode |
| 637 | jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*) |
| 638 | move $a1, rSELF # pass Thread::Current |
| 639 | END art_quick_throw_no_such_method |
| 640 | |
| 641 | /* |
| 642 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 643 | * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain |
| 644 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 645 | * stack and call the appropriate C helper. |
| 646 | * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1. |
| 647 | * |
| 648 | * The helper will attempt to locate the target and return a 128-bit result in $v0/$v1 consisting |
| 649 | * of the target Method* in $v0 and method->code_ in $v1. |
| 650 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 651 | * If unsuccessful, the helper will return null/null. There will be a pending exception in the |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 652 | * thread and we branch to another stub to deliver it. |
| 653 | * |
| 654 | * On success this wrapper will restore arguments and *jump* to the target, leaving the ra |
| 655 | * pointing back to the original caller. |
| 656 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 657 | .macro INVOKE_TRAMPOLINE_BODY cxx_name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 658 | .extern \cxx_name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 659 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 660 | move $a2, rSELF # pass Thread::Current |
| 661 | jal \cxx_name # (method_idx, this, Thread*, $sp) |
| 662 | move $a3, $sp # pass $sp |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 663 | move $a0, $v0 # save target Method* |
| 664 | move $t9, $v1 # save $v0->code_ |
| 665 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 666 | beq $v0, $zero, 1f |
| 667 | nop |
| 668 | jalr $zero, $t9 |
| 669 | nop |
| 670 | 1: |
| 671 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 672 | .endm |
| 673 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 674 | ENTRY \c_name |
| 675 | INVOKE_TRAMPOLINE_BODY \cxx_name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 676 | END \c_name |
| 677 | .endm |
| 678 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 679 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 680 | |
| 681 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 682 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 683 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 684 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 685 | |
| 686 | # On entry: |
| 687 | # t0 = shorty |
| 688 | # t1 = ptr to arg_array |
| 689 | # t2 = number of argument bytes remain |
| 690 | # v0 = ptr to stack frame where to copy arg_array |
| 691 | # This macro modifies t3, t9 and v0 |
| 692 | .macro LOOP_OVER_SHORTY_LOADING_REG gpu, fpu, label |
| 693 | lbu $t3, 0($t0) # get argument type from shorty |
| 694 | beqz $t3, \label |
| 695 | daddiu $t0, 1 |
| 696 | li $t9, 68 # put char 'D' into t9 |
| 697 | beq $t9, $t3, 1f # branch if result type char == 'D' |
| 698 | li $t9, 70 # put char 'F' into t9 |
| 699 | beq $t9, $t3, 2f # branch if result type char == 'F' |
| 700 | li $t9, 74 # put char 'J' into t9 |
| 701 | beq $t9, $t3, 3f # branch if result type char == 'J' |
| 702 | nop |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 703 | lw $\gpu, 0($t1) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 704 | sw $\gpu, 0($v0) |
| 705 | daddiu $v0, 4 |
| 706 | daddiu $t1, 4 |
| 707 | b 4f |
| 708 | daddiu $t2, -4 # delay slot |
| 709 | |
| 710 | 1: # found double |
| 711 | lwu $t3, 0($t1) |
| 712 | mtc1 $t3, $\fpu |
| 713 | sw $t3, 0($v0) |
| 714 | lwu $t3, 4($t1) |
| 715 | mthc1 $t3, $\fpu |
| 716 | sw $t3, 4($v0) |
| 717 | daddiu $v0, 8 |
| 718 | daddiu $t1, 8 |
| 719 | b 4f |
| 720 | daddiu $t2, -8 # delay slot |
| 721 | |
| 722 | 2: # found float |
| 723 | lwu $t3, 0($t1) |
| 724 | mtc1 $t3, $\fpu |
| 725 | sw $t3, 0($v0) |
| 726 | daddiu $v0, 4 |
| 727 | daddiu $t1, 4 |
| 728 | b 4f |
| 729 | daddiu $t2, -4 # delay slot |
| 730 | |
| 731 | 3: # found long (8 bytes) |
| 732 | lwu $t3, 0($t1) |
| 733 | sw $t3, 0($v0) |
| 734 | lwu $t9, 4($t1) |
| 735 | sw $t9, 4($v0) |
| 736 | dsll $t9, $t9, 32 |
| 737 | or $\gpu, $t9, $t3 |
| 738 | daddiu $v0, 8 |
| 739 | daddiu $t1, 8 |
| 740 | daddiu $t2, -8 |
| 741 | 4: |
| 742 | .endm |
| 743 | |
| 744 | /* |
| 745 | * Invocation stub for quick code. |
| 746 | * On entry: |
| 747 | * a0 = method pointer |
| 748 | * a1 = argument array that must at least contain the this ptr. |
| 749 | * a2 = size of argument array in bytes |
| 750 | * a3 = (managed) thread pointer |
| 751 | * a4 = JValue* result |
| 752 | * a5 = shorty |
| 753 | */ |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 754 | ENTRY_NO_GP art_quick_invoke_stub |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 755 | # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra onto the stack |
| 756 | daddiu $sp, $sp, -48 |
| 757 | .cfi_adjust_cfa_offset 48 |
| 758 | sd $ra, 40($sp) |
| 759 | .cfi_rel_offset 31, 40 |
| 760 | sd $s8, 32($sp) |
| 761 | .cfi_rel_offset 30, 32 |
| 762 | sd $s1, 24($sp) |
| 763 | .cfi_rel_offset 17, 24 |
| 764 | sd $s0, 16($sp) |
| 765 | .cfi_rel_offset 16, 16 |
| 766 | sd $a5, 8($sp) |
| 767 | .cfi_rel_offset 9, 8 |
| 768 | sd $a4, 0($sp) |
| 769 | .cfi_rel_offset 8, 0 |
| 770 | |
| 771 | daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 772 | move $s1, $a3 # move managed thread pointer into s1 (rSELF) |
| 773 | move $s8, $sp # save sp in s8 (fp) |
| 774 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 775 | daddiu $t3, $a2, 24 # add 8 for ArtMethod* and 16 for stack alignment |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 776 | dsrl $t3, $t3, 4 # shift the frame size right 4 |
| 777 | dsll $t3, $t3, 4 # shift the frame size left 4 to align to 16 bytes |
| 778 | dsubu $sp, $sp, $t3 # reserve stack space for argument array |
| 779 | |
| 780 | daddiu $t0, $a5, 1 # t0 = shorty[1] (skip 1 for return type) |
| 781 | daddiu $t1, $a1, 4 # t1 = ptr to arg_array[4] (skip this ptr) |
| 782 | daddiu $t2, $a2, -4 # t2 = number of argument bytes remain (skip this ptr) |
Nikola Veljkovic | 80f7a57 | 2015-06-02 17:27:53 +0200 | [diff] [blame] | 783 | daddiu $v0, $sp, 12 # v0 points to where to copy arg_array |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 784 | LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_fn |
| 785 | LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_fn |
| 786 | LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_fn |
| 787 | LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_fn |
| 788 | LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_fn |
| 789 | LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_fn |
| 790 | |
| 791 | # copy arguments onto stack (t2 should be multiples of 4) |
| 792 | ble $t2, $zero, call_fn # t2 = number of argument bytes remain |
| 793 | 1: |
| 794 | lw $t3, 0($t1) # load from argument array |
| 795 | daddiu $t1, $t1, 4 |
| 796 | sw $t3, 0($v0) # save to stack |
| 797 | daddiu $t2, -4 |
| 798 | bgt $t2, $zero, 1b # t2 = number of argument bytes remain |
| 799 | daddiu $v0, $v0, 4 |
| 800 | |
| 801 | call_fn: |
| 802 | # call method (a0 and a1 have been untouched) |
| 803 | lwu $a1, 0($a1) # make a1 = this ptr |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 804 | sw $a1, 8($sp) # copy this ptr (skip 8 bytes for ArtMethod*) |
| 805 | sd $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
| 806 | ld $t9, ART_METHOD_QUICK_CODE_OFFSET_64($a0) # get pointer to the code |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 807 | jalr $t9 # call the method |
| 808 | nop |
| 809 | move $sp, $s8 # restore sp |
| 810 | |
| 811 | # pop a4, a5, s1(rSELF), s8, ra off of the stack |
| 812 | ld $a4, 0($sp) |
| 813 | .cfi_restore 8 |
| 814 | ld $a5, 8($sp) |
| 815 | .cfi_restore 9 |
| 816 | ld $s0, 16($sp) |
| 817 | .cfi_restore 16 |
| 818 | ld $s1, 24($sp) |
| 819 | .cfi_restore 17 |
| 820 | ld $s8, 32($sp) |
| 821 | .cfi_restore 30 |
| 822 | ld $ra, 40($sp) |
| 823 | .cfi_restore 31 |
| 824 | daddiu $sp, $sp, 48 |
| 825 | .cfi_adjust_cfa_offset -48 |
| 826 | |
| 827 | # a4 = JValue* result |
| 828 | # a5 = shorty string |
| 829 | lbu $t1, 0($a5) # get result type from shorty |
| 830 | li $t2, 68 # put char 'D' into t2 |
| 831 | beq $t1, $t2, 1f # branch if result type char == 'D' |
| 832 | li $t3, 70 # put char 'F' into t3 |
| 833 | beq $t1, $t3, 1f # branch if result type char == 'F' |
| 834 | sw $v0, 0($a4) # store the result |
| 835 | dsrl $v1, $v0, 32 |
| 836 | jalr $zero, $ra |
| 837 | sw $v1, 4($a4) # store the other half of the result |
| 838 | 1: |
| 839 | mfc1 $v0, $f0 |
| 840 | mfhc1 $v1, $f0 |
| 841 | sw $v0, 0($a4) # store the result |
| 842 | jalr $zero, $ra |
| 843 | sw $v1, 4($a4) # store the other half of the result |
| 844 | END art_quick_invoke_stub |
| 845 | |
| 846 | /* |
| 847 | * Invocation static stub for quick code. |
| 848 | * On entry: |
| 849 | * a0 = method pointer |
| 850 | * a1 = argument array that must at least contain the this ptr. |
| 851 | * a2 = size of argument array in bytes |
| 852 | * a3 = (managed) thread pointer |
| 853 | * a4 = JValue* result |
| 854 | * a5 = shorty |
| 855 | */ |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 856 | ENTRY_NO_GP art_quick_invoke_static_stub |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 857 | |
| 858 | # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra, onto the stack |
| 859 | daddiu $sp, $sp, -48 |
| 860 | .cfi_adjust_cfa_offset 48 |
| 861 | sd $ra, 40($sp) |
| 862 | .cfi_rel_offset 31, 40 |
| 863 | sd $s8, 32($sp) |
| 864 | .cfi_rel_offset 30, 32 |
| 865 | sd $s1, 24($sp) |
| 866 | .cfi_rel_offset 17, 24 |
| 867 | sd $s0, 16($sp) |
| 868 | .cfi_rel_offset 16, 16 |
| 869 | sd $a5, 8($sp) |
| 870 | .cfi_rel_offset 9, 8 |
| 871 | sd $a4, 0($sp) |
| 872 | .cfi_rel_offset 8, 0 |
| 873 | |
| 874 | daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 875 | move $s1, $a3 # move managed thread pointer into s1 (rSELF) |
| 876 | move $s8, $sp # save sp in s8 (fp) |
| 877 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 878 | daddiu $t3, $a2, 24 # add 8 for ArtMethod* and 16 for stack alignment |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 879 | dsrl $t3, $t3, 4 # shift the frame size right 4 |
| 880 | dsll $t3, $t3, 4 # shift the frame size left 4 to align to 16 bytes |
| 881 | dsubu $sp, $sp, $t3 # reserve stack space for argument array |
| 882 | |
| 883 | daddiu $t0, $a5, 1 # t0 = shorty[1] (skip 1 for return type) |
| 884 | move $t1, $a1 # t1 = arg_array |
| 885 | move $t2, $a2 # t2 = number of argument bytes remain |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 886 | daddiu $v0, $sp, 8 # v0 points to where to copy arg_array |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 887 | LOOP_OVER_SHORTY_LOADING_REG a1, f13, call_sfn |
| 888 | LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_sfn |
| 889 | LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_sfn |
| 890 | LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_sfn |
| 891 | LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_sfn |
| 892 | LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_sfn |
| 893 | LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_sfn |
| 894 | |
| 895 | # copy arguments onto stack (t2 should be multiples of 4) |
| 896 | ble $t2, $zero, call_sfn # t2 = number of argument bytes remain |
| 897 | 1: |
| 898 | lw $t3, 0($t1) # load from argument array |
| 899 | daddiu $t1, $t1, 4 |
| 900 | sw $t3, 0($v0) # save to stack |
| 901 | daddiu $t2, -4 |
| 902 | bgt $t2, $zero, 1b # t2 = number of argument bytes remain |
| 903 | daddiu $v0, $v0, 4 |
| 904 | |
| 905 | call_sfn: |
| 906 | # call method (a0 has been untouched) |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 907 | sd $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
| 908 | ld $t9, ART_METHOD_QUICK_CODE_OFFSET_64($a0) # get pointer to the code |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 909 | jalr $t9 # call the method |
| 910 | nop |
| 911 | move $sp, $s8 # restore sp |
| 912 | |
| 913 | # pop a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra off of the stack |
| 914 | ld $a4, 0($sp) |
| 915 | .cfi_restore 8 |
| 916 | ld $a5, 8($sp) |
| 917 | .cfi_restore 9 |
| 918 | ld $s0, 16($sp) |
| 919 | .cfi_restore 16 |
| 920 | ld $s1, 24($sp) |
| 921 | .cfi_restore 17 |
| 922 | ld $s8, 32($sp) |
| 923 | .cfi_restore 30 |
| 924 | ld $ra, 40($sp) |
| 925 | .cfi_restore 31 |
| 926 | daddiu $sp, $sp, 48 |
| 927 | .cfi_adjust_cfa_offset -48 |
| 928 | |
| 929 | # a4 = JValue* result |
| 930 | # a5 = shorty string |
| 931 | lbu $t1, 0($a5) # get result type from shorty |
| 932 | li $t2, 68 # put char 'D' into t2 |
| 933 | beq $t1, $t2, 1f # branch if result type char == 'D' |
| 934 | li $t3, 70 # put char 'F' into t3 |
| 935 | beq $t1, $t3, 1f # branch if result type char == 'F' |
| 936 | sw $v0, 0($a4) # store the result |
| 937 | dsrl $v1, $v0, 32 |
| 938 | jalr $zero, $ra |
| 939 | sw $v1, 4($a4) # store the other half of the result |
| 940 | 1: |
| 941 | mfc1 $v0, $f0 |
| 942 | mfhc1 $v1, $f0 |
| 943 | sw $v0, 0($a4) # store the result |
| 944 | jalr $zero, $ra |
| 945 | sw $v1, 4($a4) # store the other half of the result |
| 946 | END art_quick_invoke_static_stub |
| 947 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 948 | /* |
| 949 | * Entry from managed code that calls artHandleFillArrayDataFromCode and |
| 950 | * delivers exception on failure. |
| 951 | */ |
| 952 | .extern artHandleFillArrayDataFromCode |
| 953 | ENTRY art_quick_handle_fill_data |
| 954 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 955 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 956 | jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*) |
| 957 | move $a3, rSELF # pass Thread::Current |
| 958 | RETURN_IF_ZERO |
| 959 | END art_quick_handle_fill_data |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 960 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 961 | /* |
| 962 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. |
| 963 | */ |
| 964 | .extern artLockObjectFromCode |
| 965 | ENTRY art_quick_lock_object |
| 966 | beq $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set |
| 967 | nop |
| 968 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block |
| 969 | jal artLockObjectFromCode # (Object* obj, Thread*) |
| 970 | move $a1, rSELF # pass Thread::Current |
| 971 | RETURN_IF_ZERO |
| 972 | END art_quick_lock_object |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 973 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 974 | /* |
| 975 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 976 | */ |
| 977 | .extern artUnlockObjectFromCode |
| 978 | ENTRY art_quick_unlock_object |
| 979 | beq $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set |
| 980 | nop |
| 981 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC |
| 982 | jal artUnlockObjectFromCode # (Object* obj, Thread*) |
| 983 | move $a1, rSELF # pass Thread::Current |
| 984 | RETURN_IF_ZERO |
| 985 | END art_quick_unlock_object |
| 986 | |
| 987 | /* |
| 988 | * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. |
| 989 | */ |
| 990 | .extern artThrowClassCastException |
| 991 | ENTRY art_quick_check_cast |
| 992 | daddiu $sp, $sp, -32 |
| 993 | .cfi_adjust_cfa_offset 32 |
| 994 | sd $ra, 24($sp) |
| 995 | .cfi_rel_offset 31, 24 |
| 996 | sd $t9, 16($sp) |
| 997 | sd $a1, 8($sp) |
| 998 | sd $a0, 0($sp) |
| 999 | jal artIsAssignableFromCode |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1000 | .cpreturn # Restore gp from t8 in branch delay slot. |
| 1001 | # t8 may be clobbered in artIsAssignableFromCode. |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1002 | beq $v0, $zero, .Lthrow_class_cast_exception |
| 1003 | ld $ra, 24($sp) |
| 1004 | jalr $zero, $ra |
| 1005 | daddiu $sp, $sp, 32 |
| 1006 | .cfi_adjust_cfa_offset -32 |
| 1007 | .Lthrow_class_cast_exception: |
| 1008 | ld $t9, 16($sp) |
| 1009 | ld $a1, 8($sp) |
| 1010 | ld $a0, 0($sp) |
| 1011 | daddiu $sp, $sp, 32 |
| 1012 | .cfi_adjust_cfa_offset -32 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1013 | SETUP_GP |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1014 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1015 | dla $t9, artThrowClassCastException |
| 1016 | jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*) |
| 1017 | move $a2, rSELF # pass Thread::Current |
| 1018 | END art_quick_check_cast |
| 1019 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1020 | |
| 1021 | /* |
| 1022 | * Restore rReg's value from offset($sp) if rReg is not the same as rExclude. |
| 1023 | * nReg is the register number for rReg. |
| 1024 | */ |
| 1025 | .macro POP_REG_NE rReg, nReg, offset, rExclude |
| 1026 | .ifnc \rReg, \rExclude |
| 1027 | ld \rReg, \offset($sp) # restore rReg |
| 1028 | .cfi_restore \nReg |
| 1029 | .endif |
| 1030 | .endm |
| 1031 | |
| 1032 | /* |
| 1033 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1034 | * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET. |
| 1035 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1036 | */ |
| 1037 | .macro READ_BARRIER rDest, rObj, offset |
| 1038 | #ifdef USE_READ_BARRIER |
| 1039 | # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 16B-aligned. |
| 1040 | daddiu $sp, $sp, -64 |
| 1041 | .cfi_adjust_cfa_offset 64 |
| 1042 | sd $ra, 56($sp) |
| 1043 | .cfi_rel_offset 31, 56 |
| 1044 | sd $t9, 48($sp) |
| 1045 | .cfi_rel_offset 25, 48 |
| 1046 | sd $t1, 40($sp) |
| 1047 | .cfi_rel_offset 13, 40 |
| 1048 | sd $t0, 32($sp) |
| 1049 | .cfi_rel_offset 12, 32 |
| 1050 | sd $a2, 16($sp) # padding slot at offset 24 (padding can be any slot in the 64B) |
| 1051 | .cfi_rel_offset 6, 16 |
| 1052 | sd $a1, 8($sp) |
| 1053 | .cfi_rel_offset 5, 8 |
| 1054 | sd $a0, 0($sp) |
| 1055 | .cfi_rel_offset 4, 0 |
| 1056 | |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1057 | # move $a0, \rRef # pass ref in a0 (no-op for now since parameter ref is unused) |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1058 | .ifnc \rObj, $a1 |
| 1059 | move $a1, \rObj # pass rObj |
| 1060 | .endif |
| 1061 | daddiu $a2, $zero, \offset # pass offset |
| 1062 | jal artReadBarrierSlow # artReadBarrierSlow(ref, rObj, offset) |
| 1063 | .cpreturn # Restore gp from t8 in branch delay slot. |
| 1064 | # t8 may be clobbered in artReadBarrierSlow. |
| 1065 | # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning. |
| 1066 | move \rDest, $v0 # save return value in rDest |
| 1067 | # (rDest cannot be v0 in art_quick_aput_obj) |
| 1068 | |
| 1069 | ld $a0, 0($sp) # restore registers except rDest |
| 1070 | # (rDest can only be t0 or t1 in art_quick_aput_obj) |
| 1071 | .cfi_restore 4 |
| 1072 | ld $a1, 8($sp) |
| 1073 | .cfi_restore 5 |
| 1074 | ld $a2, 16($sp) |
| 1075 | .cfi_restore 6 |
| 1076 | POP_REG_NE $t0, 12, 32, \rDest |
| 1077 | POP_REG_NE $t1, 13, 40, \rDest |
| 1078 | ld $t9, 48($sp) |
| 1079 | .cfi_restore 25 |
| 1080 | ld $ra, 56($sp) # restore $ra |
| 1081 | .cfi_restore 31 |
| 1082 | daddiu $sp, $sp, 64 |
| 1083 | .cfi_adjust_cfa_offset -64 |
| 1084 | SETUP_GP # set up gp because we are not returning |
| 1085 | #else |
| 1086 | lwu \rDest, \offset(\rObj) |
| 1087 | UNPOISON_HEAP_REF \rDest |
| 1088 | #endif // USE_READ_BARRIER |
| 1089 | .endm |
| 1090 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1091 | /* |
| 1092 | * Entry from managed code for array put operations of objects where the value being stored |
| 1093 | * needs to be checked for compatibility. |
| 1094 | * a0 = array, a1 = index, a2 = value |
| 1095 | */ |
| 1096 | ENTRY art_quick_aput_obj_with_null_and_bound_check |
| 1097 | bne $a0, $zero, .Lart_quick_aput_obj_with_bound_check_gp_set |
| 1098 | nop |
| 1099 | b .Lart_quick_throw_null_pointer_exception_gp_set |
| 1100 | nop |
| 1101 | END art_quick_aput_obj_with_null_and_bound_check |
| 1102 | |
| 1103 | ENTRY art_quick_aput_obj_with_bound_check |
| 1104 | lwu $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0) |
| 1105 | sltu $t1, $a1, $t0 |
| 1106 | bne $t1, $zero, .Lart_quick_aput_obj_gp_set |
| 1107 | nop |
| 1108 | move $a0, $a1 |
| 1109 | b .Lart_quick_throw_array_bounds_gp_set |
| 1110 | move $a1, $t0 |
| 1111 | END art_quick_aput_obj_with_bound_check |
| 1112 | |
| 1113 | ENTRY art_quick_aput_obj |
| 1114 | beq $a2, $zero, .Ldo_aput_null |
| 1115 | nop |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1116 | READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET |
| 1117 | READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET |
| 1118 | READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1119 | bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability |
| 1120 | nop |
| 1121 | .Ldo_aput: |
| 1122 | dsll $a1, $a1, 2 |
| 1123 | daddu $t0, $a0, $a1 |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1124 | POISON_HEAP_REF $a2 |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1125 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| 1126 | ld $t0, THREAD_CARD_TABLE_OFFSET(rSELF) |
| 1127 | dsrl $t1, $a0, 7 |
| 1128 | daddu $t1, $t1, $t0 |
| 1129 | sb $t0, ($t1) |
| 1130 | jalr $zero, $ra |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1131 | .cpreturn # Restore gp from t8 in branch delay slot. |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1132 | .Ldo_aput_null: |
| 1133 | dsll $a1, $a1, 2 |
| 1134 | daddu $t0, $a0, $a1 |
| 1135 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| 1136 | jalr $zero, $ra |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1137 | .cpreturn # Restore gp from t8 in branch delay slot. |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1138 | .Lcheck_assignability: |
| 1139 | daddiu $sp, $sp, -64 |
| 1140 | .cfi_adjust_cfa_offset 64 |
| 1141 | sd $ra, 56($sp) |
| 1142 | .cfi_rel_offset 31, 56 |
| 1143 | sd $t9, 24($sp) |
| 1144 | sd $a2, 16($sp) |
| 1145 | sd $a1, 8($sp) |
| 1146 | sd $a0, 0($sp) |
| 1147 | move $a1, $t1 |
| 1148 | move $a0, $t0 |
| 1149 | jal artIsAssignableFromCode # (Class*, Class*) |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1150 | .cpreturn # Restore gp from t8 in branch delay slot. |
| 1151 | # t8 may be clobbered in artIsAssignableFromCode. |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1152 | ld $ra, 56($sp) |
| 1153 | ld $t9, 24($sp) |
| 1154 | ld $a2, 16($sp) |
| 1155 | ld $a1, 8($sp) |
| 1156 | ld $a0, 0($sp) |
| 1157 | daddiu $sp, $sp, 64 |
| 1158 | .cfi_adjust_cfa_offset -64 |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1159 | SETUP_GP |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1160 | bne $v0, $zero, .Ldo_aput |
| 1161 | nop |
| 1162 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1163 | move $a1, $a2 |
| 1164 | dla $t9, artThrowArrayStoreException |
| 1165 | jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*) |
| 1166 | move $a2, rSELF # pass Thread::Current |
| 1167 | END art_quick_aput_obj |
| 1168 | |
| 1169 | /* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1170 | * Called by managed code to resolve a static field and load a boolean primitive value. |
| 1171 | */ |
| 1172 | .extern artGetBooleanStaticFromCode |
| 1173 | ENTRY art_quick_get_boolean_static |
| 1174 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1175 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1176 | jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1177 | move $a2, rSELF # pass Thread::Current |
| 1178 | RETURN_IF_NO_EXCEPTION |
| 1179 | END art_quick_get_boolean_static |
| 1180 | |
| 1181 | /* |
| 1182 | * Called by managed code to resolve a static field and load a byte primitive value. |
| 1183 | */ |
| 1184 | .extern artGetByteStaticFromCode |
| 1185 | ENTRY art_quick_get_byte_static |
| 1186 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1187 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1188 | jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1189 | move $a2, rSELF # pass Thread::Current |
| 1190 | RETURN_IF_NO_EXCEPTION |
| 1191 | END art_quick_get_byte_static |
| 1192 | |
| 1193 | /* |
| 1194 | * Called by managed code to resolve a static field and load a char primitive value. |
| 1195 | */ |
| 1196 | .extern artGetCharStaticFromCode |
| 1197 | ENTRY art_quick_get_char_static |
| 1198 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1199 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1200 | jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1201 | move $a2, rSELF # pass Thread::Current |
| 1202 | RETURN_IF_NO_EXCEPTION |
| 1203 | END art_quick_get_char_static |
| 1204 | |
| 1205 | /* |
| 1206 | * Called by managed code to resolve a static field and load a short primitive value. |
| 1207 | */ |
| 1208 | .extern artGetShortStaticFromCode |
| 1209 | ENTRY art_quick_get_short_static |
| 1210 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1211 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1212 | jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1213 | move $a2, rSELF # pass Thread::Current |
| 1214 | RETURN_IF_NO_EXCEPTION |
| 1215 | END art_quick_get_short_static |
| 1216 | |
| 1217 | /* |
| 1218 | * Called by managed code to resolve a static field and load a 32-bit primitive value. |
| 1219 | */ |
| 1220 | .extern artGet32StaticFromCode |
| 1221 | ENTRY art_quick_get32_static |
| 1222 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1223 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1224 | jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1225 | move $a2, rSELF # pass Thread::Current |
| 1226 | RETURN_IF_NO_EXCEPTION |
| 1227 | END art_quick_get32_static |
| 1228 | |
| 1229 | /* |
| 1230 | * Called by managed code to resolve a static field and load a 64-bit primitive value. |
| 1231 | */ |
| 1232 | .extern artGet64StaticFromCode |
| 1233 | ENTRY art_quick_get64_static |
| 1234 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1235 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1236 | jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1237 | move $a2, rSELF # pass Thread::Current |
| 1238 | RETURN_IF_NO_EXCEPTION |
| 1239 | END art_quick_get64_static |
| 1240 | |
| 1241 | /* |
| 1242 | * Called by managed code to resolve a static field and load an object reference. |
| 1243 | */ |
| 1244 | .extern artGetObjStaticFromCode |
| 1245 | ENTRY art_quick_get_obj_static |
| 1246 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1247 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1248 | jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1249 | move $a2, rSELF # pass Thread::Current |
| 1250 | RETURN_IF_NO_EXCEPTION |
| 1251 | END art_quick_get_obj_static |
| 1252 | |
| 1253 | /* |
| 1254 | * Called by managed code to resolve an instance field and load a boolean primitive value. |
| 1255 | */ |
| 1256 | .extern artGetBooleanInstanceFromCode |
| 1257 | ENTRY art_quick_get_boolean_instance |
| 1258 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1259 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1260 | jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1261 | move $a3, rSELF # pass Thread::Current |
| 1262 | RETURN_IF_NO_EXCEPTION |
| 1263 | END art_quick_get_boolean_instance |
| 1264 | |
| 1265 | /* |
| 1266 | * Called by managed code to resolve an instance field and load a byte primitive value. |
| 1267 | */ |
| 1268 | .extern artGetByteInstanceFromCode |
| 1269 | ENTRY art_quick_get_byte_instance |
| 1270 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1271 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1272 | jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1273 | move $a3, rSELF # pass Thread::Current |
| 1274 | RETURN_IF_NO_EXCEPTION |
| 1275 | END art_quick_get_byte_instance |
| 1276 | |
| 1277 | /* |
| 1278 | * Called by managed code to resolve an instance field and load a char primitive value. |
| 1279 | */ |
| 1280 | .extern artGetCharInstanceFromCode |
| 1281 | ENTRY art_quick_get_char_instance |
| 1282 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1283 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1284 | jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1285 | move $a3, rSELF # pass Thread::Current |
| 1286 | RETURN_IF_NO_EXCEPTION |
| 1287 | END art_quick_get_char_instance |
| 1288 | |
| 1289 | /* |
| 1290 | * Called by managed code to resolve an instance field and load a short primitive value. |
| 1291 | */ |
| 1292 | .extern artGetShortInstanceFromCode |
| 1293 | ENTRY art_quick_get_short_instance |
| 1294 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1295 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1296 | jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1297 | move $a3, rSELF # pass Thread::Current |
| 1298 | RETURN_IF_NO_EXCEPTION |
| 1299 | END art_quick_get_short_instance |
| 1300 | |
| 1301 | /* |
| 1302 | * Called by managed code to resolve an instance field and load a 32-bit primitive value. |
| 1303 | */ |
| 1304 | .extern artGet32InstanceFromCode |
| 1305 | ENTRY art_quick_get32_instance |
| 1306 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1307 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1308 | jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1309 | move $a3, rSELF # pass Thread::Current |
| 1310 | RETURN_IF_NO_EXCEPTION |
| 1311 | END art_quick_get32_instance |
| 1312 | |
| 1313 | /* |
| 1314 | * Called by managed code to resolve an instance field and load a 64-bit primitive value. |
| 1315 | */ |
| 1316 | .extern artGet64InstanceFromCode |
| 1317 | ENTRY art_quick_get64_instance |
| 1318 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1319 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1320 | jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1321 | move $a3, rSELF # pass Thread::Current |
| 1322 | RETURN_IF_NO_EXCEPTION |
| 1323 | END art_quick_get64_instance |
| 1324 | |
| 1325 | /* |
| 1326 | * Called by managed code to resolve an instance field and load an object reference. |
| 1327 | */ |
| 1328 | .extern artGetObjInstanceFromCode |
| 1329 | ENTRY art_quick_get_obj_instance |
| 1330 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1331 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1332 | jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1333 | move $a3, rSELF # pass Thread::Current |
| 1334 | RETURN_IF_NO_EXCEPTION |
| 1335 | END art_quick_get_obj_instance |
| 1336 | |
| 1337 | /* |
| 1338 | * Called by managed code to resolve a static field and store a 8-bit primitive value. |
| 1339 | */ |
| 1340 | .extern artSet8StaticFromCode |
| 1341 | ENTRY art_quick_set8_static |
| 1342 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1343 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1344 | jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1345 | move $a3, rSELF # pass Thread::Current |
| 1346 | RETURN_IF_ZERO |
| 1347 | END art_quick_set8_static |
| 1348 | |
| 1349 | /* |
| 1350 | * Called by managed code to resolve a static field and store a 16-bit primitive value. |
| 1351 | */ |
| 1352 | .extern artSet16StaticFromCode |
| 1353 | ENTRY art_quick_set16_static |
| 1354 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1355 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1356 | jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1357 | move $a3, rSELF # pass Thread::Current |
| 1358 | RETURN_IF_ZERO |
| 1359 | END art_quick_set16_static |
| 1360 | |
| 1361 | /* |
| 1362 | * Called by managed code to resolve a static field and store a 32-bit primitive value. |
| 1363 | */ |
| 1364 | .extern artSet32StaticFromCode |
| 1365 | ENTRY art_quick_set32_static |
| 1366 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1367 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1368 | jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1369 | move $a3, rSELF # pass Thread::Current |
| 1370 | RETURN_IF_ZERO |
| 1371 | END art_quick_set32_static |
| 1372 | |
| 1373 | /* |
| 1374 | * Called by managed code to resolve a static field and store a 64-bit primitive value. |
| 1375 | */ |
| 1376 | .extern artSet64StaticFromCode |
| 1377 | ENTRY art_quick_set64_static |
| 1378 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 1379 | # a2 contains the new val |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1380 | ld $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1381 | jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*) |
| 1382 | move $a3, rSELF # pass Thread::Current |
| 1383 | RETURN_IF_ZERO |
| 1384 | END art_quick_set64_static |
| 1385 | |
| 1386 | /* |
| 1387 | * Called by managed code to resolve a static field and store an object reference. |
| 1388 | */ |
| 1389 | .extern artSetObjStaticFromCode |
| 1390 | ENTRY art_quick_set_obj_static |
| 1391 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1392 | ld $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1393 | jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1394 | move $a3, rSELF # pass Thread::Current |
| 1395 | RETURN_IF_ZERO |
| 1396 | END art_quick_set_obj_static |
| 1397 | |
| 1398 | /* |
| 1399 | * Called by managed code to resolve an instance field and store a 8-bit primitive value. |
| 1400 | */ |
| 1401 | .extern artSet8InstanceFromCode |
| 1402 | ENTRY art_quick_set8_instance |
| 1403 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1404 | ld $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1405 | jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1406 | move $a4, rSELF # pass Thread::Current |
| 1407 | RETURN_IF_ZERO |
| 1408 | END art_quick_set8_instance |
| 1409 | |
| 1410 | /* |
| 1411 | * Called by managed code to resolve an instance field and store a 16-bit primitive value. |
| 1412 | */ |
| 1413 | .extern artSet16InstanceFromCode |
| 1414 | ENTRY art_quick_set16_instance |
| 1415 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1416 | ld $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1417 | jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1418 | move $a4, rSELF # pass Thread::Current |
| 1419 | RETURN_IF_ZERO |
| 1420 | END art_quick_set16_instance |
| 1421 | |
| 1422 | /* |
| 1423 | * Called by managed code to resolve an instance field and store a 32-bit primitive value. |
| 1424 | */ |
| 1425 | .extern artSet32InstanceFromCode |
| 1426 | ENTRY art_quick_set32_instance |
| 1427 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1428 | ld $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1429 | jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1430 | move $a4, rSELF # pass Thread::Current |
| 1431 | RETURN_IF_ZERO |
| 1432 | END art_quick_set32_instance |
| 1433 | |
| 1434 | /* |
| 1435 | * Called by managed code to resolve an instance field and store a 64-bit primitive value. |
| 1436 | */ |
| 1437 | .extern artSet64InstanceFromCode |
| 1438 | ENTRY art_quick_set64_instance |
| 1439 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1440 | ld $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1441 | jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1442 | move $a4, rSELF # pass Thread::Current |
| 1443 | RETURN_IF_ZERO |
| 1444 | END art_quick_set64_instance |
| 1445 | |
| 1446 | /* |
| 1447 | * Called by managed code to resolve an instance field and store an object reference. |
| 1448 | */ |
| 1449 | .extern artSetObjInstanceFromCode |
| 1450 | ENTRY art_quick_set_obj_instance |
| 1451 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1452 | ld $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1453 | jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1454 | move $a4, rSELF # pass Thread::Current |
| 1455 | RETURN_IF_ZERO |
| 1456 | END art_quick_set_obj_instance |
| 1457 | |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1458 | // Macro to facilitate adding new allocation entrypoints. |
| 1459 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1460 | .extern \entrypoint |
| 1461 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1462 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1463 | jal \entrypoint |
| 1464 | move $a1, rSELF # pass Thread::Current |
| 1465 | \return |
| 1466 | END \name |
| 1467 | .endm |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1468 | |
| 1469 | // Macro to facilitate adding new allocation entrypoints. |
| 1470 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1471 | .extern \entrypoint |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1472 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1473 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1474 | jal \entrypoint |
| 1475 | move $a2, rSELF # pass Thread::Current |
| 1476 | \return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1477 | END \name |
| 1478 | .endm |
| 1479 | |
| 1480 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1481 | .extern \entrypoint |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1482 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1483 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1484 | jal \entrypoint |
| 1485 | move $a3, rSELF # pass Thread::Current |
| 1486 | \return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1487 | END \name |
| 1488 | .endm |
| 1489 | |
Vladimir Marko | e85e123 | 2015-04-28 14:14:58 +0100 | [diff] [blame] | 1490 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1491 | .extern \entrypoint |
| 1492 | ENTRY \name |
| 1493 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1494 | jal \entrypoint |
| 1495 | move $a4, rSELF # pass Thread::Current |
| 1496 | \return |
| 1497 | END \name |
| 1498 | .endm |
| 1499 | |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1500 | // Generate the allocation entrypoints for each allocator. |
Goran Jakovljevic | 982a9a8 | 2015-12-21 12:00:54 +0100 | [diff] [blame] | 1501 | GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1502 | |
Goran Jakovljevic | 982a9a8 | 2015-12-21 12:00:54 +0100 | [diff] [blame] | 1503 | // A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc). |
| 1504 | ENTRY art_quick_alloc_object_rosalloc |
| 1505 | |
| 1506 | # Fast path rosalloc allocation |
| 1507 | # a0: type_idx |
| 1508 | # a1: ArtMethod* |
| 1509 | # s1: Thread::Current |
| 1510 | # ----------------------------- |
| 1511 | # t0: class |
| 1512 | # t1: object size |
| 1513 | # t2: rosalloc run |
| 1514 | # t3: thread stack top offset |
| 1515 | # a4: thread stack bottom offset |
| 1516 | # v0: free list head |
| 1517 | # |
| 1518 | # a5, a6 : temps |
| 1519 | |
| 1520 | ld $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_64($a1) # Load dex cache resolved types array. |
| 1521 | |
| 1522 | dsll $a5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT # Shift the value. |
| 1523 | daddu $a5, $t0, $a5 # Compute the index. |
| 1524 | lwu $t0, 0($a5) # Load class (t0). |
| 1525 | beqzc $t0, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1526 | |
| 1527 | li $a6, MIRROR_CLASS_STATUS_INITIALIZED |
| 1528 | lwu $a5, MIRROR_CLASS_STATUS_OFFSET($t0) # Check class status. |
| 1529 | bnec $a5, $a6, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1530 | |
| 1531 | # Add a fake dependence from the following access flag and size loads to the status load. This |
| 1532 | # is to prevent those loads from being reordered above the status load and reading wrong values. |
| 1533 | xor $a5, $a5, $a5 |
| 1534 | daddu $t0, $t0, $a5 |
| 1535 | |
| 1536 | lwu $a5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0) # Check if access flags has |
| 1537 | li $a6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE # kAccClassIsFinalizable. |
| 1538 | and $a6, $a5, $a6 |
| 1539 | bnezc $a6, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1540 | |
| 1541 | ld $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) # Check if thread local allocation stack |
| 1542 | ld $a4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1) # has any room left. |
| 1543 | bgeuc $t3, $a4, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1544 | |
| 1545 | lwu $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0) # Load object size (t1). |
| 1546 | li $a5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE # Check if size is for a thread local |
| 1547 | # allocation. |
| 1548 | bltuc $a5, $t1, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1549 | |
| 1550 | # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket |
| 1551 | # quantum size and divide by the quantum size and subtract by 1. |
| 1552 | daddiu $t1, $t1, -1 # Decrease obj size and shift right by |
| 1553 | dsrl $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT # quantum. |
| 1554 | |
| 1555 | dsll $t2, $t1, POINTER_SIZE_SHIFT |
| 1556 | daddu $t2, $t2, $s1 |
| 1557 | ld $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2) # Load rosalloc run (t2). |
| 1558 | |
| 1559 | # Load the free list head (v0). |
| 1560 | # NOTE: this will be the return val. |
| 1561 | ld $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2) |
| 1562 | beqzc $v0, .Lart_quick_alloc_object_rosalloc_slow_path |
| 1563 | |
| 1564 | # Load the next pointer of the head and update the list head with the next pointer. |
| 1565 | ld $a5, ROSALLOC_SLOT_NEXT_OFFSET($v0) |
| 1566 | sd $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2) |
| 1567 | |
| 1568 | # Store the class pointer in the header. This also overwrites the first pointer. The offsets are |
| 1569 | # asserted to match. |
| 1570 | |
| 1571 | #if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET |
| 1572 | #error "Class pointer needs to overwrite next pointer." |
| 1573 | #endif |
| 1574 | |
| 1575 | POISON_HEAP_REF $t0 |
| 1576 | sw $t0, MIRROR_OBJECT_CLASS_OFFSET($v0) |
| 1577 | |
| 1578 | # Push the new object onto the thread local allocation stack and increment the thread local |
| 1579 | # allocation stack top. |
| 1580 | sd $v0, 0($t3) |
| 1581 | daddiu $t3, $t3, COMPRESSED_REFERENCE_SIZE |
| 1582 | sd $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) |
| 1583 | |
| 1584 | # Decrement the size of the free list. |
| 1585 | lw $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2) |
| 1586 | addiu $a5, $a5, -1 |
| 1587 | sw $a5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2) |
| 1588 | |
| 1589 | sync # Fence. |
| 1590 | |
| 1591 | jalr $zero, $ra |
| 1592 | .cpreturn # Restore gp from t8 in branch delay slot. |
| 1593 | |
| 1594 | .Lart_quick_alloc_object_rosalloc_slow_path: |
| 1595 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1596 | jal artAllocObjectFromCodeRosAlloc |
| 1597 | move $a2 ,$s1 # Pass self as argument. |
| 1598 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1599 | |
| 1600 | END art_quick_alloc_object_rosalloc |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1601 | |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1602 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB) |
| 1603 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB) |
| 1604 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1605 | /* |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1606 | * Entry from managed code to resolve a string, this stub will allocate a String and deliver an |
| 1607 | * exception on error. On success the String is returned. A0 holds the string index. The fast |
| 1608 | * path check for hit in strings cache has already been performed. |
| 1609 | */ |
| 1610 | ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1611 | |
| 1612 | /* |
| 1613 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 1614 | * initializer and deliver the exception on error. On success the static storage base is |
| 1615 | * returned. |
| 1616 | */ |
| 1617 | ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1618 | |
| 1619 | /* |
| 1620 | * Entry from managed code when dex cache misses for a type_idx. |
| 1621 | */ |
| 1622 | ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1623 | |
| 1624 | /* |
| 1625 | * Entry from managed code when type_idx needs to be checked for access and dex cache may also |
| 1626 | * miss. |
| 1627 | */ |
| 1628 | ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1629 | |
| 1630 | /* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1631 | * Called by managed code when the value in rSUSPEND has been decremented to 0. |
| 1632 | */ |
| 1633 | .extern artTestSuspendFromCode |
| 1634 | ENTRY art_quick_test_suspend |
| 1635 | lh $a0, THREAD_FLAGS_OFFSET(rSELF) |
| 1636 | bne $a0, $zero, 1f |
| 1637 | daddiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 1638 | jalr $zero, $ra |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1639 | .cpreturn # Restore gp from t8 in branch delay slot. |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1640 | 1: |
| 1641 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl |
| 1642 | jal artTestSuspendFromCode # (Thread*) |
| 1643 | move $a0, rSELF |
| 1644 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 1645 | END art_quick_test_suspend |
Douglas Leung | 6461d19 | 2015-01-30 18:13:58 -0800 | [diff] [blame] | 1646 | |
| 1647 | /* |
| 1648 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
| 1649 | * r0 holds the proxy method; r1, r2 and r3 may contain arguments. |
| 1650 | */ |
| 1651 | .extern artQuickProxyInvokeHandler |
| 1652 | ENTRY art_quick_proxy_invoke_handler |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 1653 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0 |
Douglas Leung | 6461d19 | 2015-01-30 18:13:58 -0800 | [diff] [blame] | 1654 | move $a2, rSELF # pass Thread::Current |
| 1655 | jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP) |
| 1656 | move $a3, $sp # pass $sp |
| 1657 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 1658 | daddiu $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE # skip a0-a7 and f12-f19 |
| 1659 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1660 | bne $t0, $zero, 1f |
| 1661 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1662 | jalr $zero, $ra |
| 1663 | dmtc1 $v1, $f1 # place return value to FP return value |
| 1664 | 1: |
| 1665 | DELIVER_PENDING_EXCEPTION |
| 1666 | END art_quick_proxy_invoke_handler |
| 1667 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1668 | /* |
| 1669 | * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's |
| 1670 | * dex method index. |
| 1671 | */ |
| 1672 | ENTRY art_quick_imt_conflict_trampoline |
Nicolas Geoffray | 8ea18d0 | 2015-05-26 16:29:08 +0100 | [diff] [blame] | 1673 | move $a0, $t0 |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 1674 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1675 | END art_quick_imt_conflict_trampoline |
Andreas Gampe | cc7c39d | 2015-01-30 17:04:45 -0800 | [diff] [blame] | 1676 | |
| 1677 | .extern artQuickResolutionTrampoline |
| 1678 | ENTRY art_quick_resolution_trampoline |
| 1679 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1680 | move $a2, rSELF # pass Thread::Current |
| 1681 | jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP) |
| 1682 | move $a3, $sp # pass $sp |
| 1683 | beq $v0, $zero, 1f |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1684 | ld $a0, 0($sp) # load resolved method in $a0 |
Andreas Gampe | cc7c39d | 2015-01-30 17:04:45 -0800 | [diff] [blame] | 1685 | # artQuickResolutionTrampoline puts resolved method in *SP |
| 1686 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1687 | move $t9, $v0 # code pointer must be in $t9 to generate the global pointer |
| 1688 | jalr $zero, $t9 # tail call to method |
| 1689 | nop |
| 1690 | 1: |
| 1691 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1692 | DELIVER_PENDING_EXCEPTION |
| 1693 | END art_quick_resolution_trampoline |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1694 | |
| 1695 | .extern artQuickGenericJniTrampoline |
| 1696 | .extern artQuickGenericJniEndTrampoline |
| 1697 | ENTRY art_quick_generic_jni_trampoline |
Douglas Leung | 8223b80 | 2015-04-28 17:22:29 -0700 | [diff] [blame] | 1698 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0 |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1699 | move $s8, $sp # save $sp |
| 1700 | |
| 1701 | # prepare for call to artQuickGenericJniTrampoline(Thread*, SP) |
| 1702 | move $a0, rSELF # pass Thread::Current |
| 1703 | move $a1, $sp # pass $sp |
| 1704 | jal artQuickGenericJniTrampoline # (Thread*, SP) |
| 1705 | daddiu $sp, $sp, -5120 # reserve space on the stack |
| 1706 | |
| 1707 | # The C call will have registered the complete save-frame on success. |
| 1708 | # The result of the call is: |
| 1709 | # v0: ptr to native code, 0 on error. |
| 1710 | # v1: ptr to the bottom of the used area of the alloca, can restore stack till here. |
| 1711 | beq $v0, $zero, 1f # check entry error |
| 1712 | move $t9, $v0 # save the code ptr |
| 1713 | move $sp, $v1 # release part of the alloca |
| 1714 | |
| 1715 | # Load parameters from stack into registers |
| 1716 | ld $a0, 0($sp) |
| 1717 | ld $a1, 8($sp) |
| 1718 | ld $a2, 16($sp) |
| 1719 | ld $a3, 24($sp) |
| 1720 | ld $a4, 32($sp) |
| 1721 | ld $a5, 40($sp) |
| 1722 | ld $a6, 48($sp) |
| 1723 | ld $a7, 56($sp) |
| 1724 | # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine. |
| 1725 | l.d $f12, 0($sp) |
| 1726 | l.d $f13, 8($sp) |
| 1727 | l.d $f14, 16($sp) |
| 1728 | l.d $f15, 24($sp) |
| 1729 | l.d $f16, 32($sp) |
| 1730 | l.d $f17, 40($sp) |
| 1731 | l.d $f18, 48($sp) |
| 1732 | l.d $f19, 56($sp) |
| 1733 | jalr $t9 # native call |
| 1734 | daddiu $sp, $sp, 64 |
| 1735 | |
| 1736 | # result sign extension is handled in C code |
| 1737 | # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f) |
| 1738 | move $a0, rSELF # pass Thread::Current |
| 1739 | move $a1, $v0 |
| 1740 | jal artQuickGenericJniEndTrampoline |
| 1741 | dmfc1 $a2, $f0 |
| 1742 | |
| 1743 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1744 | bne $t0, $zero, 1f # check for pending exceptions |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1745 | move $sp, $s8 # tear down the alloca |
| 1746 | |
| 1747 | # tear dpown the callee-save frame |
| 1748 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1749 | |
| 1750 | jalr $zero, $ra |
| 1751 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1752 | |
| 1753 | 1: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1754 | ld $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) |
| 1755 | # This will create a new save-all frame, required by the runtime. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1756 | DELIVER_PENDING_EXCEPTION |
| 1757 | END art_quick_generic_jni_trampoline |
| 1758 | |
| 1759 | .extern artQuickToInterpreterBridge |
| 1760 | ENTRY art_quick_to_interpreter_bridge |
| 1761 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1762 | move $a1, rSELF # pass Thread::Current |
| 1763 | jal artQuickToInterpreterBridge # (Method* method, Thread*, SP) |
| 1764 | move $a2, $sp # pass $sp |
| 1765 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 1766 | daddiu $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE # skip a0-a7 and f12-f19 |
| 1767 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1768 | bne $t0, $zero, 1f |
| 1769 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1770 | jalr $zero, $ra |
| 1771 | dmtc1 $v1, $f1 # place return value to FP return value |
| 1772 | 1: |
| 1773 | DELIVER_PENDING_EXCEPTION |
| 1774 | END art_quick_to_interpreter_bridge |
| 1775 | |
| 1776 | /* |
| 1777 | * Routine that intercepts method calls and returns. |
| 1778 | */ |
| 1779 | .extern artInstrumentationMethodEntryFromCode |
| 1780 | .extern artInstrumentationMethodExitFromCode |
| 1781 | ENTRY art_quick_instrumentation_entry |
| 1782 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1783 | daddiu $sp, $sp, -16 # space for saving arg0 |
| 1784 | .cfi_adjust_cfa_offset 16 |
| 1785 | sd $a0, 0($sp) # save arg0 |
| 1786 | move $a3, $ra # pass $ra |
| 1787 | jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, RA) |
| 1788 | move $a2, rSELF # pass Thread::Current |
| 1789 | move $t9, $v0 # $t9 holds reference to code |
| 1790 | ld $a0, 0($sp) # restore arg0 |
| 1791 | daddiu $sp, $sp, 16 # remove args |
| 1792 | .cfi_adjust_cfa_offset -16 |
| 1793 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1794 | jalr $t9 # call method |
| 1795 | nop |
| 1796 | END art_quick_instrumentation_entry |
| 1797 | /* intentional fallthrough */ |
| 1798 | .global art_quick_instrumentation_exit |
| 1799 | art_quick_instrumentation_exit: |
| 1800 | .cfi_startproc |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1801 | SETUP_GP |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1802 | move $ra, $zero # link register is to here, so clobber with 0 for later checks |
| 1803 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1804 | move $t0, $sp # remember bottom of caller's frame |
| 1805 | daddiu $sp, $sp, -16 # save return values and set up args |
| 1806 | .cfi_adjust_cfa_offset 16 |
| 1807 | sd $v0, 0($sp) |
| 1808 | .cfi_rel_offset 2, 0 |
| 1809 | s.d $f0, 8($sp) |
| 1810 | mov.d $f15, $f0 # pass fpr result |
| 1811 | move $a2, $v0 # pass gpr result |
| 1812 | move $a1, $t0 # pass $sp |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1813 | move $a0, rSELF # pass Thread::Current |
Goran Jakovljevic | 0456881 | 2015-04-23 15:27:23 +0200 | [diff] [blame] | 1814 | jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res) |
| 1815 | .cpreturn # Restore gp from t8 in branch delay slot. gp is not used anymore, |
| 1816 | # and t8 may be clobbered in artInstrumentationMethodExitFromCode. |
| 1817 | |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 1818 | move $t9, $v0 # set aside returned link register |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1819 | move $ra, $v1 # set link register for deoptimization |
| 1820 | ld $v0, 0($sp) # restore return values |
| 1821 | l.d $f0, 8($sp) |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 1822 | jalr $zero, $t9 # return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1823 | daddiu $sp, $sp, 16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE # 16 bytes of saved values + ref_only callee save frame |
| 1824 | .cfi_adjust_cfa_offset -(16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE) |
| 1825 | END art_quick_instrumentation_exit |
| 1826 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1827 | /* |
| 1828 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 1829 | * will long jump to the upcall with a special exception of -1. |
| 1830 | */ |
| 1831 | .extern artDeoptimize |
| 1832 | .extern artEnterInterpreterFromDeoptimize |
| 1833 | ENTRY art_quick_deoptimize |
| 1834 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1835 | jal artDeoptimize # artDeoptimize(Thread*, SP) |
| 1836 | # Returns caller method's frame size. |
| 1837 | move $a0, rSELF # pass Thread::current |
| 1838 | END art_quick_deoptimize |
| 1839 | |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 1840 | /* |
| 1841 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
| 1842 | * will long jump to the upcall with a special exception of -1. |
| 1843 | */ |
| 1844 | .extern artDeoptimizeFromCompiledCode |
| 1845 | ENTRY art_quick_deoptimize_from_compiled_code |
| 1846 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1847 | jal artDeoptimizeFromCompiledCode # artDeoptimizeFromCompiledCode(Thread*, SP) |
| 1848 | # Returns caller method's frame size. |
| 1849 | move $a0, rSELF # pass Thread::current |
| 1850 | END art_quick_deoptimize_from_compiled_code |
| 1851 | |
Chris Larsen | 9701c2e | 2015-09-04 17:22:47 -0700 | [diff] [blame] | 1852 | .set push |
| 1853 | .set noat |
| 1854 | /* java.lang.String.compareTo(String anotherString) */ |
| 1855 | ENTRY_NO_GP art_quick_string_compareto |
| 1856 | /* $a0 holds address of "this" */ |
| 1857 | /* $a1 holds address of "anotherString" */ |
| 1858 | beq $a0,$a1,9f # this and anotherString are the same object |
| 1859 | move $v0,$zero |
| 1860 | |
| 1861 | lw $a2,MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
| 1862 | lw $a3,MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length() |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 1863 | MINu $t2, $a2, $a3 |
| 1864 | # $t2 now holds min(this.length(),anotherString.length()) |
Chris Larsen | 9701c2e | 2015-09-04 17:22:47 -0700 | [diff] [blame] | 1865 | |
| 1866 | beqz $t2,9f # while min(this.length(),anotherString.length())-i != 0 |
| 1867 | subu $v0,$a2,$a3 # if $t2==0 return |
| 1868 | # (this.length() - anotherString.length()) |
| 1869 | 1: |
| 1870 | lhu $t0,MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i) |
| 1871 | lhu $t1,MIRROR_STRING_VALUE_OFFSET($a1) |
| 1872 | bne $t0,$t1,9f # if this.charAt(i) != anotherString.charAt(i) |
| 1873 | subu $v0,$t0,$t1 # return (this.charAt(i) - anotherString.charAt(i)) |
| 1874 | daddiu $a0,$a0,2 # point at this.charAt(i++) |
| 1875 | subu $t2,$t2,1 # new value of |
| 1876 | # min(this.length(),anotherString.length())-i |
| 1877 | bnez $t2,1b |
| 1878 | daddiu $a1,$a1,2 # point at anotherString.charAt(i++) |
| 1879 | subu $v0,$a2,$a3 |
| 1880 | |
| 1881 | 9: |
| 1882 | j $ra |
| 1883 | nop |
| 1884 | END art_quick_string_compareto |
| 1885 | |
| 1886 | /* java.lang.String.indexOf(int ch, int fromIndex=0) */ |
| 1887 | ENTRY_NO_GP art_quick_indexof |
| 1888 | /* $a0 holds address of "this" */ |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 1889 | /* $a1 holds "ch" */ |
| 1890 | /* $a2 holds "fromIndex" */ |
Chris Larsen | 9701c2e | 2015-09-04 17:22:47 -0700 | [diff] [blame] | 1891 | lw $t0,MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 1892 | slt $at, $a2, $zero # if fromIndex < 0 |
| 1893 | seleqz $a2, $a2, $at # fromIndex = 0; |
| 1894 | subu $t0,$t0,$a2 # this.length() - fromIndex |
| 1895 | blez $t0,6f # if this.length()-fromIndex <= 0 |
Chris Larsen | 9701c2e | 2015-09-04 17:22:47 -0700 | [diff] [blame] | 1896 | li $v0,-1 # return -1; |
| 1897 | |
| 1898 | sll $v0,$a2,1 # $a0 += $a2 * 2 |
| 1899 | daddu $a0,$a0,$v0 # " " " " " |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 1900 | move $v0,$a2 # Set i to fromIndex. |
Chris Larsen | 9701c2e | 2015-09-04 17:22:47 -0700 | [diff] [blame] | 1901 | |
| 1902 | 1: |
| 1903 | lhu $t3,MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch |
| 1904 | beq $t3,$a1,6f # return i; |
| 1905 | daddu $a0,$a0,2 # i++ |
| 1906 | subu $t0,$t0,1 # this.length() - i |
| 1907 | bnez $t0,1b # while this.length() - i > 0 |
| 1908 | addu $v0,$v0,1 # i++ |
| 1909 | |
| 1910 | li $v0,-1 # if this.length() - i <= 0 |
| 1911 | # return -1; |
| 1912 | |
| 1913 | 6: |
| 1914 | j $ra |
| 1915 | nop |
| 1916 | END art_quick_indexof |
| 1917 | |
| 1918 | .set pop |