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