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 | /* |
| 30 | * Macro that sets up the callee save frame to conform with |
| 31 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
| 32 | * callee-save: padding + $f24-$f31 + $s0-$s7 + $gp + $ra + $s8 = 19 total + 1x8 bytes padding |
| 33 | */ |
| 34 | .macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 35 | daddiu $sp, $sp, -160 |
| 36 | .cfi_adjust_cfa_offset 160 |
| 37 | |
| 38 | // Ugly compile-time check, but we only have the preprocessor. |
| 39 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 160) |
| 40 | #error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 41 | #endif |
| 42 | |
| 43 | sd $ra, 152($sp) |
| 44 | .cfi_rel_offset 31, 152 |
| 45 | sd $s8, 144($sp) |
| 46 | .cfi_rel_offset 30, 144 |
| 47 | sd $gp, 136($sp) |
| 48 | .cfi_rel_offset 28, 136 |
| 49 | sd $s7, 128($sp) |
| 50 | .cfi_rel_offset 23, 128 |
| 51 | sd $s6, 120($sp) |
| 52 | .cfi_rel_offset 22, 120 |
| 53 | sd $s5, 112($sp) |
| 54 | .cfi_rel_offset 21, 112 |
| 55 | sd $s4, 104($sp) |
| 56 | .cfi_rel_offset 20, 104 |
| 57 | sd $s3, 96($sp) |
| 58 | .cfi_rel_offset 19, 96 |
| 59 | sd $s2, 88($sp) |
| 60 | .cfi_rel_offset 18, 88 |
| 61 | sd $s1, 80($sp) |
| 62 | .cfi_rel_offset 17, 80 |
| 63 | sd $s0, 72($sp) |
| 64 | .cfi_rel_offset 16, 72 |
| 65 | |
| 66 | // FP callee-saves |
| 67 | s.d $f31, 64($sp) |
| 68 | s.d $f30, 56($sp) |
| 69 | s.d $f29, 48($sp) |
| 70 | s.d $f28, 40($sp) |
| 71 | s.d $f27, 32($sp) |
| 72 | s.d $f26, 24($sp) |
| 73 | s.d $f25, 16($sp) |
| 74 | s.d $f24, 8($sp) |
| 75 | |
| 76 | # load appropriate callee-save-method |
| 77 | ld $v0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 78 | ld $v0, 0($v0) |
| 79 | THIS_LOAD_REQUIRES_READ_BARRIER |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 80 | lwu $v0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($v0) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 81 | sw $v0, 0($sp) # Place Method* at bottom of stack. |
| 82 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 83 | .endm |
| 84 | |
| 85 | /* |
| 86 | * Macro that sets up the callee save frame to conform with |
| 87 | * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes |
| 88 | * non-moving GC. |
| 89 | * Does not include rSUSPEND or rSELF |
| 90 | * callee-save: padding + $s2-$s7 + $gp + $ra + $s8 = 9 total + 1x8 bytes padding |
| 91 | */ |
| 92 | .macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
| 93 | daddiu $sp, $sp, -80 |
| 94 | .cfi_adjust_cfa_offset 80 |
| 95 | |
| 96 | // Ugly compile-time check, but we only have the preprocessor. |
| 97 | #if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 80) |
| 98 | #error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 99 | #endif |
| 100 | |
| 101 | sd $ra, 72($sp) |
| 102 | .cfi_rel_offset 31, 72 |
| 103 | sd $s8, 64($sp) |
| 104 | .cfi_rel_offset 30, 64 |
| 105 | sd $gp, 56($sp) |
| 106 | .cfi_rel_offset 28, 56 |
| 107 | sd $s7, 48($sp) |
| 108 | .cfi_rel_offset 23, 48 |
| 109 | sd $s6, 40($sp) |
| 110 | .cfi_rel_offset 22, 40 |
| 111 | sd $s5, 32($sp) |
| 112 | .cfi_rel_offset 21, 32 |
| 113 | sd $s4, 24($sp) |
| 114 | .cfi_rel_offset 20, 24 |
| 115 | sd $s3, 16($sp) |
| 116 | .cfi_rel_offset 19, 16 |
| 117 | sd $s2, 8($sp) |
| 118 | .cfi_rel_offset 18, 8 |
| 119 | # load appropriate callee-save-method |
| 120 | ld $v0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 121 | ld $v0, 0($v0) |
| 122 | THIS_LOAD_REQUIRES_READ_BARRIER |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 123 | lwu $v0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($v0) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 124 | sw $v0, 0($sp) # Place Method* at bottom of stack. |
| 125 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 126 | .endm |
| 127 | |
| 128 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 129 | ld $ra, 72($sp) |
| 130 | .cfi_restore 31 |
| 131 | ld $s8, 64($sp) |
| 132 | .cfi_restore 30 |
| 133 | ld $gp, 56($sp) |
| 134 | .cfi_restore 28 |
| 135 | ld $s7, 48($sp) |
| 136 | .cfi_restore 23 |
| 137 | ld $s6, 40($sp) |
| 138 | .cfi_restore 22 |
| 139 | ld $s5, 32($sp) |
| 140 | .cfi_restore 21 |
| 141 | ld $s4, 24($sp) |
| 142 | .cfi_restore 20 |
| 143 | ld $s3, 16($sp) |
| 144 | .cfi_restore 19 |
| 145 | ld $s2, 8($sp) |
| 146 | .cfi_restore 18 |
| 147 | daddiu $sp, $sp, 80 |
| 148 | .cfi_adjust_cfa_offset -80 |
| 149 | .endm |
| 150 | |
| 151 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 152 | ld $ra, 72($sp) |
| 153 | .cfi_restore 31 |
| 154 | ld $s8, 64($sp) |
| 155 | .cfi_restore 30 |
| 156 | ld $gp, 56($sp) |
| 157 | .cfi_restore 28 |
| 158 | ld $s7, 48($sp) |
| 159 | .cfi_restore 23 |
| 160 | ld $s6, 40($sp) |
| 161 | .cfi_restore 22 |
| 162 | ld $s5, 32($sp) |
| 163 | .cfi_restore 21 |
| 164 | ld $s4, 24($sp) |
| 165 | .cfi_restore 20 |
| 166 | ld $s3, 16($sp) |
| 167 | .cfi_restore 19 |
| 168 | ld $s2, 8($sp) |
| 169 | .cfi_restore 18 |
| 170 | jalr $zero, $ra |
| 171 | daddiu $sp, $sp, 80 |
| 172 | .cfi_adjust_cfa_offset -80 |
| 173 | .endm |
| 174 | |
| 175 | // This assumes the top part of these stack frame types are identical. |
| 176 | #define REFS_AND_ARGS_MINUS_REFS_SIZE (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE - FRAME_SIZE_REFS_ONLY_CALLEE_SAVE) |
| 177 | |
| 178 | /* |
| 179 | * Macro that sets up the callee save frame to conform with |
| 180 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes |
| 181 | * non-moving GC. |
| 182 | * callee-save: padding + $f12-$f19 + $a1-$a7 + $s2-$s7 + $gp + $ra + $s8 = 24 total + 1 words padding + Method* |
| 183 | */ |
| 184 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 185 | daddiu $sp, $sp, -208 |
| 186 | .cfi_adjust_cfa_offset 208 |
| 187 | |
| 188 | // Ugly compile-time check, but we only have the preprocessor. |
| 189 | #if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 208) |
| 190 | #error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS64) size not as expected." |
| 191 | #endif |
| 192 | |
| 193 | sd $ra, 200($sp) # = kQuickCalleeSaveFrame_RefAndArgs_LrOffset |
| 194 | .cfi_rel_offset 31, 200 |
| 195 | sd $s8, 192($sp) |
| 196 | .cfi_rel_offset 30, 192 |
| 197 | sd $gp, 184($sp) |
| 198 | .cfi_rel_offset 28, 184 |
| 199 | sd $s7, 176($sp) |
| 200 | .cfi_rel_offset 23, 176 |
| 201 | sd $s6, 168($sp) |
| 202 | .cfi_rel_offset 22, 168 |
| 203 | sd $s5, 160($sp) |
| 204 | .cfi_rel_offset 21, 160 |
| 205 | sd $s4, 152($sp) |
| 206 | .cfi_rel_offset 20, 152 |
| 207 | sd $s3, 144($sp) |
| 208 | .cfi_rel_offset 19, 144 |
| 209 | sd $s2, 136($sp) |
| 210 | .cfi_rel_offset 18, 136 |
| 211 | |
| 212 | sd $a7, 128($sp) |
| 213 | .cfi_rel_offset 11, 128 |
| 214 | sd $a6, 120($sp) |
| 215 | .cfi_rel_offset 10, 120 |
| 216 | sd $a5, 112($sp) |
| 217 | .cfi_rel_offset 9, 112 |
| 218 | sd $a4, 104($sp) |
| 219 | .cfi_rel_offset 8, 104 |
| 220 | sd $a3, 96($sp) |
| 221 | .cfi_rel_offset 7, 96 |
| 222 | sd $a2, 88($sp) |
| 223 | .cfi_rel_offset 6, 88 |
| 224 | sd $a1, 80($sp) # = kQuickCalleeSaveFrame_RefAndArgs_Gpr1Offset |
| 225 | .cfi_rel_offset 5, 80 |
| 226 | |
| 227 | s.d $f19, 72($sp) |
| 228 | s.d $f18, 64($sp) |
| 229 | s.d $f17, 56($sp) |
| 230 | s.d $f16, 48($sp) |
| 231 | s.d $f15, 40($sp) |
| 232 | s.d $f14, 32($sp) |
| 233 | s.d $f13, 24($sp) # = kQuickCalleeSaveFrame_RefAndArgs_Fpr1Offset |
| 234 | s.d $f12, 16($sp) # This isn't necessary to store. |
| 235 | |
| 236 | # 1x8 bytes paddig + Method* |
| 237 | ld $v0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 238 | ld $v0, 0($v0) |
| 239 | THIS_LOAD_REQUIRES_READ_BARRIER |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 240 | lwu $v0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($v0) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 241 | sw $v0, 0($sp) # Place Method* at bottom of stack. |
| 242 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 243 | .endm |
| 244 | |
| 245 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 246 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 247 | # load appropriate callee-save-method |
| 248 | ld $v0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 249 | ld $v0, 0($v0) |
| 250 | THIS_LOAD_REQUIRES_READ_BARRIER |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 251 | lwu $v0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($v0) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 252 | sw $v0, 0($sp) # Place Method* at bottom of stack. |
| 253 | sd $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 254 | .endm |
| 255 | |
| 256 | .macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 257 | ld $ra, 200($sp) |
| 258 | .cfi_restore 31 |
| 259 | ld $s8, 192($sp) |
| 260 | .cfi_restore 30 |
| 261 | ld $gp, 184($sp) |
| 262 | .cfi_restore 28 |
| 263 | ld $s7, 176($sp) |
| 264 | .cfi_restore 23 |
| 265 | ld $s6, 168($sp) |
| 266 | .cfi_restore 22 |
| 267 | ld $s5, 160($sp) |
| 268 | .cfi_restore 21 |
| 269 | ld $s4, 152($sp) |
| 270 | .cfi_restore 20 |
| 271 | ld $s3, 144($sp) |
| 272 | .cfi_restore 19 |
| 273 | ld $s2, 136($sp) |
| 274 | .cfi_restore 18 |
| 275 | |
| 276 | ld $a7, 128($sp) |
| 277 | .cfi_restore 11 |
| 278 | ld $a6, 120($sp) |
| 279 | .cfi_restore 10 |
| 280 | ld $a5, 112($sp) |
| 281 | .cfi_restore 9 |
| 282 | ld $a4, 104($sp) |
| 283 | .cfi_restore 8 |
| 284 | ld $a3, 96($sp) |
| 285 | .cfi_restore 7 |
| 286 | ld $a2, 88($sp) |
| 287 | .cfi_restore 6 |
| 288 | ld $a1, 80($sp) |
| 289 | .cfi_restore 5 |
| 290 | |
| 291 | l.d $f19, 72($sp) |
| 292 | l.d $f18, 64($sp) |
| 293 | l.d $f17, 56($sp) |
| 294 | l.d $f16, 48($sp) |
| 295 | l.d $f15, 40($sp) |
| 296 | l.d $f14, 32($sp) |
| 297 | l.d $f13, 24($sp) |
| 298 | l.d $f12, 16($sp) |
| 299 | |
| 300 | daddiu $sp, $sp, 208 |
| 301 | .cfi_adjust_cfa_offset -208 |
| 302 | .endm |
| 303 | |
| 304 | /* |
| 305 | * Macro that set calls through to artDeliverPendingExceptionFromCode, |
| 306 | * where the pending |
| 307 | * exception is Thread::Current()->exception_ |
| 308 | */ |
| 309 | .macro DELIVER_PENDING_EXCEPTION |
| 310 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw |
| 311 | dla $t9, artDeliverPendingExceptionFromCode |
| 312 | jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*) |
| 313 | move $a0, rSELF # pass Thread::Current |
| 314 | .endm |
| 315 | |
| 316 | .macro RETURN_IF_NO_EXCEPTION |
| 317 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 318 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 319 | bne $t0, $zero, 1f # success if no exception is pending |
| 320 | nop |
| 321 | jalr $zero, $ra |
| 322 | nop |
| 323 | 1: |
| 324 | DELIVER_PENDING_EXCEPTION |
| 325 | .endm |
| 326 | |
| 327 | .macro RETURN_IF_ZERO |
| 328 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 329 | bne $v0, $zero, 1f # success? |
| 330 | nop |
| 331 | jalr $zero, $ra # return on success |
| 332 | nop |
| 333 | 1: |
| 334 | DELIVER_PENDING_EXCEPTION |
| 335 | .endm |
| 336 | |
| 337 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 338 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 339 | beq $v0, $zero, 1f # success? |
| 340 | nop |
| 341 | jalr $zero, $ra # return on success |
| 342 | nop |
| 343 | 1: |
| 344 | DELIVER_PENDING_EXCEPTION |
| 345 | .endm |
| 346 | |
| 347 | /* |
| 348 | * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_ |
| 349 | * FIXME: just guessing about the shape of the jmpbuf. Where will pc be? |
| 350 | */ |
| 351 | ENTRY art_quick_do_long_jump |
| 352 | l.d $f0, 0($a1) |
| 353 | l.d $f1, 8($a1) |
| 354 | l.d $f2, 16($a1) |
| 355 | l.d $f3, 24($a1) |
| 356 | l.d $f4, 32($a1) |
| 357 | l.d $f5, 40($a1) |
| 358 | l.d $f6, 48($a1) |
| 359 | l.d $f7, 56($a1) |
| 360 | l.d $f8, 64($a1) |
| 361 | l.d $f9, 72($a1) |
| 362 | l.d $f10, 80($a1) |
| 363 | l.d $f11, 88($a1) |
| 364 | l.d $f12, 96($a1) |
| 365 | l.d $f13, 104($a1) |
| 366 | l.d $f14, 112($a1) |
| 367 | l.d $f15, 120($a1) |
| 368 | l.d $f16, 128($a1) |
| 369 | l.d $f17, 136($a1) |
| 370 | l.d $f18, 144($a1) |
| 371 | l.d $f19, 152($a1) |
| 372 | l.d $f20, 160($a1) |
| 373 | l.d $f21, 168($a1) |
| 374 | l.d $f22, 176($a1) |
| 375 | l.d $f23, 184($a1) |
| 376 | l.d $f24, 192($a1) |
| 377 | l.d $f25, 200($a1) |
| 378 | l.d $f26, 208($a1) |
| 379 | l.d $f27, 216($a1) |
| 380 | l.d $f28, 224($a1) |
| 381 | l.d $f29, 232($a1) |
| 382 | l.d $f30, 240($a1) |
| 383 | l.d $f31, 248($a1) |
| 384 | .set push |
| 385 | .set nomacro |
| 386 | .set noat |
| 387 | # no need to load zero |
| 388 | ld $at, 8($a0) |
| 389 | .set pop |
| 390 | ld $v0, 16($a0) |
| 391 | ld $v1, 24($a0) |
| 392 | # a0 has to be loaded last |
| 393 | ld $a1, 40($a0) |
| 394 | ld $a2, 48($a0) |
| 395 | ld $a3, 56($a0) |
| 396 | ld $a4, 64($a0) |
| 397 | ld $a5, 72($a0) |
| 398 | ld $a6, 80($a0) |
| 399 | ld $a7, 88($a0) |
| 400 | ld $t0, 96($a0) |
| 401 | ld $t1, 104($a0) |
| 402 | ld $t2, 112($a0) |
| 403 | ld $t3, 120($a0) |
| 404 | ld $s0, 128($a0) |
| 405 | ld $s1, 136($a0) |
| 406 | ld $s2, 144($a0) |
| 407 | ld $s3, 152($a0) |
| 408 | ld $s4, 160($a0) |
| 409 | ld $s5, 168($a0) |
| 410 | ld $s6, 176($a0) |
| 411 | ld $s7, 184($a0) |
| 412 | ld $t8, 192($a0) |
| 413 | ld $t9, 200($a0) |
| 414 | # no need to load k0, k1 |
| 415 | ld $gp, 224($a0) |
| 416 | ld $sp, 232($a0) |
| 417 | ld $s8, 240($a0) |
| 418 | ld $ra, 248($a0) |
| 419 | ld $a0, 32($a0) |
| 420 | move $v0, $zero # clear result registers v0 and v1 |
| 421 | jalr $zero, $ra # do long jump |
| 422 | move $v1, $zero |
| 423 | END art_quick_do_long_jump |
| 424 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 425 | /* |
| 426 | * Called by managed code, saves most registers (forms basis of long jump |
| 427 | * context) and passes the bottom of the stack. |
| 428 | * artDeliverExceptionFromCode will place the callee save Method* at |
| 429 | * the bottom of the thread. On entry v0 holds Throwable* |
| 430 | */ |
| 431 | ENTRY art_quick_deliver_exception |
| 432 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 433 | dla $t9, artDeliverExceptionFromCode |
| 434 | jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*) |
| 435 | move $a1, rSELF # pass Thread::Current |
| 436 | END art_quick_deliver_exception |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 437 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 438 | /* |
| 439 | * Called by managed code to create and deliver a NullPointerException |
| 440 | */ |
| 441 | .extern artThrowNullPointerExceptionFromCode |
| 442 | ENTRY art_quick_throw_null_pointer_exception |
| 443 | .Lart_quick_throw_null_pointer_exception_gp_set: |
| 444 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 445 | dla $t9, artThrowNullPointerExceptionFromCode |
| 446 | jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*) |
| 447 | move $a0, rSELF # pass Thread::Current |
| 448 | END art_quick_throw_null_pointer_exception |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 449 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 450 | /* |
| 451 | * Called by managed code to create and deliver an ArithmeticException |
| 452 | */ |
| 453 | .extern artThrowDivZeroFromCode |
| 454 | ENTRY art_quick_throw_div_zero |
| 455 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 456 | dla $t9, artThrowDivZeroFromCode |
| 457 | jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*) |
| 458 | move $a0, rSELF # pass Thread::Current |
| 459 | END art_quick_throw_div_zero |
| 460 | |
| 461 | /* |
| 462 | * Called by managed code to create and deliver an |
| 463 | * ArrayIndexOutOfBoundsException |
| 464 | */ |
| 465 | .extern artThrowArrayBoundsFromCode |
| 466 | ENTRY art_quick_throw_array_bounds |
| 467 | .Lart_quick_throw_array_bounds_gp_set: |
| 468 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 469 | dla $t9, artThrowArrayBoundsFromCode |
| 470 | jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*) |
| 471 | move $a2, rSELF # pass Thread::Current |
| 472 | END art_quick_throw_array_bounds |
| 473 | |
| 474 | /* |
| 475 | * Called by managed code to create and deliver a StackOverflowError. |
| 476 | */ |
| 477 | .extern artThrowStackOverflowFromCode |
| 478 | ENTRY art_quick_throw_stack_overflow |
| 479 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 480 | dla $t9, artThrowStackOverflowFromCode |
| 481 | jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*) |
| 482 | move $a0, rSELF # pass Thread::Current |
| 483 | END art_quick_throw_stack_overflow |
| 484 | |
| 485 | /* |
| 486 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 487 | */ |
| 488 | .extern artThrowNoSuchMethodFromCode |
| 489 | ENTRY art_quick_throw_no_such_method |
| 490 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 491 | dla $t9, artThrowNoSuchMethodFromCode |
| 492 | jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*) |
| 493 | move $a1, rSELF # pass Thread::Current |
| 494 | END art_quick_throw_no_such_method |
| 495 | |
| 496 | /* |
| 497 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 498 | * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain |
| 499 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 500 | * stack and call the appropriate C helper. |
| 501 | * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1. |
| 502 | * |
| 503 | * The helper will attempt to locate the target and return a 128-bit result in $v0/$v1 consisting |
| 504 | * of the target Method* in $v0 and method->code_ in $v1. |
| 505 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 506 | * 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] | 507 | * thread and we branch to another stub to deliver it. |
| 508 | * |
| 509 | * On success this wrapper will restore arguments and *jump* to the target, leaving the ra |
| 510 | * pointing back to the original caller. |
| 511 | */ |
| 512 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 513 | .extern \cxx_name |
| 514 | ENTRY \c_name |
| 515 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC |
| 516 | lwu $a2, FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE($sp) # pass caller Method* |
| 517 | move $a3, rSELF # pass Thread::Current |
| 518 | jal \cxx_name # (method_idx, this, caller, Thread*, $sp) |
| 519 | move $a4, $sp # pass $sp |
| 520 | move $a0, $v0 # save target Method* |
| 521 | move $t9, $v1 # save $v0->code_ |
| 522 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 523 | beq $v0, $zero, 1f |
| 524 | nop |
| 525 | jalr $zero, $t9 |
| 526 | nop |
| 527 | 1: |
| 528 | DELIVER_PENDING_EXCEPTION |
| 529 | END \c_name |
| 530 | .endm |
| 531 | |
| 532 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 533 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 534 | |
| 535 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 536 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 537 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 538 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 539 | |
| 540 | # On entry: |
| 541 | # t0 = shorty |
| 542 | # t1 = ptr to arg_array |
| 543 | # t2 = number of argument bytes remain |
| 544 | # v0 = ptr to stack frame where to copy arg_array |
| 545 | # This macro modifies t3, t9 and v0 |
| 546 | .macro LOOP_OVER_SHORTY_LOADING_REG gpu, fpu, label |
| 547 | lbu $t3, 0($t0) # get argument type from shorty |
| 548 | beqz $t3, \label |
| 549 | daddiu $t0, 1 |
| 550 | li $t9, 68 # put char 'D' into t9 |
| 551 | beq $t9, $t3, 1f # branch if result type char == 'D' |
| 552 | li $t9, 70 # put char 'F' into t9 |
| 553 | beq $t9, $t3, 2f # branch if result type char == 'F' |
| 554 | li $t9, 74 # put char 'J' into t9 |
| 555 | beq $t9, $t3, 3f # branch if result type char == 'J' |
| 556 | nop |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 557 | lw $\gpu, 0($t1) |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 558 | sw $\gpu, 0($v0) |
| 559 | daddiu $v0, 4 |
| 560 | daddiu $t1, 4 |
| 561 | b 4f |
| 562 | daddiu $t2, -4 # delay slot |
| 563 | |
| 564 | 1: # found double |
| 565 | lwu $t3, 0($t1) |
| 566 | mtc1 $t3, $\fpu |
| 567 | sw $t3, 0($v0) |
| 568 | lwu $t3, 4($t1) |
| 569 | mthc1 $t3, $\fpu |
| 570 | sw $t3, 4($v0) |
| 571 | daddiu $v0, 8 |
| 572 | daddiu $t1, 8 |
| 573 | b 4f |
| 574 | daddiu $t2, -8 # delay slot |
| 575 | |
| 576 | 2: # found float |
| 577 | lwu $t3, 0($t1) |
| 578 | mtc1 $t3, $\fpu |
| 579 | sw $t3, 0($v0) |
| 580 | daddiu $v0, 4 |
| 581 | daddiu $t1, 4 |
| 582 | b 4f |
| 583 | daddiu $t2, -4 # delay slot |
| 584 | |
| 585 | 3: # found long (8 bytes) |
| 586 | lwu $t3, 0($t1) |
| 587 | sw $t3, 0($v0) |
| 588 | lwu $t9, 4($t1) |
| 589 | sw $t9, 4($v0) |
| 590 | dsll $t9, $t9, 32 |
| 591 | or $\gpu, $t9, $t3 |
| 592 | daddiu $v0, 8 |
| 593 | daddiu $t1, 8 |
| 594 | daddiu $t2, -8 |
| 595 | 4: |
| 596 | .endm |
| 597 | |
| 598 | /* |
| 599 | * Invocation stub for quick code. |
| 600 | * On entry: |
| 601 | * a0 = method pointer |
| 602 | * a1 = argument array that must at least contain the this ptr. |
| 603 | * a2 = size of argument array in bytes |
| 604 | * a3 = (managed) thread pointer |
| 605 | * a4 = JValue* result |
| 606 | * a5 = shorty |
| 607 | */ |
| 608 | ENTRY art_quick_invoke_stub |
| 609 | # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra onto the stack |
| 610 | daddiu $sp, $sp, -48 |
| 611 | .cfi_adjust_cfa_offset 48 |
| 612 | sd $ra, 40($sp) |
| 613 | .cfi_rel_offset 31, 40 |
| 614 | sd $s8, 32($sp) |
| 615 | .cfi_rel_offset 30, 32 |
| 616 | sd $s1, 24($sp) |
| 617 | .cfi_rel_offset 17, 24 |
| 618 | sd $s0, 16($sp) |
| 619 | .cfi_rel_offset 16, 16 |
| 620 | sd $a5, 8($sp) |
| 621 | .cfi_rel_offset 9, 8 |
| 622 | sd $a4, 0($sp) |
| 623 | .cfi_rel_offset 8, 0 |
| 624 | |
| 625 | daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 626 | move $s1, $a3 # move managed thread pointer into s1 (rSELF) |
| 627 | move $s8, $sp # save sp in s8 (fp) |
| 628 | |
| 629 | daddiu $t3, $a2, 20 # add 4 for method* and 16 for stack alignment |
| 630 | dsrl $t3, $t3, 4 # shift the frame size right 4 |
| 631 | dsll $t3, $t3, 4 # shift the frame size left 4 to align to 16 bytes |
| 632 | dsubu $sp, $sp, $t3 # reserve stack space for argument array |
| 633 | |
| 634 | daddiu $t0, $a5, 1 # t0 = shorty[1] (skip 1 for return type) |
| 635 | daddiu $t1, $a1, 4 # t1 = ptr to arg_array[4] (skip this ptr) |
| 636 | daddiu $t2, $a2, -4 # t2 = number of argument bytes remain (skip this ptr) |
| 637 | daddiu $v0, $sp, 8 # v0 points to where to copy arg_array |
| 638 | LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_fn |
| 639 | LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_fn |
| 640 | LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_fn |
| 641 | LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_fn |
| 642 | LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_fn |
| 643 | LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_fn |
| 644 | |
| 645 | # copy arguments onto stack (t2 should be multiples of 4) |
| 646 | ble $t2, $zero, call_fn # t2 = number of argument bytes remain |
| 647 | 1: |
| 648 | lw $t3, 0($t1) # load from argument array |
| 649 | daddiu $t1, $t1, 4 |
| 650 | sw $t3, 0($v0) # save to stack |
| 651 | daddiu $t2, -4 |
| 652 | bgt $t2, $zero, 1b # t2 = number of argument bytes remain |
| 653 | daddiu $v0, $v0, 4 |
| 654 | |
| 655 | call_fn: |
| 656 | # call method (a0 and a1 have been untouched) |
| 657 | lwu $a1, 0($a1) # make a1 = this ptr |
| 658 | sw $a1, 4($sp) # copy this ptr (skip 4 bytes for method*) |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 659 | sw $zero, 0($sp) # store null for method* at bottom of frame |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 660 | ld $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET_64($a0) # get pointer to the code |
| 661 | jalr $t9 # call the method |
| 662 | nop |
| 663 | move $sp, $s8 # restore sp |
| 664 | |
| 665 | # pop a4, a5, s1(rSELF), s8, ra off of the stack |
| 666 | ld $a4, 0($sp) |
| 667 | .cfi_restore 8 |
| 668 | ld $a5, 8($sp) |
| 669 | .cfi_restore 9 |
| 670 | ld $s0, 16($sp) |
| 671 | .cfi_restore 16 |
| 672 | ld $s1, 24($sp) |
| 673 | .cfi_restore 17 |
| 674 | ld $s8, 32($sp) |
| 675 | .cfi_restore 30 |
| 676 | ld $ra, 40($sp) |
| 677 | .cfi_restore 31 |
| 678 | daddiu $sp, $sp, 48 |
| 679 | .cfi_adjust_cfa_offset -48 |
| 680 | |
| 681 | # a4 = JValue* result |
| 682 | # a5 = shorty string |
| 683 | lbu $t1, 0($a5) # get result type from shorty |
| 684 | li $t2, 68 # put char 'D' into t2 |
| 685 | beq $t1, $t2, 1f # branch if result type char == 'D' |
| 686 | li $t3, 70 # put char 'F' into t3 |
| 687 | beq $t1, $t3, 1f # branch if result type char == 'F' |
| 688 | sw $v0, 0($a4) # store the result |
| 689 | dsrl $v1, $v0, 32 |
| 690 | jalr $zero, $ra |
| 691 | sw $v1, 4($a4) # store the other half of the result |
| 692 | 1: |
| 693 | mfc1 $v0, $f0 |
| 694 | mfhc1 $v1, $f0 |
| 695 | sw $v0, 0($a4) # store the result |
| 696 | jalr $zero, $ra |
| 697 | sw $v1, 4($a4) # store the other half of the result |
| 698 | END art_quick_invoke_stub |
| 699 | |
| 700 | /* |
| 701 | * Invocation static stub for quick code. |
| 702 | * On entry: |
| 703 | * a0 = method pointer |
| 704 | * a1 = argument array that must at least contain the this ptr. |
| 705 | * a2 = size of argument array in bytes |
| 706 | * a3 = (managed) thread pointer |
| 707 | * a4 = JValue* result |
| 708 | * a5 = shorty |
| 709 | */ |
| 710 | ENTRY art_quick_invoke_static_stub |
| 711 | |
| 712 | # push a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra, onto the stack |
| 713 | daddiu $sp, $sp, -48 |
| 714 | .cfi_adjust_cfa_offset 48 |
| 715 | sd $ra, 40($sp) |
| 716 | .cfi_rel_offset 31, 40 |
| 717 | sd $s8, 32($sp) |
| 718 | .cfi_rel_offset 30, 32 |
| 719 | sd $s1, 24($sp) |
| 720 | .cfi_rel_offset 17, 24 |
| 721 | sd $s0, 16($sp) |
| 722 | .cfi_rel_offset 16, 16 |
| 723 | sd $a5, 8($sp) |
| 724 | .cfi_rel_offset 9, 8 |
| 725 | sd $a4, 0($sp) |
| 726 | .cfi_rel_offset 8, 0 |
| 727 | |
| 728 | daddiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 729 | move $s1, $a3 # move managed thread pointer into s1 (rSELF) |
| 730 | move $s8, $sp # save sp in s8 (fp) |
| 731 | |
| 732 | daddiu $t3, $a2, 20 # add 4 for method* and 16 for stack alignment |
| 733 | dsrl $t3, $t3, 4 # shift the frame size right 4 |
| 734 | dsll $t3, $t3, 4 # shift the frame size left 4 to align to 16 bytes |
| 735 | dsubu $sp, $sp, $t3 # reserve stack space for argument array |
| 736 | |
| 737 | daddiu $t0, $a5, 1 # t0 = shorty[1] (skip 1 for return type) |
| 738 | move $t1, $a1 # t1 = arg_array |
| 739 | move $t2, $a2 # t2 = number of argument bytes remain |
| 740 | daddiu $v0, $sp, 4 # v0 points to where to copy arg_array |
| 741 | LOOP_OVER_SHORTY_LOADING_REG a1, f13, call_sfn |
| 742 | LOOP_OVER_SHORTY_LOADING_REG a2, f14, call_sfn |
| 743 | LOOP_OVER_SHORTY_LOADING_REG a3, f15, call_sfn |
| 744 | LOOP_OVER_SHORTY_LOADING_REG a4, f16, call_sfn |
| 745 | LOOP_OVER_SHORTY_LOADING_REG a5, f17, call_sfn |
| 746 | LOOP_OVER_SHORTY_LOADING_REG a6, f18, call_sfn |
| 747 | LOOP_OVER_SHORTY_LOADING_REG a7, f19, call_sfn |
| 748 | |
| 749 | # copy arguments onto stack (t2 should be multiples of 4) |
| 750 | ble $t2, $zero, call_sfn # t2 = number of argument bytes remain |
| 751 | 1: |
| 752 | lw $t3, 0($t1) # load from argument array |
| 753 | daddiu $t1, $t1, 4 |
| 754 | sw $t3, 0($v0) # save to stack |
| 755 | daddiu $t2, -4 |
| 756 | bgt $t2, $zero, 1b # t2 = number of argument bytes remain |
| 757 | daddiu $v0, $v0, 4 |
| 758 | |
| 759 | call_sfn: |
| 760 | # call method (a0 has been untouched) |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 761 | sw $zero, 0($sp) # store null for method* at bottom of frame |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 762 | ld $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET_64($a0) # get pointer to the code |
| 763 | jalr $t9 # call the method |
| 764 | nop |
| 765 | move $sp, $s8 # restore sp |
| 766 | |
| 767 | # pop a4, a5, s0(rSUSPEND), s1(rSELF), s8, ra off of the stack |
| 768 | ld $a4, 0($sp) |
| 769 | .cfi_restore 8 |
| 770 | ld $a5, 8($sp) |
| 771 | .cfi_restore 9 |
| 772 | ld $s0, 16($sp) |
| 773 | .cfi_restore 16 |
| 774 | ld $s1, 24($sp) |
| 775 | .cfi_restore 17 |
| 776 | ld $s8, 32($sp) |
| 777 | .cfi_restore 30 |
| 778 | ld $ra, 40($sp) |
| 779 | .cfi_restore 31 |
| 780 | daddiu $sp, $sp, 48 |
| 781 | .cfi_adjust_cfa_offset -48 |
| 782 | |
| 783 | # a4 = JValue* result |
| 784 | # a5 = shorty string |
| 785 | lbu $t1, 0($a5) # get result type from shorty |
| 786 | li $t2, 68 # put char 'D' into t2 |
| 787 | beq $t1, $t2, 1f # branch if result type char == 'D' |
| 788 | li $t3, 70 # put char 'F' into t3 |
| 789 | beq $t1, $t3, 1f # branch if result type char == 'F' |
| 790 | sw $v0, 0($a4) # store the result |
| 791 | dsrl $v1, $v0, 32 |
| 792 | jalr $zero, $ra |
| 793 | sw $v1, 4($a4) # store the other half of the result |
| 794 | 1: |
| 795 | mfc1 $v0, $f0 |
| 796 | mfhc1 $v1, $f0 |
| 797 | sw $v0, 0($a4) # store the result |
| 798 | jalr $zero, $ra |
| 799 | sw $v1, 4($a4) # store the other half of the result |
| 800 | END art_quick_invoke_static_stub |
| 801 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 802 | /* |
| 803 | * Entry from managed code that calls artHandleFillArrayDataFromCode and |
| 804 | * delivers exception on failure. |
| 805 | */ |
| 806 | .extern artHandleFillArrayDataFromCode |
| 807 | ENTRY art_quick_handle_fill_data |
| 808 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC |
| 809 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 810 | jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*) |
| 811 | move $a3, rSELF # pass Thread::Current |
| 812 | RETURN_IF_ZERO |
| 813 | END art_quick_handle_fill_data |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 814 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 815 | /* |
| 816 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. |
| 817 | */ |
| 818 | .extern artLockObjectFromCode |
| 819 | ENTRY art_quick_lock_object |
| 820 | beq $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set |
| 821 | nop |
| 822 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block |
| 823 | jal artLockObjectFromCode # (Object* obj, Thread*) |
| 824 | move $a1, rSELF # pass Thread::Current |
| 825 | RETURN_IF_ZERO |
| 826 | END art_quick_lock_object |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 827 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 828 | /* |
| 829 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 830 | */ |
| 831 | .extern artUnlockObjectFromCode |
| 832 | ENTRY art_quick_unlock_object |
| 833 | beq $a0, $zero, .Lart_quick_throw_null_pointer_exception_gp_set |
| 834 | nop |
| 835 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC |
| 836 | jal artUnlockObjectFromCode # (Object* obj, Thread*) |
| 837 | move $a1, rSELF # pass Thread::Current |
| 838 | RETURN_IF_ZERO |
| 839 | END art_quick_unlock_object |
| 840 | |
| 841 | /* |
| 842 | * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. |
| 843 | */ |
| 844 | .extern artThrowClassCastException |
| 845 | ENTRY art_quick_check_cast |
| 846 | daddiu $sp, $sp, -32 |
| 847 | .cfi_adjust_cfa_offset 32 |
| 848 | sd $ra, 24($sp) |
| 849 | .cfi_rel_offset 31, 24 |
| 850 | sd $t9, 16($sp) |
| 851 | sd $a1, 8($sp) |
| 852 | sd $a0, 0($sp) |
| 853 | jal artIsAssignableFromCode |
| 854 | nop |
| 855 | beq $v0, $zero, .Lthrow_class_cast_exception |
| 856 | ld $ra, 24($sp) |
| 857 | jalr $zero, $ra |
| 858 | daddiu $sp, $sp, 32 |
| 859 | .cfi_adjust_cfa_offset -32 |
| 860 | .Lthrow_class_cast_exception: |
| 861 | ld $t9, 16($sp) |
| 862 | ld $a1, 8($sp) |
| 863 | ld $a0, 0($sp) |
| 864 | daddiu $sp, $sp, 32 |
| 865 | .cfi_adjust_cfa_offset -32 |
| 866 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 867 | dla $t9, artThrowClassCastException |
| 868 | jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*) |
| 869 | move $a2, rSELF # pass Thread::Current |
| 870 | END art_quick_check_cast |
| 871 | |
| 872 | /* |
| 873 | * Entry from managed code for array put operations of objects where the value being stored |
| 874 | * needs to be checked for compatibility. |
| 875 | * a0 = array, a1 = index, a2 = value |
| 876 | */ |
| 877 | ENTRY art_quick_aput_obj_with_null_and_bound_check |
| 878 | bne $a0, $zero, .Lart_quick_aput_obj_with_bound_check_gp_set |
| 879 | nop |
| 880 | b .Lart_quick_throw_null_pointer_exception_gp_set |
| 881 | nop |
| 882 | END art_quick_aput_obj_with_null_and_bound_check |
| 883 | |
| 884 | ENTRY art_quick_aput_obj_with_bound_check |
| 885 | lwu $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0) |
| 886 | sltu $t1, $a1, $t0 |
| 887 | bne $t1, $zero, .Lart_quick_aput_obj_gp_set |
| 888 | nop |
| 889 | move $a0, $a1 |
| 890 | b .Lart_quick_throw_array_bounds_gp_set |
| 891 | move $a1, $t0 |
| 892 | END art_quick_aput_obj_with_bound_check |
| 893 | |
| 894 | ENTRY art_quick_aput_obj |
| 895 | beq $a2, $zero, .Ldo_aput_null |
| 896 | nop |
| 897 | lwu $t0, MIRROR_OBJECT_CLASS_OFFSET($a0) |
| 898 | lwu $t1, MIRROR_OBJECT_CLASS_OFFSET($a2) |
| 899 | lwu $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0) |
| 900 | bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability |
| 901 | nop |
| 902 | .Ldo_aput: |
| 903 | dsll $a1, $a1, 2 |
| 904 | daddu $t0, $a0, $a1 |
| 905 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| 906 | ld $t0, THREAD_CARD_TABLE_OFFSET(rSELF) |
| 907 | dsrl $t1, $a0, 7 |
| 908 | daddu $t1, $t1, $t0 |
| 909 | sb $t0, ($t1) |
| 910 | jalr $zero, $ra |
| 911 | nop |
| 912 | .Ldo_aput_null: |
| 913 | dsll $a1, $a1, 2 |
| 914 | daddu $t0, $a0, $a1 |
| 915 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| 916 | jalr $zero, $ra |
| 917 | nop |
| 918 | .Lcheck_assignability: |
| 919 | daddiu $sp, $sp, -64 |
| 920 | .cfi_adjust_cfa_offset 64 |
| 921 | sd $ra, 56($sp) |
| 922 | .cfi_rel_offset 31, 56 |
| 923 | sd $t9, 24($sp) |
| 924 | sd $a2, 16($sp) |
| 925 | sd $a1, 8($sp) |
| 926 | sd $a0, 0($sp) |
| 927 | move $a1, $t1 |
| 928 | move $a0, $t0 |
| 929 | jal artIsAssignableFromCode # (Class*, Class*) |
| 930 | nop |
| 931 | ld $ra, 56($sp) |
| 932 | ld $t9, 24($sp) |
| 933 | ld $a2, 16($sp) |
| 934 | ld $a1, 8($sp) |
| 935 | ld $a0, 0($sp) |
| 936 | daddiu $sp, $sp, 64 |
| 937 | .cfi_adjust_cfa_offset -64 |
| 938 | bne $v0, $zero, .Ldo_aput |
| 939 | nop |
| 940 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 941 | move $a1, $a2 |
| 942 | dla $t9, artThrowArrayStoreException |
| 943 | jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*) |
| 944 | move $a2, rSELF # pass Thread::Current |
| 945 | END art_quick_aput_obj |
| 946 | |
| 947 | /* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 948 | * Called by managed code to resolve a static field and load a boolean primitive value. |
| 949 | */ |
| 950 | .extern artGetBooleanStaticFromCode |
| 951 | ENTRY art_quick_get_boolean_static |
| 952 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 953 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 954 | jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 955 | move $a2, rSELF # pass Thread::Current |
| 956 | RETURN_IF_NO_EXCEPTION |
| 957 | END art_quick_get_boolean_static |
| 958 | |
| 959 | /* |
| 960 | * Called by managed code to resolve a static field and load a byte primitive value. |
| 961 | */ |
| 962 | .extern artGetByteStaticFromCode |
| 963 | ENTRY art_quick_get_byte_static |
| 964 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 965 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 966 | jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 967 | move $a2, rSELF # pass Thread::Current |
| 968 | RETURN_IF_NO_EXCEPTION |
| 969 | END art_quick_get_byte_static |
| 970 | |
| 971 | /* |
| 972 | * Called by managed code to resolve a static field and load a char primitive value. |
| 973 | */ |
| 974 | .extern artGetCharStaticFromCode |
| 975 | ENTRY art_quick_get_char_static |
| 976 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 977 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 978 | jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 979 | move $a2, rSELF # pass Thread::Current |
| 980 | RETURN_IF_NO_EXCEPTION |
| 981 | END art_quick_get_char_static |
| 982 | |
| 983 | /* |
| 984 | * Called by managed code to resolve a static field and load a short primitive value. |
| 985 | */ |
| 986 | .extern artGetShortStaticFromCode |
| 987 | ENTRY art_quick_get_short_static |
| 988 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 989 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 990 | jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 991 | move $a2, rSELF # pass Thread::Current |
| 992 | RETURN_IF_NO_EXCEPTION |
| 993 | END art_quick_get_short_static |
| 994 | |
| 995 | /* |
| 996 | * Called by managed code to resolve a static field and load a 32-bit primitive value. |
| 997 | */ |
| 998 | .extern artGet32StaticFromCode |
| 999 | ENTRY art_quick_get32_static |
| 1000 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1001 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1002 | jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1003 | move $a2, rSELF # pass Thread::Current |
| 1004 | RETURN_IF_NO_EXCEPTION |
| 1005 | END art_quick_get32_static |
| 1006 | |
| 1007 | /* |
| 1008 | * Called by managed code to resolve a static field and load a 64-bit primitive value. |
| 1009 | */ |
| 1010 | .extern artGet64StaticFromCode |
| 1011 | ENTRY art_quick_get64_static |
| 1012 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1013 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1014 | jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1015 | move $a2, rSELF # pass Thread::Current |
| 1016 | RETURN_IF_NO_EXCEPTION |
| 1017 | END art_quick_get64_static |
| 1018 | |
| 1019 | /* |
| 1020 | * Called by managed code to resolve a static field and load an object reference. |
| 1021 | */ |
| 1022 | .extern artGetObjStaticFromCode |
| 1023 | ENTRY art_quick_get_obj_static |
| 1024 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1025 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1026 | jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*) |
| 1027 | move $a2, rSELF # pass Thread::Current |
| 1028 | RETURN_IF_NO_EXCEPTION |
| 1029 | END art_quick_get_obj_static |
| 1030 | |
| 1031 | /* |
| 1032 | * Called by managed code to resolve an instance field and load a boolean primitive value. |
| 1033 | */ |
| 1034 | .extern artGetBooleanInstanceFromCode |
| 1035 | ENTRY art_quick_get_boolean_instance |
| 1036 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1037 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1038 | jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1039 | move $a3, rSELF # pass Thread::Current |
| 1040 | RETURN_IF_NO_EXCEPTION |
| 1041 | END art_quick_get_boolean_instance |
| 1042 | |
| 1043 | /* |
| 1044 | * Called by managed code to resolve an instance field and load a byte primitive value. |
| 1045 | */ |
| 1046 | .extern artGetByteInstanceFromCode |
| 1047 | ENTRY art_quick_get_byte_instance |
| 1048 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1049 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1050 | jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1051 | move $a3, rSELF # pass Thread::Current |
| 1052 | RETURN_IF_NO_EXCEPTION |
| 1053 | END art_quick_get_byte_instance |
| 1054 | |
| 1055 | /* |
| 1056 | * Called by managed code to resolve an instance field and load a char primitive value. |
| 1057 | */ |
| 1058 | .extern artGetCharInstanceFromCode |
| 1059 | ENTRY art_quick_get_char_instance |
| 1060 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1061 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1062 | jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1063 | move $a3, rSELF # pass Thread::Current |
| 1064 | RETURN_IF_NO_EXCEPTION |
| 1065 | END art_quick_get_char_instance |
| 1066 | |
| 1067 | /* |
| 1068 | * Called by managed code to resolve an instance field and load a short primitive value. |
| 1069 | */ |
| 1070 | .extern artGetShortInstanceFromCode |
| 1071 | ENTRY art_quick_get_short_instance |
| 1072 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1073 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1074 | jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1075 | move $a3, rSELF # pass Thread::Current |
| 1076 | RETURN_IF_NO_EXCEPTION |
| 1077 | END art_quick_get_short_instance |
| 1078 | |
| 1079 | /* |
| 1080 | * Called by managed code to resolve an instance field and load a 32-bit primitive value. |
| 1081 | */ |
| 1082 | .extern artGet32InstanceFromCode |
| 1083 | ENTRY art_quick_get32_instance |
| 1084 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1085 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1086 | jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1087 | move $a3, rSELF # pass Thread::Current |
| 1088 | RETURN_IF_NO_EXCEPTION |
| 1089 | END art_quick_get32_instance |
| 1090 | |
| 1091 | /* |
| 1092 | * Called by managed code to resolve an instance field and load a 64-bit primitive value. |
| 1093 | */ |
| 1094 | .extern artGet64InstanceFromCode |
| 1095 | ENTRY art_quick_get64_instance |
| 1096 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1097 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1098 | jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1099 | move $a3, rSELF # pass Thread::Current |
| 1100 | RETURN_IF_NO_EXCEPTION |
| 1101 | END art_quick_get64_instance |
| 1102 | |
| 1103 | /* |
| 1104 | * Called by managed code to resolve an instance field and load an object reference. |
| 1105 | */ |
| 1106 | .extern artGetObjInstanceFromCode |
| 1107 | ENTRY art_quick_get_obj_instance |
| 1108 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1109 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1110 | jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*) |
| 1111 | move $a3, rSELF # pass Thread::Current |
| 1112 | RETURN_IF_NO_EXCEPTION |
| 1113 | END art_quick_get_obj_instance |
| 1114 | |
| 1115 | /* |
| 1116 | * Called by managed code to resolve a static field and store a 8-bit primitive value. |
| 1117 | */ |
| 1118 | .extern artSet8StaticFromCode |
| 1119 | ENTRY art_quick_set8_static |
| 1120 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1121 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1122 | jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1123 | move $a3, rSELF # pass Thread::Current |
| 1124 | RETURN_IF_ZERO |
| 1125 | END art_quick_set8_static |
| 1126 | |
| 1127 | /* |
| 1128 | * Called by managed code to resolve a static field and store a 16-bit primitive value. |
| 1129 | */ |
| 1130 | .extern artSet16StaticFromCode |
| 1131 | ENTRY art_quick_set16_static |
| 1132 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1133 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1134 | jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1135 | move $a3, rSELF # pass Thread::Current |
| 1136 | RETURN_IF_ZERO |
| 1137 | END art_quick_set16_static |
| 1138 | |
| 1139 | /* |
| 1140 | * Called by managed code to resolve a static field and store a 32-bit primitive value. |
| 1141 | */ |
| 1142 | .extern artSet32StaticFromCode |
| 1143 | ENTRY art_quick_set32_static |
| 1144 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1145 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1146 | jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1147 | move $a3, rSELF # pass Thread::Current |
| 1148 | RETURN_IF_ZERO |
| 1149 | END art_quick_set32_static |
| 1150 | |
| 1151 | /* |
| 1152 | * Called by managed code to resolve a static field and store a 64-bit primitive value. |
| 1153 | */ |
| 1154 | .extern artSet64StaticFromCode |
| 1155 | ENTRY art_quick_set64_static |
| 1156 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1157 | move $a2, $a1 # pass new_val |
| 1158 | lwu $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1159 | jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*) |
| 1160 | move $a3, rSELF # pass Thread::Current |
| 1161 | RETURN_IF_ZERO |
| 1162 | END art_quick_set64_static |
| 1163 | |
| 1164 | /* |
| 1165 | * Called by managed code to resolve a static field and store an object reference. |
| 1166 | */ |
| 1167 | .extern artSetObjStaticFromCode |
| 1168 | ENTRY art_quick_set_obj_static |
| 1169 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1170 | lwu $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1171 | jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*) |
| 1172 | move $a3, rSELF # pass Thread::Current |
| 1173 | RETURN_IF_ZERO |
| 1174 | END art_quick_set_obj_static |
| 1175 | |
| 1176 | /* |
| 1177 | * Called by managed code to resolve an instance field and store a 8-bit primitive value. |
| 1178 | */ |
| 1179 | .extern artSet8InstanceFromCode |
| 1180 | ENTRY art_quick_set8_instance |
| 1181 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1182 | lwu $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1183 | jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1184 | move $a4, rSELF # pass Thread::Current |
| 1185 | RETURN_IF_ZERO |
| 1186 | END art_quick_set8_instance |
| 1187 | |
| 1188 | /* |
| 1189 | * Called by managed code to resolve an instance field and store a 16-bit primitive value. |
| 1190 | */ |
| 1191 | .extern artSet16InstanceFromCode |
| 1192 | ENTRY art_quick_set16_instance |
| 1193 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1194 | lwu $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1195 | jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1196 | move $a4, rSELF # pass Thread::Current |
| 1197 | RETURN_IF_ZERO |
| 1198 | END art_quick_set16_instance |
| 1199 | |
| 1200 | /* |
| 1201 | * Called by managed code to resolve an instance field and store a 32-bit primitive value. |
| 1202 | */ |
| 1203 | .extern artSet32InstanceFromCode |
| 1204 | ENTRY art_quick_set32_instance |
| 1205 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1206 | lwu $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1207 | jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1208 | move $a4, rSELF # pass Thread::Current |
| 1209 | RETURN_IF_ZERO |
| 1210 | END art_quick_set32_instance |
| 1211 | |
| 1212 | /* |
| 1213 | * Called by managed code to resolve an instance field and store a 64-bit primitive value. |
| 1214 | */ |
| 1215 | .extern artSet64InstanceFromCode |
| 1216 | ENTRY art_quick_set64_instance |
| 1217 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1218 | lwu $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1219 | jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1220 | move $a4, rSELF # pass Thread::Current |
| 1221 | RETURN_IF_ZERO |
| 1222 | END art_quick_set64_instance |
| 1223 | |
| 1224 | /* |
| 1225 | * Called by managed code to resolve an instance field and store an object reference. |
| 1226 | */ |
| 1227 | .extern artSetObjInstanceFromCode |
| 1228 | ENTRY art_quick_set_obj_instance |
| 1229 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1230 | lwu $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method* |
| 1231 | jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*) |
| 1232 | move $a4, rSELF # pass Thread::Current |
| 1233 | RETURN_IF_ZERO |
| 1234 | END art_quick_set_obj_instance |
| 1235 | |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1236 | // Macro to facilitate adding new allocation entrypoints. |
| 1237 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1238 | .extern \entrypoint |
| 1239 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1240 | 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] | 1241 | jal \entrypoint |
| 1242 | move $a1, rSELF # pass Thread::Current |
| 1243 | \return |
| 1244 | END \name |
| 1245 | .endm |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1246 | |
| 1247 | // Macro to facilitate adding new allocation entrypoints. |
| 1248 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1249 | .extern \entrypoint |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1250 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1251 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1252 | jal \entrypoint |
| 1253 | move $a2, rSELF # pass Thread::Current |
| 1254 | \return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1255 | END \name |
| 1256 | .endm |
| 1257 | |
| 1258 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1259 | .extern \entrypoint |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1260 | ENTRY \name |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1261 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1262 | jal \entrypoint |
| 1263 | move $a3, rSELF # pass Thread::Current |
| 1264 | \return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1265 | END \name |
| 1266 | .endm |
| 1267 | |
Vladimir Marko | e85e123 | 2015-04-28 14:14:58 +0100 | [diff] [blame] | 1268 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1269 | .extern \entrypoint |
| 1270 | ENTRY \name |
| 1271 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC |
| 1272 | jal \entrypoint |
| 1273 | move $a4, rSELF # pass Thread::Current |
| 1274 | \return |
| 1275 | END \name |
| 1276 | .endm |
| 1277 | |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1278 | // Generate the allocation entrypoints for each allocator. |
| 1279 | GENERATE_ALL_ALLOC_ENTRYPOINTS |
| 1280 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1281 | /* |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1282 | * Entry from managed code to resolve a string, this stub will allocate a String and deliver an |
| 1283 | * exception on error. On success the String is returned. A0 holds the string index. The fast |
| 1284 | * path check for hit in strings cache has already been performed. |
| 1285 | */ |
| 1286 | ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1287 | |
| 1288 | /* |
| 1289 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 1290 | * initializer and deliver the exception on error. On success the static storage base is |
| 1291 | * returned. |
| 1292 | */ |
| 1293 | ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1294 | |
| 1295 | /* |
| 1296 | * Entry from managed code when dex cache misses for a type_idx. |
| 1297 | */ |
| 1298 | ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1299 | |
| 1300 | /* |
| 1301 | * Entry from managed code when type_idx needs to be checked for access and dex cache may also |
| 1302 | * miss. |
| 1303 | */ |
| 1304 | ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1305 | |
| 1306 | /* |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1307 | * Called by managed code when the value in rSUSPEND has been decremented to 0. |
| 1308 | */ |
| 1309 | .extern artTestSuspendFromCode |
| 1310 | ENTRY art_quick_test_suspend |
| 1311 | lh $a0, THREAD_FLAGS_OFFSET(rSELF) |
| 1312 | bne $a0, $zero, 1f |
| 1313 | daddiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
| 1314 | jalr $zero, $ra |
| 1315 | nop |
| 1316 | 1: |
| 1317 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl |
| 1318 | jal artTestSuspendFromCode # (Thread*) |
| 1319 | move $a0, rSELF |
| 1320 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 1321 | END art_quick_test_suspend |
Douglas Leung | 6461d19 | 2015-01-30 18:13:58 -0800 | [diff] [blame] | 1322 | |
| 1323 | /* |
| 1324 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
| 1325 | * r0 holds the proxy method; r1, r2 and r3 may contain arguments. |
| 1326 | */ |
| 1327 | .extern artQuickProxyInvokeHandler |
| 1328 | ENTRY art_quick_proxy_invoke_handler |
| 1329 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1330 | sd $a0, 0($sp) # place proxy method at bottom of frame |
| 1331 | move $a2, rSELF # pass Thread::Current |
| 1332 | jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP) |
| 1333 | move $a3, $sp # pass $sp |
| 1334 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 1335 | daddiu $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE # skip a0-a7 and f12-f19 |
| 1336 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1337 | bne $t0, $zero, 1f |
| 1338 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1339 | jalr $zero, $ra |
| 1340 | dmtc1 $v1, $f1 # place return value to FP return value |
| 1341 | 1: |
| 1342 | DELIVER_PENDING_EXCEPTION |
| 1343 | END art_quick_proxy_invoke_handler |
| 1344 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1345 | /* |
| 1346 | * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's |
| 1347 | * dex method index. |
| 1348 | */ |
| 1349 | ENTRY art_quick_imt_conflict_trampoline |
| 1350 | lwu $a0, 0($sp) # load caller Method* |
| 1351 | lwu $a0, MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods |
| 1352 | dsll $t0, 2 # convert target method offset to bytes |
| 1353 | daddu $a0, $t0 # get address of target method |
| 1354 | dla $t9, art_quick_invoke_interface_trampoline |
| 1355 | jalr $zero, $t9 |
| 1356 | lwu $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method |
| 1357 | END art_quick_imt_conflict_trampoline |
Andreas Gampe | cc7c39d | 2015-01-30 17:04:45 -0800 | [diff] [blame] | 1358 | |
| 1359 | .extern artQuickResolutionTrampoline |
| 1360 | ENTRY art_quick_resolution_trampoline |
| 1361 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1362 | move $a2, rSELF # pass Thread::Current |
| 1363 | jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP) |
| 1364 | move $a3, $sp # pass $sp |
| 1365 | beq $v0, $zero, 1f |
| 1366 | lwu $a0, 0($sp) # load resolved method in $a0 |
| 1367 | # artQuickResolutionTrampoline puts resolved method in *SP |
| 1368 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1369 | move $t9, $v0 # code pointer must be in $t9 to generate the global pointer |
| 1370 | jalr $zero, $t9 # tail call to method |
| 1371 | nop |
| 1372 | 1: |
| 1373 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1374 | DELIVER_PENDING_EXCEPTION |
| 1375 | END art_quick_resolution_trampoline |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1376 | |
| 1377 | .extern artQuickGenericJniTrampoline |
| 1378 | .extern artQuickGenericJniEndTrampoline |
| 1379 | ENTRY art_quick_generic_jni_trampoline |
| 1380 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 1381 | sd $a0, 0($sp) # store native ArtMethod* to bottom of stack |
| 1382 | move $s8, $sp # save $sp |
| 1383 | |
| 1384 | # prepare for call to artQuickGenericJniTrampoline(Thread*, SP) |
| 1385 | move $a0, rSELF # pass Thread::Current |
| 1386 | move $a1, $sp # pass $sp |
| 1387 | jal artQuickGenericJniTrampoline # (Thread*, SP) |
| 1388 | daddiu $sp, $sp, -5120 # reserve space on the stack |
| 1389 | |
| 1390 | # The C call will have registered the complete save-frame on success. |
| 1391 | # The result of the call is: |
| 1392 | # v0: ptr to native code, 0 on error. |
| 1393 | # v1: ptr to the bottom of the used area of the alloca, can restore stack till here. |
| 1394 | beq $v0, $zero, 1f # check entry error |
| 1395 | move $t9, $v0 # save the code ptr |
| 1396 | move $sp, $v1 # release part of the alloca |
| 1397 | |
| 1398 | # Load parameters from stack into registers |
| 1399 | ld $a0, 0($sp) |
| 1400 | ld $a1, 8($sp) |
| 1401 | ld $a2, 16($sp) |
| 1402 | ld $a3, 24($sp) |
| 1403 | ld $a4, 32($sp) |
| 1404 | ld $a5, 40($sp) |
| 1405 | ld $a6, 48($sp) |
| 1406 | ld $a7, 56($sp) |
| 1407 | # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine. |
| 1408 | l.d $f12, 0($sp) |
| 1409 | l.d $f13, 8($sp) |
| 1410 | l.d $f14, 16($sp) |
| 1411 | l.d $f15, 24($sp) |
| 1412 | l.d $f16, 32($sp) |
| 1413 | l.d $f17, 40($sp) |
| 1414 | l.d $f18, 48($sp) |
| 1415 | l.d $f19, 56($sp) |
| 1416 | jalr $t9 # native call |
| 1417 | daddiu $sp, $sp, 64 |
| 1418 | |
| 1419 | # result sign extension is handled in C code |
| 1420 | # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f) |
| 1421 | move $a0, rSELF # pass Thread::Current |
| 1422 | move $a1, $v0 |
| 1423 | jal artQuickGenericJniEndTrampoline |
| 1424 | dmfc1 $a2, $f0 |
| 1425 | |
| 1426 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1427 | bne $t0, $zero, 1f # check for pending exceptions |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1428 | move $sp, $s8 # tear down the alloca |
| 1429 | |
| 1430 | # tear dpown the callee-save frame |
| 1431 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1432 | |
| 1433 | jalr $zero, $ra |
| 1434 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1435 | |
| 1436 | 1: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1437 | ld $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) |
| 1438 | # This will create a new save-all frame, required by the runtime. |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1439 | DELIVER_PENDING_EXCEPTION |
| 1440 | END art_quick_generic_jni_trampoline |
| 1441 | |
| 1442 | .extern artQuickToInterpreterBridge |
| 1443 | ENTRY art_quick_to_interpreter_bridge |
| 1444 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1445 | move $a1, rSELF # pass Thread::Current |
| 1446 | jal artQuickToInterpreterBridge # (Method* method, Thread*, SP) |
| 1447 | move $a2, $sp # pass $sp |
| 1448 | ld $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| 1449 | daddiu $sp, $sp, REFS_AND_ARGS_MINUS_REFS_SIZE # skip a0-a7 and f12-f19 |
| 1450 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1451 | bne $t0, $zero, 1f |
| 1452 | dmtc1 $v0, $f0 # place return value to FP return value |
| 1453 | jalr $zero, $ra |
| 1454 | dmtc1 $v1, $f1 # place return value to FP return value |
| 1455 | 1: |
| 1456 | DELIVER_PENDING_EXCEPTION |
| 1457 | END art_quick_to_interpreter_bridge |
| 1458 | |
| 1459 | /* |
| 1460 | * Routine that intercepts method calls and returns. |
| 1461 | */ |
| 1462 | .extern artInstrumentationMethodEntryFromCode |
| 1463 | .extern artInstrumentationMethodExitFromCode |
| 1464 | ENTRY art_quick_instrumentation_entry |
| 1465 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1466 | daddiu $sp, $sp, -16 # space for saving arg0 |
| 1467 | .cfi_adjust_cfa_offset 16 |
| 1468 | sd $a0, 0($sp) # save arg0 |
| 1469 | move $a3, $ra # pass $ra |
| 1470 | jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, RA) |
| 1471 | move $a2, rSELF # pass Thread::Current |
| 1472 | move $t9, $v0 # $t9 holds reference to code |
| 1473 | ld $a0, 0($sp) # restore arg0 |
| 1474 | daddiu $sp, $sp, 16 # remove args |
| 1475 | .cfi_adjust_cfa_offset -16 |
| 1476 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
| 1477 | jalr $t9 # call method |
| 1478 | nop |
| 1479 | END art_quick_instrumentation_entry |
| 1480 | /* intentional fallthrough */ |
| 1481 | .global art_quick_instrumentation_exit |
| 1482 | art_quick_instrumentation_exit: |
| 1483 | .cfi_startproc |
| 1484 | daddiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp |
| 1485 | .cpload $t9 |
| 1486 | move $ra, $zero # link register is to here, so clobber with 0 for later checks |
| 1487 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1488 | move $t0, $sp # remember bottom of caller's frame |
| 1489 | daddiu $sp, $sp, -16 # save return values and set up args |
| 1490 | .cfi_adjust_cfa_offset 16 |
| 1491 | sd $v0, 0($sp) |
| 1492 | .cfi_rel_offset 2, 0 |
| 1493 | s.d $f0, 8($sp) |
| 1494 | mov.d $f15, $f0 # pass fpr result |
| 1495 | move $a2, $v0 # pass gpr result |
| 1496 | move $a1, $t0 # pass $sp |
| 1497 | jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res) |
| 1498 | move $a0, rSELF # pass Thread::Current |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 1499 | move $t9, $v0 # set aside returned link register |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1500 | move $ra, $v1 # set link register for deoptimization |
| 1501 | ld $v0, 0($sp) # restore return values |
| 1502 | l.d $f0, 8($sp) |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 1503 | jalr $zero, $t9 # return |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1504 | daddiu $sp, $sp, 16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE # 16 bytes of saved values + ref_only callee save frame |
| 1505 | .cfi_adjust_cfa_offset -(16+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE) |
| 1506 | END art_quick_instrumentation_exit |
| 1507 | |
Maja Gagic | 6ea651f | 2015-02-24 16:55:04 +0100 | [diff] [blame] | 1508 | /* |
| 1509 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 1510 | * will long jump to the upcall with a special exception of -1. |
| 1511 | */ |
| 1512 | .extern artDeoptimize |
| 1513 | .extern artEnterInterpreterFromDeoptimize |
| 1514 | ENTRY art_quick_deoptimize |
| 1515 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1516 | jal artDeoptimize # artDeoptimize(Thread*, SP) |
| 1517 | # Returns caller method's frame size. |
| 1518 | move $a0, rSELF # pass Thread::current |
| 1519 | END art_quick_deoptimize |
| 1520 | |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 1521 | UNIMPLEMENTED art_quick_indexof |
| 1522 | UNIMPLEMENTED art_quick_string_compareto |