| Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 17 | #include "asm_support_mips.S" |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 18 | |
| Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 19 | #include "arch/quick_alloc_entrypoints.S" |
| 20 | |
| jeffhao | 0703060 | 2012-09-26 14:33:14 -0700 | [diff] [blame] | 21 | .set noreorder |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 22 | .balign 4 |
| 23 | |
| 24 | /* Deliver the given exception */ |
| 25 | .extern artDeliverExceptionFromCode |
| 26 | /* Deliver an exception pending on a thread */ |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 27 | .extern artDeliverPendingExceptionFromCode |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 28 | |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 29 | #define ARG_SLOT_SIZE 32 // space for a0-a3 plus 4 more words |
| 30 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 31 | /* |
| 32 | * Macro that sets up the callee save frame to conform with |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 33 | * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 34 | * Callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word for Method* |
| 35 | * Clobbers $t0 and $sp |
| 36 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 37 | * Reserves FRAME_SIZE_SAVE_ALL_CALLEE_SAVES + ARG_SLOT_SIZE bytes on the stack |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 38 | */ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 39 | .macro SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 40 | addiu $sp, $sp, -112 |
| 41 | .cfi_adjust_cfa_offset 112 |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 42 | |
| 43 | // Ugly compile-time check, but we only have the preprocessor. |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 44 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 112) |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 45 | #error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(MIPS) size not as expected." |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 46 | #endif |
| 47 | |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 48 | sw $ra, 108($sp) |
| 49 | .cfi_rel_offset 31, 108 |
| 50 | sw $s8, 104($sp) |
| 51 | .cfi_rel_offset 30, 104 |
| 52 | sw $gp, 100($sp) |
| 53 | .cfi_rel_offset 28, 100 |
| 54 | sw $s7, 96($sp) |
| 55 | .cfi_rel_offset 23, 96 |
| 56 | sw $s6, 92($sp) |
| 57 | .cfi_rel_offset 22, 92 |
| 58 | sw $s5, 88($sp) |
| 59 | .cfi_rel_offset 21, 88 |
| 60 | sw $s4, 84($sp) |
| 61 | .cfi_rel_offset 20, 84 |
| 62 | sw $s3, 80($sp) |
| 63 | .cfi_rel_offset 19, 80 |
| 64 | sw $s2, 76($sp) |
| 65 | .cfi_rel_offset 18, 76 |
| 66 | sw $s1, 72($sp) |
| 67 | .cfi_rel_offset 17, 72 |
| 68 | sw $s0, 68($sp) |
| 69 | .cfi_rel_offset 16, 68 |
| 70 | // 4-byte placeholder for register $zero, serving for alignment |
| 71 | // of the following double precision floating point registers. |
| Andreas Gampe | a4e0e67 | 2015-05-27 18:31:42 -0700 | [diff] [blame] | 72 | |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 73 | CHECK_ALIGNMENT $sp, $t1 |
| 74 | sdc1 $f30, 56($sp) |
| 75 | sdc1 $f28, 48($sp) |
| 76 | sdc1 $f26, 40($sp) |
| 77 | sdc1 $f24, 32($sp) |
| 78 | sdc1 $f22, 24($sp) |
| 79 | sdc1 $f20, 16($sp) |
| Andreas Gampe | a4e0e67 | 2015-05-27 18:31:42 -0700 | [diff] [blame] | 80 | |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 81 | # 1 word for holding Method* plus 12 bytes padding to keep contents of SP |
| 82 | # a multiple of 16. |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 83 | |
| Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 84 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 85 | lw $t0, 0($t0) |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 86 | lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET($t0) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 87 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 88 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 89 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 90 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 91 | .endm |
| 92 | |
| 93 | /* |
| 94 | * Macro that sets up the callee save frame to conform with |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 95 | * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly). Restoration assumes non-moving GC. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 96 | * Does not include rSUSPEND or rSELF |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 97 | * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method* |
| 98 | * Clobbers $t0 and $sp |
| 99 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 100 | * Reserves FRAME_SIZE_SAVE_REFS_ONLY + ARG_SLOT_SIZE bytes on the stack |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 101 | */ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 102 | .macro SETUP_SAVE_REFS_ONLY_FRAME |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 103 | addiu $sp, $sp, -48 |
| 104 | .cfi_adjust_cfa_offset 48 |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 105 | |
| 106 | // Ugly compile-time check, but we only have the preprocessor. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 107 | #if (FRAME_SIZE_SAVE_REFS_ONLY != 48) |
| 108 | #error "FRAME_SIZE_SAVE_REFS_ONLY(MIPS) size not as expected." |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 109 | #endif |
| 110 | |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 111 | sw $ra, 44($sp) |
| 112 | .cfi_rel_offset 31, 44 |
| 113 | sw $s8, 40($sp) |
| 114 | .cfi_rel_offset 30, 40 |
| 115 | sw $gp, 36($sp) |
| 116 | .cfi_rel_offset 28, 36 |
| 117 | sw $s7, 32($sp) |
| 118 | .cfi_rel_offset 23, 32 |
| 119 | sw $s6, 28($sp) |
| 120 | .cfi_rel_offset 22, 28 |
| 121 | sw $s5, 24($sp) |
| 122 | .cfi_rel_offset 21, 24 |
| 123 | sw $s4, 20($sp) |
| 124 | .cfi_rel_offset 20, 20 |
| 125 | sw $s3, 16($sp) |
| 126 | .cfi_rel_offset 19, 16 |
| 127 | sw $s2, 12($sp) |
| 128 | .cfi_rel_offset 18, 12 |
| 129 | # 2 words for alignment and bottom word will hold Method* |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 130 | |
| Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 131 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 132 | lw $t0, 0($t0) |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 133 | lw $t0, RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET($t0) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 134 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 135 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 136 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 137 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 138 | .endm |
| 139 | |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 140 | .macro RESTORE_SAVE_REFS_ONLY_FRAME |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 141 | addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack |
| 142 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 143 | lw $ra, 44($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 144 | .cfi_restore 31 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 145 | lw $s8, 40($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 146 | .cfi_restore 30 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 147 | lw $gp, 36($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 148 | .cfi_restore 28 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 149 | lw $s7, 32($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 150 | .cfi_restore 23 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 151 | lw $s6, 28($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 152 | .cfi_restore 22 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 153 | lw $s5, 24($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 154 | .cfi_restore 21 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 155 | lw $s4, 20($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 156 | .cfi_restore 20 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 157 | lw $s3, 16($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 158 | .cfi_restore 19 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 159 | lw $s2, 12($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 160 | .cfi_restore 18 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 161 | addiu $sp, $sp, 48 |
| 162 | .cfi_adjust_cfa_offset -48 |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 163 | .endm |
| 164 | |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 165 | .macro RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN |
| 166 | RESTORE_SAVE_REFS_ONLY_FRAME |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 167 | jalr $zero, $ra |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 168 | nop |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 169 | .endm |
| 170 | |
| 171 | /* |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 172 | * Individually usable part of macro SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY. |
| 173 | */ |
| 174 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_S4_THRU_S8 |
| 175 | sw $s8, 104($sp) |
| 176 | .cfi_rel_offset 30, 104 |
| 177 | sw $s7, 96($sp) |
| 178 | .cfi_rel_offset 23, 96 |
| 179 | sw $s6, 92($sp) |
| 180 | .cfi_rel_offset 22, 92 |
| 181 | sw $s5, 88($sp) |
| 182 | .cfi_rel_offset 21, 88 |
| 183 | sw $s4, 84($sp) |
| 184 | .cfi_rel_offset 20, 84 |
| 185 | .endm |
| 186 | |
| 187 | /* |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 188 | * Macro that sets up the callee save frame to conform with |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 189 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 190 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 191 | * (26 total + 1 word padding + method*) |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 192 | */ |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 193 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY save_s4_thru_s8=1 |
| 194 | addiu $sp, $sp, -112 |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 195 | .cfi_adjust_cfa_offset 112 |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 196 | |
| 197 | // Ugly compile-time check, but we only have the preprocessor. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 198 | #if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 112) |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 199 | #error "FRAME_SIZE_SAVE_REFS_AND_ARGS(MIPS) size not as expected." |
| Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 200 | #endif |
| 201 | |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 202 | sw $ra, 108($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 203 | .cfi_rel_offset 31, 108 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 204 | sw $gp, 100($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 205 | .cfi_rel_offset 28, 100 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 206 | .if \save_s4_thru_s8 |
| 207 | SETUP_SAVE_REFS_AND_ARGS_FRAME_S4_THRU_S8 |
| 208 | .endif |
| 209 | sw $s3, 80($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 210 | .cfi_rel_offset 19, 80 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 211 | sw $s2, 76($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 212 | .cfi_rel_offset 18, 76 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 213 | sw $t1, 72($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 214 | .cfi_rel_offset 9, 72 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 215 | sw $t0, 68($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 216 | .cfi_rel_offset 8, 68 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 217 | sw $a3, 64($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 218 | .cfi_rel_offset 7, 64 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 219 | sw $a2, 60($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 220 | .cfi_rel_offset 6, 60 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 221 | sw $a1, 56($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 222 | .cfi_rel_offset 5, 56 |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 223 | CHECK_ALIGNMENT $sp, $t8 |
| 224 | sdc1 $f18, 48($sp) |
| 225 | sdc1 $f16, 40($sp) |
| 226 | sdc1 $f14, 32($sp) |
| 227 | sdc1 $f12, 24($sp) |
| 228 | sdc1 $f10, 16($sp) |
| 229 | sdc1 $f8, 8($sp) |
| jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 230 | # bottom will hold Method* |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 231 | .endm |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 232 | |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 233 | /* |
| 234 | * Macro that sets up the callee save frame to conform with |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 235 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 236 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 237 | * (26 total + 1 word padding + method*) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 238 | * Clobbers $t0 and $sp |
| 239 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 240 | * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 241 | */ |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 242 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME save_s4_thru_s8_only=0 |
| 243 | .if \save_s4_thru_s8_only |
| 244 | // It is expected that `SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY /* save_s4_thru_s8 */ 0` |
| 245 | // has been done prior to `SETUP_SAVE_REFS_AND_ARGS_FRAME /* save_s4_thru_s8_only */ 1`. |
| 246 | SETUP_SAVE_REFS_AND_ARGS_FRAME_S4_THRU_S8 |
| 247 | .else |
| 248 | SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY |
| 249 | .endif |
| Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 250 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 251 | lw $t0, 0($t0) |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 252 | lw $t0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET($t0) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 253 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 254 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 255 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 256 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| 257 | .endm |
| 258 | |
| 259 | /* |
| 260 | * Macro that sets up the callee save frame to conform with |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 261 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 262 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 263 | * (26 total + 1 word padding + method*) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 264 | * Clobbers $sp |
| 265 | * Use $a0 as the Method* and loads it into bottom of stack. |
| 266 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 267 | * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 268 | */ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 269 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
| 270 | SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 271 | sw $a0, 0($sp) # Place Method* at bottom of stack. |
| 272 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 273 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 274 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 275 | .endm |
| 276 | |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 277 | /* |
| 278 | * Individually usable part of macro RESTORE_SAVE_REFS_AND_ARGS_FRAME. |
| 279 | */ |
| 280 | .macro RESTORE_SAVE_REFS_AND_ARGS_FRAME_GP |
| 281 | lw $gp, 100($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 282 | .cfi_restore 28 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 283 | .endm |
| 284 | |
| 285 | /* |
| 286 | * Individually usable part of macro RESTORE_SAVE_REFS_AND_ARGS_FRAME. |
| 287 | */ |
| 288 | .macro RESTORE_SAVE_REFS_AND_ARGS_FRAME_A1 |
| 289 | lw $a1, 56($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 290 | .cfi_restore 5 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 291 | .endm |
| 292 | |
| 293 | .macro RESTORE_SAVE_REFS_AND_ARGS_FRAME restore_s4_thru_s8=1, remove_arg_slots=1 |
| 294 | .if \remove_arg_slots |
| 295 | addiu $sp, $sp, ARG_SLOT_SIZE # Remove argument slots from the stack. |
| 296 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 297 | .endif |
| 298 | lw $ra, 108($sp) |
| 299 | .cfi_restore 31 |
| 300 | .if \restore_s4_thru_s8 |
| 301 | lw $s8, 104($sp) |
| 302 | .cfi_restore 30 |
| 303 | .endif |
| 304 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_GP |
| 305 | .if \restore_s4_thru_s8 |
| 306 | lw $s7, 96($sp) |
| 307 | .cfi_restore 23 |
| 308 | lw $s6, 92($sp) |
| 309 | .cfi_restore 22 |
| 310 | lw $s5, 88($sp) |
| 311 | .cfi_restore 21 |
| 312 | lw $s4, 84($sp) |
| 313 | .cfi_restore 20 |
| 314 | .endif |
| 315 | lw $s3, 80($sp) |
| 316 | .cfi_restore 19 |
| 317 | lw $s2, 76($sp) |
| 318 | .cfi_restore 18 |
| 319 | lw $t1, 72($sp) |
| 320 | .cfi_restore 9 |
| 321 | lw $t0, 68($sp) |
| 322 | .cfi_restore 8 |
| 323 | lw $a3, 64($sp) |
| 324 | .cfi_restore 7 |
| 325 | lw $a2, 60($sp) |
| 326 | .cfi_restore 6 |
| 327 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_A1 |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 328 | CHECK_ALIGNMENT $sp, $t8 |
| 329 | ldc1 $f18, 48($sp) |
| 330 | ldc1 $f16, 40($sp) |
| 331 | ldc1 $f14, 32($sp) |
| 332 | ldc1 $f12, 24($sp) |
| 333 | ldc1 $f10, 16($sp) |
| 334 | ldc1 $f8, 8($sp) |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 335 | addiu $sp, $sp, 112 # Pop frame. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 336 | .cfi_adjust_cfa_offset -112 |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 337 | .endm |
| 338 | |
| 339 | /* |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 340 | * Macro that sets up the callee save frame to conform with |
| 341 | * Runtime::CreateCalleeSaveMethod(kSaveEverything). |
| Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 342 | * when the $sp has already been decremented by FRAME_SIZE_SAVE_EVERYTHING. |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 343 | * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31; |
| 344 | * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method* |
| 345 | * Clobbers $t0 and $t1. |
| 346 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 347 | * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack. |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 348 | * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP. |
| 349 | */ |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 350 | .macro SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 351 | // Ugly compile-time check, but we only have the preprocessor. |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 352 | #if (FRAME_SIZE_SAVE_EVERYTHING != 256) |
| 353 | #error "FRAME_SIZE_SAVE_EVERYTHING(MIPS) size not as expected." |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 354 | #endif |
| 355 | |
| 356 | sw $ra, 252($sp) |
| 357 | .cfi_rel_offset 31, 252 |
| 358 | sw $fp, 248($sp) |
| 359 | .cfi_rel_offset 30, 248 |
| 360 | sw $gp, 244($sp) |
| 361 | .cfi_rel_offset 28, 244 |
| 362 | sw $t9, 240($sp) |
| 363 | .cfi_rel_offset 25, 240 |
| 364 | sw $t8, 236($sp) |
| 365 | .cfi_rel_offset 24, 236 |
| 366 | sw $s7, 232($sp) |
| 367 | .cfi_rel_offset 23, 232 |
| 368 | sw $s6, 228($sp) |
| 369 | .cfi_rel_offset 22, 228 |
| 370 | sw $s5, 224($sp) |
| 371 | .cfi_rel_offset 21, 224 |
| 372 | sw $s4, 220($sp) |
| 373 | .cfi_rel_offset 20, 220 |
| 374 | sw $s3, 216($sp) |
| 375 | .cfi_rel_offset 19, 216 |
| 376 | sw $s2, 212($sp) |
| 377 | .cfi_rel_offset 18, 212 |
| 378 | sw $s1, 208($sp) |
| 379 | .cfi_rel_offset 17, 208 |
| 380 | sw $s0, 204($sp) |
| 381 | .cfi_rel_offset 16, 204 |
| 382 | sw $t7, 200($sp) |
| 383 | .cfi_rel_offset 15, 200 |
| 384 | sw $t6, 196($sp) |
| 385 | .cfi_rel_offset 14, 196 |
| 386 | sw $t5, 192($sp) |
| 387 | .cfi_rel_offset 13, 192 |
| 388 | sw $t4, 188($sp) |
| 389 | .cfi_rel_offset 12, 188 |
| 390 | sw $t3, 184($sp) |
| 391 | .cfi_rel_offset 11, 184 |
| 392 | sw $t2, 180($sp) |
| 393 | .cfi_rel_offset 10, 180 |
| 394 | sw $t1, 176($sp) |
| 395 | .cfi_rel_offset 9, 176 |
| 396 | sw $t0, 172($sp) |
| 397 | .cfi_rel_offset 8, 172 |
| 398 | sw $a3, 168($sp) |
| 399 | .cfi_rel_offset 7, 168 |
| 400 | sw $a2, 164($sp) |
| 401 | .cfi_rel_offset 6, 164 |
| 402 | sw $a1, 160($sp) |
| 403 | .cfi_rel_offset 5, 160 |
| 404 | sw $a0, 156($sp) |
| 405 | .cfi_rel_offset 4, 156 |
| 406 | sw $v1, 152($sp) |
| 407 | .cfi_rel_offset 3, 152 |
| 408 | sw $v0, 148($sp) |
| 409 | .cfi_rel_offset 2, 148 |
| 410 | |
| 411 | // Set up $gp, clobbering $ra and using the branch delay slot for a useful instruction. |
| 412 | bal 1f |
| Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 413 | .set push |
| 414 | .set noat |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 415 | sw $at, 144($sp) |
| 416 | .cfi_rel_offset 1, 144 |
| Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 417 | .set pop |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 418 | 1: |
| 419 | .cpload $ra |
| 420 | |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 421 | CHECK_ALIGNMENT $sp, $t1 |
| 422 | sdc1 $f30, 136($sp) |
| 423 | sdc1 $f28, 128($sp) |
| 424 | sdc1 $f26, 120($sp) |
| 425 | sdc1 $f24, 112($sp) |
| 426 | sdc1 $f22, 104($sp) |
| 427 | sdc1 $f20, 96($sp) |
| 428 | sdc1 $f18, 88($sp) |
| 429 | sdc1 $f16, 80($sp) |
| 430 | sdc1 $f14, 72($sp) |
| 431 | sdc1 $f12, 64($sp) |
| 432 | sdc1 $f10, 56($sp) |
| 433 | sdc1 $f8, 48($sp) |
| 434 | sdc1 $f6, 40($sp) |
| 435 | sdc1 $f4, 32($sp) |
| 436 | sdc1 $f2, 24($sp) |
| 437 | sdc1 $f0, 16($sp) |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 438 | |
| 439 | # 3 words padding and 1 word for holding Method* |
| 440 | |
| 441 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 442 | lw $t0, 0($t0) |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 443 | lw $t0, \runtime_method_offset($t0) |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 444 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 445 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 446 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 447 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| 448 | .endm |
| 449 | |
| Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 450 | /* |
| 451 | * Macro that sets up the callee save frame to conform with |
| 452 | * Runtime::CreateCalleeSaveMethod(kSaveEverything). |
| 453 | * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31; |
| 454 | * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method* |
| 455 | * Clobbers $t0 and $t1. |
| 456 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| 457 | * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack. |
| 458 | * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP. |
| 459 | */ |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 460 | .macro SETUP_SAVE_EVERYTHING_FRAME runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
| Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 461 | addiu $sp, $sp, -(FRAME_SIZE_SAVE_EVERYTHING) |
| 462 | .cfi_adjust_cfa_offset (FRAME_SIZE_SAVE_EVERYTHING) |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 463 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP \runtime_method_offset |
| Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 464 | .endm |
| 465 | |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 466 | .macro RESTORE_SAVE_EVERYTHING_FRAME restore_a0=1 |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 467 | addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack |
| 468 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 469 | |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 470 | CHECK_ALIGNMENT $sp, $t1 |
| 471 | ldc1 $f30, 136($sp) |
| 472 | ldc1 $f28, 128($sp) |
| 473 | ldc1 $f26, 120($sp) |
| 474 | ldc1 $f24, 112($sp) |
| 475 | ldc1 $f22, 104($sp) |
| 476 | ldc1 $f20, 96($sp) |
| 477 | ldc1 $f18, 88($sp) |
| 478 | ldc1 $f16, 80($sp) |
| 479 | ldc1 $f14, 72($sp) |
| 480 | ldc1 $f12, 64($sp) |
| 481 | ldc1 $f10, 56($sp) |
| 482 | ldc1 $f8, 48($sp) |
| 483 | ldc1 $f6, 40($sp) |
| 484 | ldc1 $f4, 32($sp) |
| 485 | ldc1 $f2, 24($sp) |
| 486 | ldc1 $f0, 16($sp) |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 487 | |
| 488 | lw $ra, 252($sp) |
| 489 | .cfi_restore 31 |
| 490 | lw $fp, 248($sp) |
| 491 | .cfi_restore 30 |
| 492 | lw $gp, 244($sp) |
| 493 | .cfi_restore 28 |
| 494 | lw $t9, 240($sp) |
| 495 | .cfi_restore 25 |
| 496 | lw $t8, 236($sp) |
| 497 | .cfi_restore 24 |
| 498 | lw $s7, 232($sp) |
| 499 | .cfi_restore 23 |
| 500 | lw $s6, 228($sp) |
| 501 | .cfi_restore 22 |
| 502 | lw $s5, 224($sp) |
| 503 | .cfi_restore 21 |
| 504 | lw $s4, 220($sp) |
| 505 | .cfi_restore 20 |
| 506 | lw $s3, 216($sp) |
| 507 | .cfi_restore 19 |
| 508 | lw $s2, 212($sp) |
| 509 | .cfi_restore 18 |
| 510 | lw $s1, 208($sp) |
| 511 | .cfi_restore 17 |
| 512 | lw $s0, 204($sp) |
| 513 | .cfi_restore 16 |
| 514 | lw $t7, 200($sp) |
| 515 | .cfi_restore 15 |
| 516 | lw $t6, 196($sp) |
| 517 | .cfi_restore 14 |
| 518 | lw $t5, 192($sp) |
| 519 | .cfi_restore 13 |
| 520 | lw $t4, 188($sp) |
| 521 | .cfi_restore 12 |
| 522 | lw $t3, 184($sp) |
| 523 | .cfi_restore 11 |
| 524 | lw $t2, 180($sp) |
| 525 | .cfi_restore 10 |
| 526 | lw $t1, 176($sp) |
| 527 | .cfi_restore 9 |
| 528 | lw $t0, 172($sp) |
| 529 | .cfi_restore 8 |
| 530 | lw $a3, 168($sp) |
| 531 | .cfi_restore 7 |
| 532 | lw $a2, 164($sp) |
| 533 | .cfi_restore 6 |
| 534 | lw $a1, 160($sp) |
| 535 | .cfi_restore 5 |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 536 | .if \restore_a0 |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 537 | lw $a0, 156($sp) |
| 538 | .cfi_restore 4 |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 539 | .endif |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 540 | lw $v1, 152($sp) |
| 541 | .cfi_restore 3 |
| 542 | lw $v0, 148($sp) |
| 543 | .cfi_restore 2 |
| Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 544 | .set push |
| 545 | .set noat |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 546 | lw $at, 144($sp) |
| 547 | .cfi_restore 1 |
| Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 548 | .set pop |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 549 | |
| 550 | addiu $sp, $sp, 256 # pop frame |
| 551 | .cfi_adjust_cfa_offset -256 |
| 552 | .endm |
| 553 | |
| 554 | /* |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 555 | * Macro that calls through to artDeliverPendingExceptionFromCode, where the pending |
| 556 | * exception is Thread::Current()->exception_ when the runtime method frame is ready. |
| 557 | * Requires $gp properly set up. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 558 | */ |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 559 | .macro DELIVER_PENDING_EXCEPTION_FRAME_READY |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 560 | la $t9, artDeliverPendingExceptionFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 561 | jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 562 | move $a0, rSELF # pass Thread::Current |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 563 | .endm |
| 564 | |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 565 | /* |
| 566 | * Macro that calls through to artDeliverPendingExceptionFromCode, where the pending |
| 567 | * exception is Thread::Current()->exception_. |
| 568 | * Requires $gp properly set up. |
| 569 | */ |
| 570 | .macro DELIVER_PENDING_EXCEPTION |
| 571 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME # save callee saves for throw |
| 572 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 573 | .endm |
| 574 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 575 | .macro RETURN_IF_NO_EXCEPTION |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 576 | lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 577 | RESTORE_SAVE_REFS_ONLY_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 578 | bnez $t0, 1f # success if no exception is pending |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 579 | nop |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 580 | jalr $zero, $ra |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 581 | nop |
| 582 | 1: |
| 583 | DELIVER_PENDING_EXCEPTION |
| 584 | .endm |
| 585 | |
| 586 | .macro RETURN_IF_ZERO |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 587 | RESTORE_SAVE_REFS_ONLY_FRAME |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 588 | bnez $v0, 1f # success? |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 589 | nop |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 590 | jalr $zero, $ra # return on success |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 591 | nop |
| 592 | 1: |
| 593 | DELIVER_PENDING_EXCEPTION |
| 594 | .endm |
| 595 | |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 596 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 597 | RESTORE_SAVE_REFS_ONLY_FRAME |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 598 | beqz $v0, 1f # success? |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 599 | nop |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 600 | jalr $zero, $ra # return on success |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 601 | nop |
| 602 | 1: |
| 603 | DELIVER_PENDING_EXCEPTION |
| 604 | .endm |
| 605 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 606 | /* |
| Goran Jakovljevic | 3bc1381 | 2016-03-22 17:16:05 +0100 | [diff] [blame] | 607 | * On stack replacement stub. |
| 608 | * On entry: |
| 609 | * a0 = stack to copy |
| 610 | * a1 = size of stack |
| 611 | * a2 = pc to call |
| 612 | * a3 = JValue* result |
| 613 | * [sp + 16] = shorty |
| 614 | * [sp + 20] = thread |
| 615 | */ |
| 616 | ENTRY art_quick_osr_stub |
| 617 | // Save callee general purpose registers, RA and GP. |
| 618 | addiu $sp, $sp, -48 |
| 619 | .cfi_adjust_cfa_offset 48 |
| 620 | sw $ra, 44($sp) |
| 621 | .cfi_rel_offset 31, 44 |
| 622 | sw $s8, 40($sp) |
| 623 | .cfi_rel_offset 30, 40 |
| 624 | sw $gp, 36($sp) |
| 625 | .cfi_rel_offset 28, 36 |
| 626 | sw $s7, 32($sp) |
| 627 | .cfi_rel_offset 23, 32 |
| 628 | sw $s6, 28($sp) |
| 629 | .cfi_rel_offset 22, 28 |
| 630 | sw $s5, 24($sp) |
| 631 | .cfi_rel_offset 21, 24 |
| 632 | sw $s4, 20($sp) |
| 633 | .cfi_rel_offset 20, 20 |
| 634 | sw $s3, 16($sp) |
| 635 | .cfi_rel_offset 19, 16 |
| 636 | sw $s2, 12($sp) |
| 637 | .cfi_rel_offset 18, 12 |
| 638 | sw $s1, 8($sp) |
| 639 | .cfi_rel_offset 17, 8 |
| 640 | sw $s0, 4($sp) |
| 641 | .cfi_rel_offset 16, 4 |
| 642 | |
| 643 | move $s8, $sp # Save the stack pointer |
| 644 | move $s7, $a1 # Save size of stack |
| 645 | move $s6, $a2 # Save the pc to call |
| 646 | lw rSELF, 48+20($sp) # Save managed thread pointer into rSELF |
| 647 | addiu $t0, $sp, -12 # Reserve space for stack pointer, |
| 648 | # JValue* result, and ArtMethod* slot. |
| 649 | srl $t0, $t0, 4 # Align stack pointer to 16 bytes |
| 650 | sll $sp, $t0, 4 # Update stack pointer |
| 651 | sw $s8, 4($sp) # Save old stack pointer |
| 652 | sw $a3, 8($sp) # Save JValue* result |
| 653 | sw $zero, 0($sp) # Store null for ArtMethod* at bottom of frame |
| 654 | subu $sp, $a1 # Reserve space for callee stack |
| 655 | move $a2, $a1 |
| 656 | move $a1, $a0 |
| 657 | move $a0, $sp |
| 658 | la $t9, memcpy |
| 659 | jalr $t9 # memcpy (dest a0, src a1, bytes a2) |
| 660 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 661 | bal .Losr_entry # Call the method |
| 662 | addiu $sp, $sp, 16 # restore stack after memcpy |
| 663 | lw $a2, 8($sp) # Restore JValue* result |
| 664 | lw $sp, 4($sp) # Restore saved stack pointer |
| 665 | lw $a0, 48+16($sp) # load shorty |
| 666 | lbu $a0, 0($a0) # load return type |
| 667 | li $a1, 'D' # put char 'D' into a1 |
| 668 | beq $a0, $a1, .Losr_fp_result # Test if result type char == 'D' |
| 669 | li $a1, 'F' # put char 'F' into a1 |
| 670 | beq $a0, $a1, .Losr_fp_result # Test if result type char == 'F' |
| 671 | nop |
| 672 | sw $v0, 0($a2) |
| 673 | b .Losr_exit |
| 674 | sw $v1, 4($a2) # store v0/v1 into result |
| 675 | .Losr_fp_result: |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 676 | CHECK_ALIGNMENT $a2, $t0, 8 |
| 677 | sdc1 $f0, 0($a2) # store f0/f1 into result |
| Goran Jakovljevic | 3bc1381 | 2016-03-22 17:16:05 +0100 | [diff] [blame] | 678 | .Losr_exit: |
| 679 | lw $ra, 44($sp) |
| 680 | .cfi_restore 31 |
| 681 | lw $s8, 40($sp) |
| 682 | .cfi_restore 30 |
| 683 | lw $gp, 36($sp) |
| 684 | .cfi_restore 28 |
| 685 | lw $s7, 32($sp) |
| 686 | .cfi_restore 23 |
| 687 | lw $s6, 28($sp) |
| 688 | .cfi_restore 22 |
| 689 | lw $s5, 24($sp) |
| 690 | .cfi_restore 21 |
| 691 | lw $s4, 20($sp) |
| 692 | .cfi_restore 20 |
| 693 | lw $s3, 16($sp) |
| 694 | .cfi_restore 19 |
| 695 | lw $s2, 12($sp) |
| 696 | .cfi_restore 18 |
| 697 | lw $s1, 8($sp) |
| 698 | .cfi_restore 17 |
| 699 | lw $s0, 4($sp) |
| 700 | .cfi_restore 16 |
| 701 | jalr $zero, $ra |
| 702 | addiu $sp, $sp, 48 |
| 703 | .cfi_adjust_cfa_offset -48 |
| 704 | .Losr_entry: |
| 705 | addiu $s7, $s7, -4 |
| 706 | addu $t0, $s7, $sp |
| 707 | move $t9, $s6 |
| 708 | jalr $zero, $t9 |
| 709 | sw $ra, 0($t0) # Store RA per the compiler ABI |
| 710 | END art_quick_osr_stub |
| 711 | |
| 712 | /* |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 713 | * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_. |
| 714 | * Note that fprs_ is expected to be an address that is a multiple of 8. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 715 | * FIXME: just guessing about the shape of the jmpbuf. Where will pc be? |
| 716 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 717 | ENTRY art_quick_do_long_jump |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 718 | CHECK_ALIGNMENT $a1, $t1, 8 |
| 719 | ldc1 $f0, 0*8($a1) |
| 720 | ldc1 $f2, 1*8($a1) |
| 721 | ldc1 $f4, 2*8($a1) |
| 722 | ldc1 $f6, 3*8($a1) |
| 723 | ldc1 $f8, 4*8($a1) |
| 724 | ldc1 $f10, 5*8($a1) |
| 725 | ldc1 $f12, 6*8($a1) |
| 726 | ldc1 $f14, 7*8($a1) |
| 727 | ldc1 $f16, 8*8($a1) |
| 728 | ldc1 $f18, 9*8($a1) |
| 729 | ldc1 $f20, 10*8($a1) |
| 730 | ldc1 $f22, 11*8($a1) |
| 731 | ldc1 $f24, 12*8($a1) |
| 732 | ldc1 $f26, 13*8($a1) |
| 733 | ldc1 $f28, 14*8($a1) |
| 734 | ldc1 $f30, 15*8($a1) |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 735 | |
| Chris Dearman | 748dd95 | 2014-05-23 10:47:01 -0700 | [diff] [blame] | 736 | .set push |
| 737 | .set nomacro |
| 738 | .set noat |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 739 | lw $at, 4($a0) |
| Chris Dearman | 748dd95 | 2014-05-23 10:47:01 -0700 | [diff] [blame] | 740 | .set pop |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 741 | lw $v0, 8($a0) |
| 742 | lw $v1, 12($a0) |
| 743 | lw $a1, 20($a0) |
| 744 | lw $a2, 24($a0) |
| 745 | lw $a3, 28($a0) |
| 746 | lw $t0, 32($a0) |
| 747 | lw $t1, 36($a0) |
| 748 | lw $t2, 40($a0) |
| 749 | lw $t3, 44($a0) |
| 750 | lw $t4, 48($a0) |
| 751 | lw $t5, 52($a0) |
| 752 | lw $t6, 56($a0) |
| 753 | lw $t7, 60($a0) |
| 754 | lw $s0, 64($a0) |
| 755 | lw $s1, 68($a0) |
| 756 | lw $s2, 72($a0) |
| 757 | lw $s3, 76($a0) |
| 758 | lw $s4, 80($a0) |
| 759 | lw $s5, 84($a0) |
| 760 | lw $s6, 88($a0) |
| 761 | lw $s7, 92($a0) |
| 762 | lw $t8, 96($a0) |
| 763 | lw $t9, 100($a0) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 764 | lw $gp, 112($a0) |
| 765 | lw $sp, 116($a0) |
| 766 | lw $fp, 120($a0) |
| 767 | lw $ra, 124($a0) |
| 768 | lw $a0, 16($a0) |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 769 | move $v0, $zero # clear result registers v0 and v1 (in branch delay slot) |
| Goran Jakovljevic | 7596996 | 2015-10-27 12:29:07 +0100 | [diff] [blame] | 770 | jalr $zero, $t9 # do long jump |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 771 | move $v1, $zero |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 772 | END art_quick_do_long_jump |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 773 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 774 | /* |
| 775 | * Called by managed code, saves most registers (forms basis of long jump context) and passes |
| 776 | * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at |
| Lazar Trsic | 84bc06e | 2015-06-10 16:05:46 +0200 | [diff] [blame] | 777 | * the bottom of the thread. On entry a0 holds Throwable* |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 778 | */ |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 779 | ENTRY art_quick_deliver_exception |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 780 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 781 | la $t9, artDeliverExceptionFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 782 | jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 783 | move $a1, rSELF # pass Thread::Current |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 784 | END art_quick_deliver_exception |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 785 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 786 | /* |
| 787 | * Called by managed code to create and deliver a NullPointerException |
| 788 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 789 | .extern artThrowNullPointerExceptionFromCode |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 790 | ENTRY_NO_GP art_quick_throw_null_pointer_exception |
| 791 | // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK, |
| 792 | // even after clobbering any registers we don't need to preserve, such as $gp or $t0. |
| 793 | SETUP_SAVE_EVERYTHING_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 794 | la $t9, artThrowNullPointerExceptionFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 795 | jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 796 | move $a0, rSELF # pass Thread::Current |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 797 | END art_quick_throw_null_pointer_exception |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 798 | |
| Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 799 | |
| 800 | /* |
| 801 | * Call installed by a signal handler to create and deliver a NullPointerException. |
| 802 | */ |
| 803 | .extern artThrowNullPointerExceptionFromSignal |
| Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 804 | ENTRY_NO_GP_CUSTOM_CFA art_quick_throw_null_pointer_exception_from_signal, FRAME_SIZE_SAVE_EVERYTHING |
| 805 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP |
| 806 | # Retrieve the fault address from the padding where the signal handler stores it. |
| 807 | lw $a0, (ARG_SLOT_SIZE + __SIZEOF_POINTER__)($sp) |
| Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 808 | la $t9, artThrowNullPointerExceptionFromSignal |
| 809 | jalr $zero, $t9 # artThrowNullPointerExceptionFromSignal(uintptr_t, Thread*) |
| 810 | move $a1, rSELF # pass Thread::Current |
| 811 | END art_quick_throw_null_pointer_exception_from_signal |
| 812 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 813 | /* |
| 814 | * Called by managed code to create and deliver an ArithmeticException |
| 815 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 816 | .extern artThrowDivZeroFromCode |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 817 | ENTRY_NO_GP art_quick_throw_div_zero |
| 818 | SETUP_SAVE_EVERYTHING_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 819 | la $t9, artThrowDivZeroFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 820 | jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 821 | move $a0, rSELF # pass Thread::Current |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 822 | END art_quick_throw_div_zero |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 823 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 824 | /* |
| 825 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException |
| 826 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 827 | .extern artThrowArrayBoundsFromCode |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 828 | ENTRY_NO_GP art_quick_throw_array_bounds |
| 829 | // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK, |
| 830 | // even after clobbering any registers we don't need to preserve, such as $gp or $t0. |
| 831 | SETUP_SAVE_EVERYTHING_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 832 | la $t9, artThrowArrayBoundsFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 833 | jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 834 | move $a2, rSELF # pass Thread::Current |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 835 | END art_quick_throw_array_bounds |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 836 | |
| Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 837 | /* |
| Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 838 | * Called by managed code to create and deliver a StringIndexOutOfBoundsException |
| 839 | * as if thrown from a call to String.charAt(). |
| 840 | */ |
| 841 | .extern artThrowStringBoundsFromCode |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 842 | ENTRY_NO_GP art_quick_throw_string_bounds |
| 843 | SETUP_SAVE_EVERYTHING_FRAME |
| Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 844 | la $t9, artThrowStringBoundsFromCode |
| 845 | jalr $zero, $t9 # artThrowStringBoundsFromCode(index, limit, Thread*) |
| 846 | move $a2, rSELF # pass Thread::Current |
| 847 | END art_quick_throw_string_bounds |
| 848 | |
| 849 | /* |
| Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 850 | * Called by managed code to create and deliver a StackOverflowError. |
| 851 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 852 | .extern artThrowStackOverflowFromCode |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 853 | ENTRY art_quick_throw_stack_overflow |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 854 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 855 | la $t9, artThrowStackOverflowFromCode |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 856 | jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 857 | move $a0, rSELF # pass Thread::Current |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 858 | END art_quick_throw_stack_overflow |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 859 | |
| Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 860 | /* |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 861 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 862 | * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain |
| Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 863 | * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper. |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 864 | * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 865 | * |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 866 | * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting |
| 867 | * of the target Method* in $v0 and method->code_ in $v1. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 868 | * |
| Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 869 | * If unsuccessful, the helper will return null/null. There will be a pending exception in the |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 870 | * thread and we branch to another stub to deliver it. |
| 871 | * |
| 872 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 873 | * pointing back to the original caller. |
| 874 | */ |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 875 | .macro INVOKE_TRAMPOLINE_BODY cxx_name, save_s4_thru_s8_only=0 |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 876 | .extern \cxx_name |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 877 | SETUP_SAVE_REFS_AND_ARGS_FRAME \save_s4_thru_s8_only # save callee saves in case |
| 878 | # allocation triggers GC |
| Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 879 | move $a2, rSELF # pass Thread::Current |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 880 | la $t9, \cxx_name |
| 881 | jalr $t9 # (method_idx, this, Thread*, $sp) |
| Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 882 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
| 883 | move $a0, $v0 # save target Method* |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 884 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 885 | beqz $v0, 1f |
| Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 886 | move $t9, $v1 # save $v0->code_ |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 887 | jalr $zero, $t9 |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 888 | nop |
| 889 | 1: |
| 890 | DELIVER_PENDING_EXCEPTION |
| Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 891 | .endm |
| 892 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 893 | ENTRY \c_name |
| 894 | INVOKE_TRAMPOLINE_BODY \cxx_name |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 895 | END \c_name |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 896 | .endm |
| 897 | |
| Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 898 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 899 | |
| Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 900 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 901 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 902 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 903 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 904 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 905 | // Each of the following macros expands into four instructions or 16 bytes. |
| 906 | // They are used to build indexable "tables" of code. |
| 907 | |
| 908 | .macro LOAD_WORD_TO_REG reg, next_arg, index_reg, label |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 909 | lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4) |
| 910 | b \label |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 911 | addiu $\index_reg, 16 |
| 912 | .balign 16 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 913 | .endm |
| 914 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 915 | .macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index_reg, next_index, label |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 916 | lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8) |
| 917 | lw $\reg2, -4($\next_arg) |
| 918 | b \label |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 919 | li $\index_reg, \next_index |
| 920 | .balign 16 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 921 | .endm |
| 922 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 923 | .macro LOAD_FLOAT_TO_REG reg, next_arg, index_reg, label |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 924 | lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4) |
| 925 | b \label |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 926 | addiu $\index_reg, 16 |
| 927 | .balign 16 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 928 | .endm |
| 929 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 930 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 931 | // LDu expands into 3 instructions for 64-bit FPU, so index_reg cannot be updated here. |
| 932 | .macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label |
| 933 | .set reorder # force use of the branch delay slot |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 934 | LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one |
| 935 | # (offset is 8) |
| 936 | b \label |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 937 | .set noreorder |
| 938 | .balign 16 |
| 939 | .endm |
| 940 | #else |
| 941 | // LDu expands into 2 instructions for 32-bit FPU, so index_reg is updated here. |
| 942 | .macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label |
| 943 | LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one |
| 944 | # (offset is 8) |
| 945 | b \label |
| 946 | addiu $\index_reg, 16 |
| 947 | .balign 16 |
| 948 | .endm |
| 949 | #endif |
| 950 | |
| 951 | .macro LOAD_END index_reg, next_index, label |
| 952 | b \label |
| 953 | li $\index_reg, \next_index |
| 954 | .balign 16 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 955 | .endm |
| 956 | |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 957 | #define SPILL_SIZE 32 |
| 958 | |
| Jeff Hao | 79fe539 | 2013-04-24 18:41:58 -0700 | [diff] [blame] | 959 | /* |
| Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 960 | * Invocation stub for quick code. |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 961 | * On entry: |
| 962 | * a0 = method pointer |
| Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 963 | * a1 = argument array or null for no argument methods |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 964 | * a2 = size of argument array in bytes |
| 965 | * a3 = (managed) thread pointer |
| Jeff Hao | 6474d19 | 2013-03-26 14:08:09 -0700 | [diff] [blame] | 966 | * [sp + 16] = JValue* result |
| Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 967 | * [sp + 20] = shorty |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 968 | */ |
| 969 | ENTRY art_quick_invoke_stub |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 970 | sw $a0, 0($sp) # save out a0 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 971 | addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp |
| 972 | .cfi_adjust_cfa_offset SPILL_SIZE |
| 973 | sw $gp, 16($sp) |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 974 | sw $ra, 12($sp) |
| 975 | .cfi_rel_offset 31, 12 |
| 976 | sw $fp, 8($sp) |
| 977 | .cfi_rel_offset 30, 8 |
| 978 | sw $s1, 4($sp) |
| 979 | .cfi_rel_offset 17, 4 |
| 980 | sw $s0, 0($sp) |
| 981 | .cfi_rel_offset 16, 0 |
| 982 | move $fp, $sp # save sp in fp |
| 983 | .cfi_def_cfa_register 30 |
| 984 | move $s1, $a3 # move managed thread pointer into s1 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 985 | addiu $t0, $a2, 4 # create space for ArtMethod* in frame. |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 986 | subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes: |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 987 | srl $t0, $t0, 4 # native calling convention only aligns to 8B, |
| 988 | sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves. |
| 989 | addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 990 | la $t9, memcpy |
| 991 | jalr $t9 # (dest, src, bytes) |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 992 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 993 | addiu $sp, $sp, 16 # restore stack after memcpy |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 994 | lw $gp, 16($fp) # restore $gp |
| 995 | lw $a0, SPILL_SIZE($fp) # restore ArtMethod* |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 996 | lw $a1, 4($sp) # a1 = this* |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 997 | addiu $t8, $sp, 8 # t8 = pointer to the current argument (skip ArtMethod* and this*) |
| 998 | li $t6, 0 # t6 = gpr_index = 0 (corresponds to A2; A0 and A1 are skipped) |
| 999 | li $t7, 0 # t7 = fp_index = 0 |
| 1000 | lw $t9, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1001 | # as the $fp is SPILL_SIZE bytes below the $sp on entry) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1002 | addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type) |
| 1003 | |
| 1004 | // Load the base addresses of tabInt ... tabDouble. |
| 1005 | // We will use the register indices (gpr_index, fp_index) to branch. |
| 1006 | // Note that the indices are scaled by 16, so they can be added to the bases directly. |
| 1007 | #if defined(__mips_isa_rev) && __mips_isa_rev >= 6 |
| 1008 | lapc $t2, tabInt |
| 1009 | lapc $t3, tabLong |
| 1010 | lapc $t4, tabSingle |
| 1011 | lapc $t5, tabDouble |
| 1012 | #else |
| 1013 | bltzal $zero, tabBase # nal |
| 1014 | addiu $t2, $ra, %lo(tabInt - tabBase) |
| 1015 | tabBase: |
| 1016 | addiu $t3, $ra, %lo(tabLong - tabBase) |
| 1017 | addiu $t4, $ra, %lo(tabSingle - tabBase) |
| 1018 | addiu $t5, $ra, %lo(tabDouble - tabBase) |
| 1019 | #endif |
| 1020 | |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1021 | loop: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1022 | lbu $ra, 0($t9) # ra = shorty[i] |
| 1023 | beqz $ra, loopEnd # finish getting args when shorty[i] == '\0' |
| 1024 | addiu $t9, 1 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1025 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1026 | addiu $ra, -'J' |
| 1027 | beqz $ra, isLong # branch if result type char == 'J' |
| 1028 | addiu $ra, 'J' - 'D' |
| 1029 | beqz $ra, isDouble # branch if result type char == 'D' |
| 1030 | addiu $ra, 'D' - 'F' |
| 1031 | beqz $ra, isSingle # branch if result type char == 'F' |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1032 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1033 | addu $ra, $t2, $t6 |
| 1034 | jalr $zero, $ra |
| 1035 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1036 | |
| 1037 | isLong: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1038 | addu $ra, $t3, $t6 |
| 1039 | jalr $zero, $ra |
| 1040 | addiu $t8, 8 # next_arg = curr_arg + 8 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1041 | |
| 1042 | isSingle: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1043 | addu $ra, $t4, $t7 |
| 1044 | jalr $zero, $ra |
| 1045 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| 1046 | |
| 1047 | isDouble: |
| 1048 | addu $ra, $t5, $t7 |
| 1049 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 1050 | addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG |
| 1051 | #endif |
| 1052 | jalr $zero, $ra |
| 1053 | addiu $t8, 8 # next_arg = curr_arg + 8 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1054 | |
| 1055 | loopEnd: |
| Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1056 | lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1057 | jalr $t9 # call the method |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1058 | sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1059 | move $sp, $fp # restore the stack |
| 1060 | lw $s0, 0($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1061 | .cfi_restore 16 |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1062 | lw $s1, 4($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1063 | .cfi_restore 17 |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1064 | lw $fp, 8($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1065 | .cfi_restore 30 |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1066 | lw $ra, 12($sp) |
| Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1067 | .cfi_restore 31 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1068 | addiu $sp, $sp, SPILL_SIZE |
| 1069 | .cfi_adjust_cfa_offset -SPILL_SIZE |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1070 | lw $t0, 16($sp) # get result pointer |
| Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 1071 | lw $t1, 20($sp) # get shorty |
| 1072 | lb $t1, 0($t1) # get result type char |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1073 | li $t2, 'D' # put char 'D' into t2 |
| 1074 | beq $t1, $t2, 5f # branch if result type char == 'D' |
| 1075 | li $t3, 'F' # put char 'F' into t3 |
| 1076 | beq $t1, $t3, 5f # branch if result type char == 'F' |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1077 | sw $v0, 0($t0) # store the result |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1078 | jalr $zero, $ra |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1079 | sw $v1, 4($t0) # store the other half of the result |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1080 | 5: |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 1081 | CHECK_ALIGNMENT $t0, $t1, 8 |
| 1082 | sdc1 $f0, 0($t0) # store floating point result |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1083 | jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1084 | nop |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1085 | |
| 1086 | // Note that gpr_index is kept within the range of tabInt and tabLong |
| 1087 | // and fp_index is kept within the range of tabSingle and tabDouble. |
| 1088 | .balign 16 |
| 1089 | tabInt: |
| 1090 | LOAD_WORD_TO_REG a2, t8, t6, loop # a2 = current argument, gpr_index += 16 |
| 1091 | LOAD_WORD_TO_REG a3, t8, t6, loop # a3 = current argument, gpr_index += 16 |
| 1092 | LOAD_WORD_TO_REG t0, t8, t6, loop # t0 = current argument, gpr_index += 16 |
| 1093 | LOAD_WORD_TO_REG t1, t8, t6, loop # t1 = current argument, gpr_index += 16 |
| 1094 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1095 | tabLong: |
| 1096 | LOAD_LONG_TO_REG a2, a3, t8, t6, 2*16, loop # a2_a3 = curr_arg, gpr_index = 2*16 |
| 1097 | LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16 |
| 1098 | LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16 |
| 1099 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1100 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1101 | tabSingle: |
| 1102 | LOAD_FLOAT_TO_REG f8, t8, t7, loop # f8 = curr_arg, fp_index += 16 |
| 1103 | LOAD_FLOAT_TO_REG f10, t8, t7, loop # f10 = curr_arg, fp_index += 16 |
| 1104 | LOAD_FLOAT_TO_REG f12, t8, t7, loop # f12 = curr_arg, fp_index += 16 |
| 1105 | LOAD_FLOAT_TO_REG f14, t8, t7, loop # f14 = curr_arg, fp_index += 16 |
| 1106 | LOAD_FLOAT_TO_REG f16, t8, t7, loop # f16 = curr_arg, fp_index += 16 |
| 1107 | LOAD_FLOAT_TO_REG f18, t8, t7, loop # f18 = curr_arg, fp_index += 16 |
| 1108 | LOAD_END t7, 6*16, loop # no more FPR args, fp_index = 6*16 |
| 1109 | tabDouble: |
| 1110 | LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loop # f8_f9 = curr_arg; if FPU32, fp_index += 16 |
| 1111 | LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loop # f10_f11 = curr_arg; if FPU32, fp_index += 16 |
| 1112 | LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loop # f12_f13 = curr_arg; if FPU32, fp_index += 16 |
| 1113 | LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loop # f14_f15 = curr_arg; if FPU32, fp_index += 16 |
| 1114 | LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loop # f16_f17 = curr_arg; if FPU32, fp_index += 16 |
| 1115 | LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loop # f18_f19 = curr_arg; if FPU32, fp_index += 16 |
| 1116 | LOAD_END t7, 6*16, loop # no more FPR args, fp_index = 6*16 |
| Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1117 | END art_quick_invoke_stub |
| 1118 | |
| 1119 | /* |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1120 | * Invocation static stub for quick code. |
| 1121 | * On entry: |
| 1122 | * a0 = method pointer |
| 1123 | * a1 = argument array or null for no argument methods |
| 1124 | * a2 = size of argument array in bytes |
| 1125 | * a3 = (managed) thread pointer |
| 1126 | * [sp + 16] = JValue* result |
| 1127 | * [sp + 20] = shorty |
| 1128 | */ |
| 1129 | ENTRY art_quick_invoke_static_stub |
| 1130 | sw $a0, 0($sp) # save out a0 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1131 | addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp |
| 1132 | .cfi_adjust_cfa_offset SPILL_SIZE |
| 1133 | sw $gp, 16($sp) |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1134 | sw $ra, 12($sp) |
| 1135 | .cfi_rel_offset 31, 12 |
| 1136 | sw $fp, 8($sp) |
| 1137 | .cfi_rel_offset 30, 8 |
| 1138 | sw $s1, 4($sp) |
| 1139 | .cfi_rel_offset 17, 4 |
| 1140 | sw $s0, 0($sp) |
| 1141 | .cfi_rel_offset 16, 0 |
| 1142 | move $fp, $sp # save sp in fp |
| 1143 | .cfi_def_cfa_register 30 |
| 1144 | move $s1, $a3 # move managed thread pointer into s1 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1145 | addiu $t0, $a2, 4 # create space for ArtMethod* in frame. |
| 1146 | subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes: |
| 1147 | srl $t0, $t0, 4 # native calling convention only aligns to 8B, |
| 1148 | sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves. |
| 1149 | addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1150 | la $t9, memcpy |
| 1151 | jalr $t9 # (dest, src, bytes) |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1152 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 1153 | addiu $sp, $sp, 16 # restore stack after memcpy |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1154 | lw $gp, 16($fp) # restore $gp |
| 1155 | lw $a0, SPILL_SIZE($fp) # restore ArtMethod* |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1156 | addiu $t8, $sp, 4 # t8 = pointer to the current argument (skip ArtMethod*) |
| 1157 | li $t6, 0 # t6 = gpr_index = 0 (corresponds to A1; A0 is skipped) |
| 1158 | li $t7, 0 # t7 = fp_index = 0 |
| 1159 | lw $t9, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1160 | # as the $fp is SPILL_SIZE bytes below the $sp on entry) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1161 | addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type) |
| 1162 | |
| 1163 | // Load the base addresses of tabIntS ... tabDoubleS. |
| 1164 | // We will use the register indices (gpr_index, fp_index) to branch. |
| 1165 | // Note that the indices are scaled by 16, so they can be added to the bases directly. |
| 1166 | #if defined(__mips_isa_rev) && __mips_isa_rev >= 6 |
| 1167 | lapc $t2, tabIntS |
| 1168 | lapc $t3, tabLongS |
| 1169 | lapc $t4, tabSingleS |
| 1170 | lapc $t5, tabDoubleS |
| 1171 | #else |
| 1172 | bltzal $zero, tabBaseS # nal |
| 1173 | addiu $t2, $ra, %lo(tabIntS - tabBaseS) |
| 1174 | tabBaseS: |
| 1175 | addiu $t3, $ra, %lo(tabLongS - tabBaseS) |
| 1176 | addiu $t4, $ra, %lo(tabSingleS - tabBaseS) |
| 1177 | addiu $t5, $ra, %lo(tabDoubleS - tabBaseS) |
| 1178 | #endif |
| 1179 | |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1180 | loopS: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1181 | lbu $ra, 0($t9) # ra = shorty[i] |
| 1182 | beqz $ra, loopEndS # finish getting args when shorty[i] == '\0' |
| 1183 | addiu $t9, 1 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1184 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1185 | addiu $ra, -'J' |
| 1186 | beqz $ra, isLongS # branch if result type char == 'J' |
| 1187 | addiu $ra, 'J' - 'D' |
| 1188 | beqz $ra, isDoubleS # branch if result type char == 'D' |
| 1189 | addiu $ra, 'D' - 'F' |
| 1190 | beqz $ra, isSingleS # branch if result type char == 'F' |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1191 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1192 | addu $ra, $t2, $t6 |
| 1193 | jalr $zero, $ra |
| 1194 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1195 | |
| 1196 | isLongS: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1197 | addu $ra, $t3, $t6 |
| 1198 | jalr $zero, $ra |
| 1199 | addiu $t8, 8 # next_arg = curr_arg + 8 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1200 | |
| 1201 | isSingleS: |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1202 | addu $ra, $t4, $t7 |
| 1203 | jalr $zero, $ra |
| 1204 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| 1205 | |
| 1206 | isDoubleS: |
| 1207 | addu $ra, $t5, $t7 |
| 1208 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 1209 | addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG |
| 1210 | #endif |
| 1211 | jalr $zero, $ra |
| 1212 | addiu $t8, 8 # next_arg = curr_arg + 8 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1213 | |
| 1214 | loopEndS: |
| 1215 | lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code |
| 1216 | jalr $t9 # call the method |
| 1217 | sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
| 1218 | move $sp, $fp # restore the stack |
| 1219 | lw $s0, 0($sp) |
| 1220 | .cfi_restore 16 |
| 1221 | lw $s1, 4($sp) |
| 1222 | .cfi_restore 17 |
| 1223 | lw $fp, 8($sp) |
| 1224 | .cfi_restore 30 |
| 1225 | lw $ra, 12($sp) |
| 1226 | .cfi_restore 31 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1227 | addiu $sp, $sp, SPILL_SIZE |
| 1228 | .cfi_adjust_cfa_offset -SPILL_SIZE |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1229 | lw $t0, 16($sp) # get result pointer |
| 1230 | lw $t1, 20($sp) # get shorty |
| 1231 | lb $t1, 0($t1) # get result type char |
| 1232 | li $t2, 'D' # put char 'D' into t2 |
| 1233 | beq $t1, $t2, 6f # branch if result type char == 'D' |
| 1234 | li $t3, 'F' # put char 'F' into t3 |
| 1235 | beq $t1, $t3, 6f # branch if result type char == 'F' |
| 1236 | sw $v0, 0($t0) # store the result |
| 1237 | jalr $zero, $ra |
| 1238 | sw $v1, 4($t0) # store the other half of the result |
| 1239 | 6: |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 1240 | CHECK_ALIGNMENT $t0, $t1, 8 |
| 1241 | sdc1 $f0, 0($t0) # store floating point result |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1242 | jalr $zero, $ra |
| 1243 | nop |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1244 | |
| 1245 | // Note that gpr_index is kept within the range of tabIntS and tabLongS |
| 1246 | // and fp_index is kept within the range of tabSingleS and tabDoubleS. |
| 1247 | .balign 16 |
| 1248 | tabIntS: |
| 1249 | LOAD_WORD_TO_REG a1, t8, t6, loopS # a1 = current argument, gpr_index += 16 |
| 1250 | LOAD_WORD_TO_REG a2, t8, t6, loopS # a2 = current argument, gpr_index += 16 |
| 1251 | LOAD_WORD_TO_REG a3, t8, t6, loopS # a3 = current argument, gpr_index += 16 |
| 1252 | LOAD_WORD_TO_REG t0, t8, t6, loopS # t0 = current argument, gpr_index += 16 |
| 1253 | LOAD_WORD_TO_REG t1, t8, t6, loopS # t1 = current argument, gpr_index += 16 |
| 1254 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1255 | tabLongS: |
| 1256 | LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16 |
| 1257 | LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16 |
| 1258 | LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16 |
| 1259 | LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16 |
| 1260 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1261 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1262 | tabSingleS: |
| 1263 | LOAD_FLOAT_TO_REG f8, t8, t7, loopS # f8 = curr_arg, fp_index += 16 |
| 1264 | LOAD_FLOAT_TO_REG f10, t8, t7, loopS # f10 = curr_arg, fp_index += 16 |
| 1265 | LOAD_FLOAT_TO_REG f12, t8, t7, loopS # f12 = curr_arg, fp_index += 16 |
| 1266 | LOAD_FLOAT_TO_REG f14, t8, t7, loopS # f14 = curr_arg, fp_index += 16 |
| 1267 | LOAD_FLOAT_TO_REG f16, t8, t7, loopS # f16 = curr_arg, fp_index += 16 |
| 1268 | LOAD_FLOAT_TO_REG f18, t8, t7, loopS # f18 = curr_arg, fp_index += 16 |
| 1269 | LOAD_END t7, 6*16, loopS # no more FPR args, fp_index = 6*16 |
| 1270 | tabDoubleS: |
| 1271 | LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loopS # f8_f9 = curr_arg; if FPU32, fp_index += 16 |
| 1272 | LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loopS # f10_f11 = curr_arg; if FPU32, fp_index += 16 |
| 1273 | LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loopS # f12_f13 = curr_arg; if FPU32, fp_index += 16 |
| 1274 | LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loopS # f14_f15 = curr_arg; if FPU32, fp_index += 16 |
| 1275 | LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loopS # f16_f17 = curr_arg; if FPU32, fp_index += 16 |
| 1276 | LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loopS # f18_f19 = curr_arg; if FPU32, fp_index += 16 |
| 1277 | LOAD_END t7, 6*16, loopS # no more FPR args, fp_index = 6*16 |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1278 | END art_quick_invoke_static_stub |
| 1279 | |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1280 | #undef SPILL_SIZE |
| 1281 | |
| Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1282 | /* |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1283 | * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on |
| 1284 | * failure. |
| 1285 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1286 | .extern artHandleFillArrayDataFromCode |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1287 | ENTRY art_quick_handle_fill_data |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1288 | lw $a2, 0($sp) # pass referrer's Method* |
| 1289 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1290 | la $t9, artHandleFillArrayDataFromCode |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1291 | jalr $t9 # (payload offset, Array*, method, Thread*) |
| 1292 | move $a3, rSELF # pass Thread::Current |
| jeffhao | fc6a30e | 2012-10-18 18:24:15 -0700 | [diff] [blame] | 1293 | RETURN_IF_ZERO |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1294 | END art_quick_handle_fill_data |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1295 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1296 | /* |
| Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1297 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1298 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1299 | .extern artLockObjectFromCode |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1300 | ENTRY art_quick_lock_object |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1301 | beqz $a0, art_quick_throw_null_pointer_exception |
| Alexey Frunze | ad63fe5 | 2017-05-08 22:10:00 -0700 | [diff] [blame] | 1302 | li $t8, LOCK_WORD_THIN_LOCK_COUNT_ONE |
| 1303 | li $t3, LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED |
| 1304 | .Lretry_lock: |
| 1305 | lw $t0, THREAD_ID_OFFSET(rSELF) # TODO: Can the thread ID really change during the loop? |
| 1306 | ll $t1, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1307 | and $t2, $t1, $t3 # zero the gc bits |
| 1308 | bnez $t2, .Lnot_unlocked # already thin locked |
| 1309 | # Unlocked case - $t1: original lock word that's zero except for the read barrier bits. |
| 1310 | or $t2, $t1, $t0 # $t2 holds thread id with count of 0 with preserved read barrier bits |
| 1311 | sc $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1312 | beqz $t2, .Lretry_lock # store failed, retry |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1313 | nop |
| Alexey Frunze | ad63fe5 | 2017-05-08 22:10:00 -0700 | [diff] [blame] | 1314 | jalr $zero, $ra |
| 1315 | sync # full (LoadLoad|LoadStore) memory barrier |
| 1316 | .Lnot_unlocked: |
| 1317 | # $t1: original lock word, $t0: thread_id with count of 0 and zero read barrier bits |
| 1318 | srl $t2, $t1, LOCK_WORD_STATE_SHIFT |
| 1319 | bnez $t2, .Lslow_lock # if either of the top two bits are set, go slow path |
| 1320 | xor $t2, $t1, $t0 # lock_word.ThreadId() ^ self->ThreadId() |
| 1321 | andi $t2, $t2, 0xFFFF # zero top 16 bits |
| 1322 | bnez $t2, .Lslow_lock # lock word and self thread id's match -> recursive lock |
| 1323 | # otherwise contention, go to slow path |
| 1324 | and $t2, $t1, $t3 # zero the gc bits |
| 1325 | addu $t2, $t2, $t8 # increment count in lock word |
| 1326 | srl $t2, $t2, LOCK_WORD_STATE_SHIFT # if the first gc state bit is set, we overflowed. |
| 1327 | bnez $t2, .Lslow_lock # if we overflow the count go slow path |
| 1328 | addu $t2, $t1, $t8 # increment count for real |
| 1329 | sc $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1330 | beqz $t2, .Lretry_lock # store failed, retry |
| 1331 | nop |
| 1332 | jalr $zero, $ra |
| 1333 | nop |
| 1334 | .Lslow_lock: |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1335 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1336 | la $t9, artLockObjectFromCode |
| 1337 | jalr $t9 # (Object* obj, Thread*) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1338 | move $a1, rSELF # pass Thread::Current |
| Ian Rogers | 6bcd163 | 2013-10-08 18:50:47 -0700 | [diff] [blame] | 1339 | RETURN_IF_ZERO |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1340 | END art_quick_lock_object |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1341 | |
| Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1342 | ENTRY art_quick_lock_object_no_inline |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1343 | beqz $a0, art_quick_throw_null_pointer_exception |
| Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1344 | nop |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1345 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block |
| Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1346 | la $t9, artLockObjectFromCode |
| 1347 | jalr $t9 # (Object* obj, Thread*) |
| 1348 | move $a1, rSELF # pass Thread::Current |
| 1349 | RETURN_IF_ZERO |
| 1350 | END art_quick_lock_object_no_inline |
| 1351 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1352 | /* |
| 1353 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 1354 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1355 | .extern artUnlockObjectFromCode |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1356 | ENTRY art_quick_unlock_object |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1357 | beqz $a0, art_quick_throw_null_pointer_exception |
| Alexey Frunze | ad63fe5 | 2017-05-08 22:10:00 -0700 | [diff] [blame] | 1358 | li $t8, LOCK_WORD_THIN_LOCK_COUNT_ONE |
| 1359 | li $t3, LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED |
| 1360 | .Lretry_unlock: |
| 1361 | #ifndef USE_READ_BARRIER |
| 1362 | lw $t1, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1363 | #else |
| 1364 | ll $t1, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) # Need to use atomic read-modify-write for read barrier |
| 1365 | #endif |
| 1366 | srl $t2, $t1, LOCK_WORD_STATE_SHIFT |
| 1367 | bnez $t2, .Lslow_unlock # if either of the top two bits are set, go slow path |
| 1368 | lw $t0, THREAD_ID_OFFSET(rSELF) |
| 1369 | and $t2, $t1, $t3 # zero the gc bits |
| 1370 | xor $t2, $t2, $t0 # lock_word.ThreadId() ^ self->ThreadId() |
| 1371 | andi $t2, $t2, 0xFFFF # zero top 16 bits |
| 1372 | bnez $t2, .Lslow_unlock # do lock word and self thread id's match? |
| 1373 | and $t2, $t1, $t3 # zero the gc bits |
| 1374 | bgeu $t2, $t8, .Lrecursive_thin_unlock |
| 1375 | # transition to unlocked |
| 1376 | nor $t2, $zero, $t3 # $t2 = LOCK_WORD_GC_STATE_MASK_SHIFTED |
| 1377 | and $t2, $t1, $t2 # $t2: zero except for the preserved gc bits |
| 1378 | sync # full (LoadStore|StoreStore) memory barrier |
| 1379 | #ifndef USE_READ_BARRIER |
| 1380 | jalr $zero, $ra |
| 1381 | sw $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1382 | #else |
| 1383 | sc $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1384 | beqz $t2, .Lretry_unlock # store failed, retry |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1385 | nop |
| Alexey Frunze | ad63fe5 | 2017-05-08 22:10:00 -0700 | [diff] [blame] | 1386 | jalr $zero, $ra |
| 1387 | nop |
| 1388 | #endif |
| 1389 | .Lrecursive_thin_unlock: |
| 1390 | # t1: original lock word |
| 1391 | subu $t2, $t1, $t8 # decrement count |
| 1392 | #ifndef USE_READ_BARRIER |
| 1393 | jalr $zero, $ra |
| 1394 | sw $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1395 | #else |
| 1396 | sc $t2, MIRROR_OBJECT_LOCK_WORD_OFFSET($a0) |
| 1397 | beqz $t2, .Lretry_unlock # store failed, retry |
| 1398 | nop |
| 1399 | jalr $zero, $ra |
| 1400 | nop |
| 1401 | #endif |
| 1402 | .Lslow_unlock: |
| 1403 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1404 | la $t9, artUnlockObjectFromCode |
| Alexey Frunze | ad63fe5 | 2017-05-08 22:10:00 -0700 | [diff] [blame] | 1405 | jalr $t9 # (Object* obj, Thread*) |
| 1406 | move $a1, rSELF # pass Thread::Current |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1407 | RETURN_IF_ZERO |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1408 | END art_quick_unlock_object |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1409 | |
| Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1410 | ENTRY art_quick_unlock_object_no_inline |
| Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1411 | beqz $a0, art_quick_throw_null_pointer_exception |
| Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1412 | nop |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1413 | 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] | 1414 | la $t9, artUnlockObjectFromCode |
| 1415 | jalr $t9 # (Object* obj, Thread*) |
| 1416 | move $a1, rSELF # pass Thread::Current |
| 1417 | RETURN_IF_ZERO |
| 1418 | END art_quick_unlock_object_no_inline |
| 1419 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1420 | /* |
| Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1421 | * Entry from managed code that calls artInstanceOfFromCode and delivers exception on failure. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1422 | */ |
| Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1423 | .extern artInstanceOfFromCode |
| 1424 | .extern artThrowClassCastExceptionForObject |
| 1425 | ENTRY art_quick_check_instance_of |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1426 | addiu $sp, $sp, -32 |
| 1427 | .cfi_adjust_cfa_offset 32 |
| 1428 | sw $gp, 16($sp) |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1429 | sw $ra, 12($sp) |
| 1430 | .cfi_rel_offset 31, 12 |
| 1431 | sw $t9, 8($sp) |
| 1432 | sw $a1, 4($sp) |
| 1433 | sw $a0, 0($sp) |
| Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1434 | la $t9, artInstanceOfFromCode |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1435 | jalr $t9 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1436 | addiu $sp, $sp, -16 # reserve argument slots on the stack |
| 1437 | addiu $sp, $sp, 16 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1438 | lw $gp, 16($sp) |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1439 | beqz $v0, .Lthrow_class_cast_exception |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1440 | lw $ra, 12($sp) |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1441 | jalr $zero, $ra |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1442 | addiu $sp, $sp, 32 |
| 1443 | .cfi_adjust_cfa_offset -32 |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1444 | .Lthrow_class_cast_exception: |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1445 | lw $t9, 8($sp) |
| 1446 | lw $a1, 4($sp) |
| 1447 | lw $a0, 0($sp) |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1448 | addiu $sp, $sp, 32 |
| 1449 | .cfi_adjust_cfa_offset -32 |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1450 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1451 | la $t9, artThrowClassCastExceptionForObject |
| 1452 | jalr $zero, $t9 # artThrowClassCastException (Object*, Class*, Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1453 | move $a2, rSELF # pass Thread::Current |
| Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1454 | END art_quick_check_instance_of |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1455 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1456 | /* |
| Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1457 | * Restore rReg's value from offset($sp) if rReg is not the same as rExclude. |
| 1458 | * nReg is the register number for rReg. |
| 1459 | */ |
| 1460 | .macro POP_REG_NE rReg, nReg, offset, rExclude |
| 1461 | .ifnc \rReg, \rExclude |
| 1462 | lw \rReg, \offset($sp) # restore rReg |
| 1463 | .cfi_restore \nReg |
| 1464 | .endif |
| 1465 | .endm |
| 1466 | |
| 1467 | /* |
| 1468 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1469 | * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET. |
| 1470 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1471 | */ |
| 1472 | .macro READ_BARRIER rDest, rObj, offset |
| 1473 | #ifdef USE_READ_BARRIER |
| 1474 | # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment. |
| 1475 | addiu $sp, $sp, -32 |
| 1476 | .cfi_adjust_cfa_offset 32 |
| 1477 | sw $ra, 28($sp) |
| 1478 | .cfi_rel_offset 31, 28 |
| 1479 | sw $t9, 24($sp) |
| 1480 | .cfi_rel_offset 25, 24 |
| 1481 | sw $t1, 20($sp) |
| 1482 | .cfi_rel_offset 9, 20 |
| 1483 | sw $t0, 16($sp) |
| 1484 | .cfi_rel_offset 8, 16 |
| 1485 | sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B) |
| 1486 | .cfi_rel_offset 6, 8 |
| 1487 | sw $a1, 4($sp) |
| 1488 | .cfi_rel_offset 5, 4 |
| 1489 | sw $a0, 0($sp) |
| 1490 | .cfi_rel_offset 4, 0 |
| 1491 | |
| Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1492 | # 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] | 1493 | .ifnc \rObj, $a1 |
| 1494 | move $a1, \rObj # pass rObj |
| 1495 | .endif |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1496 | addiu $a2, $zero, \offset # pass offset |
| 1497 | la $t9, artReadBarrierSlow |
| 1498 | jalr $t9 # artReadBarrierSlow(ref, rObj, offset) |
| Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1499 | addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack |
| 1500 | # before the call to artReadBarrierSlow. |
| 1501 | addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow |
| 1502 | # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning. |
| 1503 | move \rDest, $v0 # save return value in rDest |
| 1504 | # (rDest cannot be v0 in art_quick_aput_obj) |
| 1505 | |
| 1506 | lw $a0, 0($sp) # restore registers except rDest |
| 1507 | # (rDest can only be t0 or t1 in art_quick_aput_obj) |
| 1508 | .cfi_restore 4 |
| 1509 | lw $a1, 4($sp) |
| 1510 | .cfi_restore 5 |
| 1511 | lw $a2, 8($sp) |
| 1512 | .cfi_restore 6 |
| 1513 | POP_REG_NE $t0, 8, 16, \rDest |
| 1514 | POP_REG_NE $t1, 9, 20, \rDest |
| 1515 | lw $t9, 24($sp) |
| 1516 | .cfi_restore 25 |
| 1517 | lw $ra, 28($sp) # restore $ra |
| 1518 | .cfi_restore 31 |
| 1519 | addiu $sp, $sp, 32 |
| 1520 | .cfi_adjust_cfa_offset -32 |
| 1521 | #else |
| 1522 | lw \rDest, \offset(\rObj) |
| 1523 | UNPOISON_HEAP_REF \rDest |
| 1524 | #endif // USE_READ_BARRIER |
| 1525 | .endm |
| 1526 | |
| Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1527 | #ifdef USE_READ_BARRIER |
| 1528 | .extern artReadBarrierSlow |
| 1529 | #endif |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1530 | ENTRY art_quick_aput_obj |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1531 | beqz $a2, .Ldo_aput_null |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1532 | nop |
| Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1533 | READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET |
| 1534 | READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET |
| 1535 | READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1536 | bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1537 | nop |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1538 | .Ldo_aput: |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1539 | sll $a1, $a1, 2 |
| 1540 | add $t0, $a0, $a1 |
| Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1541 | POISON_HEAP_REF $a2 |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1542 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1543 | lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF) |
| Mathieu Chartier | afdcbcb | 2017-04-26 16:43:35 -0700 | [diff] [blame] | 1544 | srl $t1, $a0, CARD_TABLE_CARD_SHIFT |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1545 | add $t1, $t1, $t0 |
| 1546 | sb $t0, ($t1) |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1547 | jalr $zero, $ra |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1548 | nop |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1549 | .Ldo_aput_null: |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1550 | sll $a1, $a1, 2 |
| 1551 | add $t0, $a0, $a1 |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1552 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1553 | jalr $zero, $ra |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1554 | nop |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1555 | .Lcheck_assignability: |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1556 | addiu $sp, $sp, -32 |
| 1557 | .cfi_adjust_cfa_offset 32 |
| 1558 | sw $ra, 28($sp) |
| 1559 | .cfi_rel_offset 31, 28 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1560 | sw $gp, 16($sp) |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1561 | sw $t9, 12($sp) |
| 1562 | sw $a2, 8($sp) |
| 1563 | sw $a1, 4($sp) |
| 1564 | sw $a0, 0($sp) |
| 1565 | move $a1, $t1 |
| 1566 | move $a0, $t0 |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1567 | la $t9, artIsAssignableFromCode |
| 1568 | jalr $t9 # (Class*, Class*) |
| 1569 | addiu $sp, $sp, -16 # reserve argument slots on the stack |
| 1570 | addiu $sp, $sp, 16 |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1571 | lw $ra, 28($sp) |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1572 | lw $gp, 16($sp) |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1573 | lw $t9, 12($sp) |
| 1574 | lw $a2, 8($sp) |
| 1575 | lw $a1, 4($sp) |
| 1576 | lw $a0, 0($sp) |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1577 | addiu $sp, 32 |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1578 | .cfi_adjust_cfa_offset -32 |
| Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1579 | bnez $v0, .Ldo_aput |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1580 | nop |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1581 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1582 | move $a1, $a2 |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1583 | la $t9, artThrowArrayStoreException |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1584 | jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*) |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1585 | move $a2, rSELF # pass Thread::Current |
| Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1586 | END art_quick_aput_obj |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1587 | |
| Alexey Frunze | 0cb1242 | 2017-01-25 19:30:18 -0800 | [diff] [blame] | 1588 | // Macros taking opportunity of code similarities for downcalls. |
| 1589 | .macro ONE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1590 | .extern \entrypoint |
| 1591 | ENTRY \name |
| 1592 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| 1593 | la $t9, \entrypoint |
| 1594 | jalr $t9 # (field_idx, Thread*) |
| 1595 | move $a1, rSELF # pass Thread::Current |
| 1596 | \return # RETURN_IF_NO_EXCEPTION or RETURN_IF_ZERO |
| 1597 | END \name |
| 1598 | .endm |
| 1599 | |
| 1600 | .macro TWO_ARG_REF_DOWNCALL name, entrypoint, return |
| 1601 | .extern \entrypoint |
| 1602 | ENTRY \name |
| 1603 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| 1604 | la $t9, \entrypoint |
| 1605 | jalr $t9 # (field_idx, Object*, Thread*) or |
| 1606 | # (field_idx, new_val, Thread*) |
| 1607 | move $a2, rSELF # pass Thread::Current |
| 1608 | \return # RETURN_IF_NO_EXCEPTION or RETURN_IF_ZERO |
| 1609 | END \name |
| 1610 | .endm |
| 1611 | |
| 1612 | .macro THREE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1613 | .extern \entrypoint |
| 1614 | ENTRY \name |
| 1615 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| 1616 | la $t9, \entrypoint |
| 1617 | jalr $t9 # (field_idx, Object*, new_val, Thread*) |
| 1618 | move $a3, rSELF # pass Thread::Current |
| 1619 | \return # RETURN_IF_NO_EXCEPTION or RETURN_IF_ZERO |
| 1620 | END \name |
| 1621 | .endm |
| 1622 | |
| 1623 | .macro FOUR_ARG_REF_DOWNCALL name, entrypoint, return |
| 1624 | .extern \entrypoint |
| 1625 | ENTRY \name |
| 1626 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| 1627 | la $t9, \entrypoint |
| 1628 | jalr $t9 # (field_idx, Object*, 64-bit new_val, Thread*) or |
| 1629 | # (field_idx, 64-bit new_val, Thread*) |
| 1630 | # Note that a 64-bit new_val needs to be aligned with |
| 1631 | # an even-numbered register, hence A1 may be skipped |
| 1632 | # for new_val to reside in A2-A3. |
| 1633 | sw rSELF, 16($sp) # pass Thread::Current |
| 1634 | \return # RETURN_IF_NO_EXCEPTION or RETURN_IF_ZERO |
| 1635 | END \name |
| 1636 | .endm |
| Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1637 | |
| 1638 | /* |
| Alexey Frunze | 0cb1242 | 2017-01-25 19:30:18 -0800 | [diff] [blame] | 1639 | * Called by managed code to resolve a static/instance field and load/store a value. |
| Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1640 | */ |
| Alexey Frunze | 0cb1242 | 2017-01-25 19:30:18 -0800 | [diff] [blame] | 1641 | ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1642 | ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1643 | ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1644 | ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1645 | ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1646 | ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1647 | ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1648 | TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1649 | TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1650 | TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1651 | TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1652 | TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1653 | TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1654 | TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCompiledCode, RETURN_IF_NO_EXCEPTION |
| 1655 | TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCompiledCode, RETURN_IF_ZERO |
| 1656 | TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCompiledCode, RETURN_IF_ZERO |
| 1657 | TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCompiledCode, RETURN_IF_ZERO |
| 1658 | TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCompiledCode, RETURN_IF_ZERO |
| 1659 | FOUR_ARG_REF_DOWNCALL art_quick_set64_static, artSet64StaticFromCompiledCode, RETURN_IF_ZERO |
| 1660 | THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCompiledCode, RETURN_IF_ZERO |
| 1661 | THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCompiledCode, RETURN_IF_ZERO |
| 1662 | THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCompiledCode, RETURN_IF_ZERO |
| 1663 | THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCompiledCode, RETURN_IF_ZERO |
| 1664 | FOUR_ARG_REF_DOWNCALL art_quick_set64_instance, artSet64InstanceFromCompiledCode, RETURN_IF_ZERO |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1665 | |
| Vladimir Marko | a3c3827 | 2015-04-28 12:37:09 +0100 | [diff] [blame] | 1666 | // Macro to facilitate adding new allocation entrypoints. |
| Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1667 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1668 | .extern \entrypoint |
| 1669 | ENTRY \name |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1670 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1671 | la $t9, \entrypoint |
| 1672 | jalr $t9 |
| Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1673 | move $a1, rSELF # pass Thread::Current |
| 1674 | \return |
| 1675 | END \name |
| 1676 | .endm |
| 1677 | |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1678 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
| 1679 | .extern \entrypoint |
| 1680 | ENTRY \name |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1681 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1682 | la $t9, \entrypoint |
| 1683 | jalr $t9 |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1684 | move $a2, rSELF # pass Thread::Current |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1685 | \return |
| 1686 | END \name |
| 1687 | .endm |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1688 | |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1689 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
| 1690 | .extern \entrypoint |
| 1691 | ENTRY \name |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1692 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1693 | la $t9, \entrypoint |
| 1694 | jalr $t9 |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1695 | move $a3, rSELF # pass Thread::Current |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1696 | \return |
| 1697 | END \name |
| 1698 | .endm |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1699 | |
| Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1700 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1701 | .extern \entrypoint |
| 1702 | ENTRY \name |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1703 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1704 | la $t9, \entrypoint |
| 1705 | jalr $t9 |
| Vladimir Marko | a3c3827 | 2015-04-28 12:37:09 +0100 | [diff] [blame] | 1706 | sw rSELF, 16($sp) # pass Thread::Current |
| Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1707 | \return |
| 1708 | END \name |
| 1709 | .endm |
| 1710 | |
| Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 1711 | // Generate the allocation entrypoints for each allocator. |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1712 | GENERATE_ALLOC_ENTRYPOINTS_FOR_NON_TLAB_ALLOCATORS |
| 1713 | // Comment out allocators that have mips specific asm. |
| 1714 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB) |
| 1715 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_region_tlab, RegionTLAB) |
| 1716 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_region_tlab, RegionTLAB) |
| 1717 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_region_tlab, RegionTLAB) |
| 1718 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED8(_region_tlab, RegionTLAB) |
| 1719 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED16(_region_tlab, RegionTLAB) |
| 1720 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED32(_region_tlab, RegionTLAB) |
| 1721 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED64(_region_tlab, RegionTLAB) |
| 1722 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_BYTES(_region_tlab, RegionTLAB) |
| 1723 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_CHARS(_region_tlab, RegionTLAB) |
| 1724 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_STRING(_region_tlab, RegionTLAB) |
| 1725 | |
| 1726 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB) |
| 1727 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_tlab, TLAB) |
| 1728 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_tlab, TLAB) |
| 1729 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_tlab, TLAB) |
| 1730 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED8(_tlab, TLAB) |
| 1731 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED16(_tlab, TLAB) |
| 1732 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED32(_tlab, TLAB) |
| 1733 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED64(_tlab, TLAB) |
| 1734 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_BYTES(_tlab, TLAB) |
| 1735 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_CHARS(_tlab, TLAB) |
| 1736 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_STRING(_tlab, TLAB) |
| Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1737 | |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1738 | // A hand-written override for: |
| 1739 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc, RosAlloc) |
| 1740 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_rosalloc, RosAlloc) |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1741 | .macro ART_QUICK_ALLOC_OBJECT_ROSALLOC c_name, cxx_name, isInitialized |
| 1742 | ENTRY_NO_GP \c_name |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1743 | # Fast path rosalloc allocation |
| 1744 | # a0: type |
| 1745 | # s1: Thread::Current |
| 1746 | # ----------------------------- |
| 1747 | # t1: object size |
| 1748 | # t2: rosalloc run |
| 1749 | # t3: thread stack top offset |
| 1750 | # t4: thread stack bottom offset |
| 1751 | # v0: free list head |
| 1752 | # |
| 1753 | # t5, t6 : temps |
| 1754 | lw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) # Check if thread local allocation |
| 1755 | lw $t4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1) # stack has any room left. |
| 1756 | bgeu $t3, $t4, .Lslow_path_\c_name |
| Pavle Batuta | 712c59d | 2015-12-02 18:39:01 +0100 | [diff] [blame] | 1757 | |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1758 | lw $t1, MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET($a0) # Load object size (t1). |
| 1759 | li $t5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE # Check if size is for a thread local |
| 1760 | # allocation. Also does the |
| 1761 | # initialized and finalizable checks. |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1762 | # When isInitialized == 0, then the class is potentially not yet initialized. |
| 1763 | # If the class is not yet initialized, the object size will be very large to force the branch |
| 1764 | # below to be taken. |
| 1765 | # |
| 1766 | # See InitializeClassVisitors in class-inl.h for more details. |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1767 | bgtu $t1, $t5, .Lslow_path_\c_name |
| 1768 | |
| 1769 | # Compute the rosalloc bracket index from the size. Since the size is already aligned we can |
| 1770 | # combine the two shifts together. |
| 1771 | srl $t1, $t1, (ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT - POINTER_SIZE_SHIFT) |
| 1772 | |
| 1773 | addu $t2, $t1, $s1 |
| 1774 | lw $t2, (THREAD_ROSALLOC_RUNS_OFFSET - __SIZEOF_POINTER__)($t2) # Load rosalloc run (t2). |
| 1775 | |
| 1776 | # Load the free list head (v0). |
| 1777 | # NOTE: this will be the return val. |
| 1778 | lw $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2) |
| 1779 | beqz $v0, .Lslow_path_\c_name |
| 1780 | nop |
| 1781 | |
| 1782 | # Load the next pointer of the head and update the list head with the next pointer. |
| 1783 | lw $t5, ROSALLOC_SLOT_NEXT_OFFSET($v0) |
| 1784 | sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2) |
| 1785 | |
| 1786 | # Store the class pointer in the header. This also overwrites the first pointer. The offsets are |
| 1787 | # asserted to match. |
| 1788 | |
| 1789 | #if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET |
| 1790 | #error "Class pointer needs to overwrite next pointer." |
| 1791 | #endif |
| 1792 | |
| 1793 | POISON_HEAP_REF $a0 |
| 1794 | sw $a0, MIRROR_OBJECT_CLASS_OFFSET($v0) |
| 1795 | |
| 1796 | # Push the new object onto the thread local allocation stack and increment the thread local |
| 1797 | # allocation stack top. |
| 1798 | sw $v0, 0($t3) |
| 1799 | addiu $t3, $t3, COMPRESSED_REFERENCE_SIZE |
| 1800 | sw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) |
| 1801 | |
| 1802 | # Decrement the size of the free list. |
| 1803 | lw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2) |
| 1804 | addiu $t5, $t5, -1 |
| 1805 | sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2) |
| 1806 | |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1807 | .if \isInitialized == 0 |
| 1808 | # This barrier is only necessary when the allocation also requires a class initialization check. |
| 1809 | # |
| 1810 | # If the class is already observably initialized, then new-instance allocations are protected |
| 1811 | # from publishing by the compiler which inserts its own StoreStore barrier. |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1812 | sync # Fence. |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1813 | .endif |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1814 | jalr $zero, $ra |
| 1815 | nop |
| 1816 | |
| 1817 | .Lslow_path_\c_name: |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1818 | addiu $t9, $t9, (.Lslow_path_\c_name - \c_name) + 4 |
| 1819 | .cpload $t9 |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1820 | SETUP_SAVE_REFS_ONLY_FRAME |
| 1821 | la $t9, \cxx_name |
| 1822 | jalr $t9 |
| 1823 | move $a1, $s1 # Pass self as argument. |
| 1824 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1825 | END \c_name |
| 1826 | .endm |
| 1827 | |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1828 | ART_QUICK_ALLOC_OBJECT_ROSALLOC art_quick_alloc_object_resolved_rosalloc, artAllocObjectFromCodeResolvedRosAlloc, /* isInitialized */ 0 |
| 1829 | ART_QUICK_ALLOC_OBJECT_ROSALLOC art_quick_alloc_object_initialized_rosalloc, artAllocObjectFromCodeInitializedRosAlloc, /* isInitialized */ 1 |
| Goran Jakovljevic | 2449e5c | 2017-01-19 11:39:18 +0100 | [diff] [blame] | 1830 | |
| Goran Jakovljevic | 854df41 | 2017-06-27 14:41:39 +0200 | [diff] [blame] | 1831 | // The common fast path code for art_quick_alloc_object_resolved/initialized_tlab |
| 1832 | // and art_quick_alloc_object_resolved/initialized_region_tlab. |
| 1833 | // |
| 1834 | // a0: type, s1(rSELF): Thread::Current. |
| 1835 | // Need to preserve a0 to the slow path. |
| 1836 | // |
| 1837 | // If isInitialized=1 then the compiler assumes the object's class has already been initialized. |
| 1838 | // If isInitialized=0 the compiler can only assume it's been at least resolved. |
| 1839 | .macro ALLOC_OBJECT_RESOLVED_TLAB_FAST_PATH slowPathLabel isInitialized |
| 1840 | lw $v0, THREAD_LOCAL_POS_OFFSET(rSELF) # Load thread_local_pos. |
| 1841 | lw $a2, THREAD_LOCAL_END_OFFSET(rSELF) # Load thread_local_end. |
| 1842 | subu $a3, $a2, $v0 # Compute the remaining buffer size. |
| 1843 | lw $t0, MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET($a0) # Load the object size. |
| 1844 | |
| 1845 | # When isInitialized == 0, then the class is potentially not yet initialized. |
| 1846 | # If the class is not yet initialized, the object size will be very large to force the branch |
| 1847 | # below to be taken. |
| 1848 | # |
| 1849 | # See InitializeClassVisitors in class-inl.h for more details. |
| 1850 | bgtu $t0, $a3, \slowPathLabel # Check if it fits. |
| 1851 | addu $t1, $v0, $t0 # Add object size to tlab pos (in branch |
| 1852 | # delay slot). |
| 1853 | # "Point of no slow path". Won't go to the slow path from here on. |
| 1854 | sw $t1, THREAD_LOCAL_POS_OFFSET(rSELF) # Store new thread_local_pos. |
| 1855 | lw $a2, THREAD_LOCAL_OBJECTS_OFFSET(rSELF) # Increment thread_local_objects. |
| 1856 | addiu $a2, $a2, 1 |
| 1857 | sw $a2, THREAD_LOCAL_OBJECTS_OFFSET(rSELF) |
| 1858 | POISON_HEAP_REF $a0 |
| 1859 | sw $a0, MIRROR_OBJECT_CLASS_OFFSET($v0) # Store the class pointer. |
| 1860 | |
| 1861 | .if \isInitialized == 0 |
| 1862 | # This barrier is only necessary when the allocation also requires a class initialization check. |
| 1863 | # |
| 1864 | # If the class is already observably initialized, then new-instance allocations are protected |
| 1865 | # from publishing by the compiler which inserts its own StoreStore barrier. |
| 1866 | sync # Fence. |
| 1867 | .endif |
| 1868 | jalr $zero, $ra |
| 1869 | nop |
| 1870 | .endm |
| 1871 | |
| 1872 | // The common code for art_quick_alloc_object_resolved/initialized_tlab |
| 1873 | // and art_quick_alloc_object_resolved/initialized_region_tlab. |
| 1874 | .macro GENERATE_ALLOC_OBJECT_TLAB name, entrypoint, isInitialized |
| 1875 | ENTRY_NO_GP \name |
| 1876 | # Fast path tlab allocation. |
| 1877 | # a0: type, s1(rSELF): Thread::Current. |
| 1878 | ALLOC_OBJECT_RESOLVED_TLAB_FAST_PATH .Lslow_path_\name, \isInitialized |
| 1879 | .Lslow_path_\name: |
| 1880 | addiu $t9, $t9, (.Lslow_path_\name - \name) + 4 |
| 1881 | .cpload $t9 |
| 1882 | SETUP_SAVE_REFS_ONLY_FRAME # Save callee saves in case of GC. |
| 1883 | la $t9, \entrypoint |
| 1884 | jalr $t9 # (mirror::Class*, Thread*) |
| 1885 | move $a1, rSELF # Pass Thread::Current. |
| 1886 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1887 | END \name |
| 1888 | .endm |
| 1889 | |
| 1890 | GENERATE_ALLOC_OBJECT_TLAB art_quick_alloc_object_resolved_region_tlab, artAllocObjectFromCodeResolvedRegionTLAB, /* isInitialized */ 0 |
| 1891 | GENERATE_ALLOC_OBJECT_TLAB art_quick_alloc_object_initialized_region_tlab, artAllocObjectFromCodeInitializedRegionTLAB, /* isInitialized */ 1 |
| 1892 | GENERATE_ALLOC_OBJECT_TLAB art_quick_alloc_object_resolved_tlab, artAllocObjectFromCodeResolvedTLAB, /* isInitialized */ 0 |
| 1893 | GENERATE_ALLOC_OBJECT_TLAB art_quick_alloc_object_initialized_tlab, artAllocObjectFromCodeInitializedTLAB, /* isInitialized */ 1 |
| 1894 | |
| 1895 | // The common fast path code for art_quick_alloc_array_resolved/initialized_tlab |
| 1896 | // and art_quick_alloc_array_resolved/initialized_region_tlab. |
| 1897 | // |
| 1898 | // a0: type, a1: component_count, a2: total_size, s1(rSELF): Thread::Current. |
| 1899 | // Need to preserve a0 and a1 to the slow path. |
| 1900 | .macro ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED_WITH_SIZE slowPathLabel |
| 1901 | li $a3, OBJECT_ALIGNMENT_MASK_TOGGLED # Apply alignemnt mask |
| 1902 | and $a2, $a2, $a3 # (addr + 7) & ~7. |
| 1903 | |
| 1904 | lw $v0, THREAD_LOCAL_POS_OFFSET(rSELF) # Load thread_local_pos. |
| 1905 | lw $t1, THREAD_LOCAL_END_OFFSET(rSELF) # Load thread_local_end. |
| 1906 | subu $t2, $t1, $v0 # Compute the remaining buffer size. |
| 1907 | bgtu $a2, $t2, \slowPathLabel # Check if it fits. |
| 1908 | addu $a2, $v0, $a2 # Add object size to tlab pos (in branch |
| 1909 | # delay slot). |
| 1910 | |
| 1911 | # "Point of no slow path". Won't go to the slow path from here on. |
| 1912 | sw $a2, THREAD_LOCAL_POS_OFFSET(rSELF) # Store new thread_local_pos. |
| 1913 | lw $a2, THREAD_LOCAL_OBJECTS_OFFSET(rSELF) # Increment thread_local_objects. |
| 1914 | addiu $a2, $a2, 1 |
| 1915 | sw $a2, THREAD_LOCAL_OBJECTS_OFFSET(rSELF) |
| 1916 | POISON_HEAP_REF $a0 |
| 1917 | sw $a0, MIRROR_OBJECT_CLASS_OFFSET($v0) # Store the class pointer. |
| 1918 | jalr $zero, $ra |
| 1919 | sw $a1, MIRROR_ARRAY_LENGTH_OFFSET($v0) # Store the array length. |
| 1920 | .endm |
| 1921 | |
| 1922 | .macro GENERATE_ALLOC_ARRAY_TLAB name, entrypoint, size_setup |
| 1923 | ENTRY_NO_GP \name |
| 1924 | # Fast path array allocation for region tlab allocation. |
| 1925 | # a0: mirror::Class* type |
| 1926 | # a1: int32_t component_count |
| 1927 | # s1(rSELF): Thread::Current |
| 1928 | \size_setup .Lslow_path_\name |
| 1929 | ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED_WITH_SIZE .Lslow_path_\name |
| 1930 | .Lslow_path_\name: |
| 1931 | # a0: mirror::Class* type |
| 1932 | # a1: int32_t component_count |
| 1933 | # a2: Thread* self |
| 1934 | addiu $t9, $t9, (.Lslow_path_\name - \name) + 4 |
| 1935 | .cpload $t9 |
| 1936 | SETUP_SAVE_REFS_ONLY_FRAME # Save callee saves in case of GC. |
| 1937 | la $t9, \entrypoint |
| 1938 | jalr $t9 |
| 1939 | move $a2, rSELF # Pass Thread::Current. |
| 1940 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1941 | END \name |
| 1942 | .endm |
| 1943 | |
| 1944 | .macro COMPUTE_ARRAY_SIZE_UNKNOWN slow_path |
| 1945 | break # We should never enter here. |
| 1946 | # Code below is for reference. |
| 1947 | # Possibly a large object, go slow. |
| 1948 | # Also does negative array size check. |
| 1949 | li $a2, ((MIN_LARGE_OBJECT_THRESHOLD - MIRROR_WIDE_ARRAY_DATA_OFFSET) / 8) |
| 1950 | bgtu $a1, $a2, \slow_path |
| 1951 | # Array classes are never finalizable |
| 1952 | # or uninitialized, no need to check. |
| 1953 | lw $a3, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($a0) # Load component type. |
| 1954 | UNPOISON_HEAP_REF $a3 |
| 1955 | lw $a3, MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET($a3) |
| 1956 | srl $a3, $a3, PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT # Component size shift is in high 16 bits. |
| 1957 | sllv $a2, $a1, $a3 # Calculate data size. |
| 1958 | # Add array data offset and alignment. |
| 1959 | addiu $a2, $a2, (MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1960 | #if MIRROR_WIDE_ARRAY_DATA_OFFSET != MIRROR_INT_ARRAY_DATA_OFFSET + 4 |
| 1961 | #error Long array data offset must be 4 greater than int array data offset. |
| 1962 | #endif |
| 1963 | |
| 1964 | addiu $a3, $a3, 1 # Add 4 to the length only if the component |
| 1965 | andi $a3, $a3, 4 # size shift is 3 (for 64 bit alignment). |
| 1966 | addu $a2, $a2, $a3 |
| 1967 | .endm |
| 1968 | |
| 1969 | .macro COMPUTE_ARRAY_SIZE_8 slow_path |
| 1970 | # Possibly a large object, go slow. |
| 1971 | # Also does negative array size check. |
| 1972 | li $a2, (MIN_LARGE_OBJECT_THRESHOLD - MIRROR_INT_ARRAY_DATA_OFFSET) |
| 1973 | bgtu $a1, $a2, \slow_path |
| 1974 | # Add array data offset and alignment (in branch delay slot). |
| 1975 | addiu $a2, $a1, (MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1976 | .endm |
| 1977 | |
| 1978 | .macro COMPUTE_ARRAY_SIZE_16 slow_path |
| 1979 | # Possibly a large object, go slow. |
| 1980 | # Also does negative array size check. |
| 1981 | li $a2, ((MIN_LARGE_OBJECT_THRESHOLD - MIRROR_INT_ARRAY_DATA_OFFSET) / 2) |
| 1982 | bgtu $a1, $a2, \slow_path |
| 1983 | sll $a2, $a1, 1 |
| 1984 | # Add array data offset and alignment. |
| 1985 | addiu $a2, $a2, (MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1986 | .endm |
| 1987 | |
| 1988 | .macro COMPUTE_ARRAY_SIZE_32 slow_path |
| 1989 | # Possibly a large object, go slow. |
| 1990 | # Also does negative array size check. |
| 1991 | li $a2, ((MIN_LARGE_OBJECT_THRESHOLD - MIRROR_INT_ARRAY_DATA_OFFSET) / 4) |
| 1992 | bgtu $a1, $a2, \slow_path |
| 1993 | sll $a2, $a1, 2 |
| 1994 | # Add array data offset and alignment. |
| 1995 | addiu $a2, $a2, (MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1996 | .endm |
| 1997 | |
| 1998 | .macro COMPUTE_ARRAY_SIZE_64 slow_path |
| 1999 | # Possibly a large object, go slow. |
| 2000 | # Also does negative array size check. |
| 2001 | li $a2, ((MIN_LARGE_OBJECT_THRESHOLD - MIRROR_LONG_ARRAY_DATA_OFFSET) / 8) |
| 2002 | bgtu $a1, $a2, \slow_path |
| 2003 | sll $a2, $a1, 3 |
| 2004 | # Add array data offset and alignment. |
| 2005 | addiu $a2, $a2, (MIRROR_WIDE_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 2006 | .endm |
| 2007 | |
| 2008 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_UNKNOWN |
| 2009 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved8_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_8 |
| 2010 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved16_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_16 |
| 2011 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved32_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_32 |
| 2012 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved64_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_64 |
| 2013 | |
| 2014 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_UNKNOWN |
| 2015 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved8_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_8 |
| 2016 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved16_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_16 |
| 2017 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved32_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_32 |
| 2018 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved64_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_64 |
| Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 2019 | |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2020 | // Macro for string and type resolution and initialization. |
| 2021 | // $a0 is both input and output. |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2022 | .macro ONE_ARG_SAVE_EVERYTHING_DOWNCALL name, entrypoint, runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2023 | .extern \entrypoint |
| 2024 | ENTRY_NO_GP \name |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2025 | SETUP_SAVE_EVERYTHING_FRAME \runtime_method_offset # Save everything in case of GC. |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2026 | move $s2, $gp # Preserve $gp across the call for exception delivery. |
| 2027 | la $t9, \entrypoint |
| 2028 | jalr $t9 # (uint32_t index, Thread*) |
| 2029 | move $a1, rSELF # Pass Thread::Current (in delay slot). |
| 2030 | beqz $v0, 1f # Success? |
| 2031 | move $a0, $v0 # Move result to $a0 (in delay slot). |
| 2032 | RESTORE_SAVE_EVERYTHING_FRAME 0 # Restore everything except $a0. |
| 2033 | jalr $zero, $ra # Return on success. |
| 2034 | nop |
| 2035 | 1: |
| 2036 | move $gp, $s2 |
| 2037 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 2038 | END \name |
| 2039 | .endm |
| 2040 | |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2041 | .macro ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT name, entrypoint |
| 2042 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL \name, \entrypoint, RUNTIME_SAVE_EVERYTHING_FOR_CLINIT_METHOD_OFFSET |
| 2043 | .endm |
| 2044 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2045 | /* |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2046 | * Entry from managed code to resolve a string, this stub will allocate a String and deliver an |
| Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 2047 | * exception on error. On success the String is returned. A0 holds the string index. The fast |
| 2048 | * path check for hit in strings cache has already been performed. |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2049 | */ |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2050 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL art_quick_resolve_string, artResolveStringFromCode |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2051 | |
| 2052 | /* |
| 2053 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 2054 | * initializer and deliver the exception on error. On success the static storage base is |
| 2055 | * returned. |
| 2056 | */ |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2057 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT art_quick_initialize_static_storage, artInitializeStaticStorageFromCode |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2058 | |
| 2059 | /* |
| 2060 | * Entry from managed code when dex cache misses for a type_idx. |
| 2061 | */ |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2062 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT art_quick_initialize_type, artInitializeTypeFromCode |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2063 | |
| 2064 | /* |
| 2065 | * Entry from managed code when type_idx needs to be checked for access and dex cache may also |
| 2066 | * miss. |
| 2067 | */ |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2068 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode |
| Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 2069 | |
| 2070 | /* |
| Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 2071 | * Called by managed code when the value in rSUSPEND has been decremented to 0. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2072 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2073 | .extern artTestSuspendFromCode |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 2074 | ENTRY_NO_GP art_quick_test_suspend |
| Alexey Frunze | 19428ad | 2017-08-03 10:36:46 -0700 | [diff] [blame] | 2075 | SETUP_SAVE_EVERYTHING_FRAME RUNTIME_SAVE_EVERYTHING_FOR_SUSPEND_CHECK_METHOD_OFFSET |
| 2076 | # save everything for stack crawl |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2077 | la $t9, artTestSuspendFromCode |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 2078 | jalr $t9 # (Thread*) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2079 | move $a0, rSELF |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2080 | RESTORE_SAVE_EVERYTHING_FRAME |
| Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 2081 | jalr $zero, $ra |
| 2082 | nop |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2083 | END art_quick_test_suspend |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2084 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2085 | /* |
| 2086 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2087 | * a0 holds the proxy method; a1, a2 and a3 may contain arguments. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2088 | */ |
| Jeff Hao | 5fa60c3 | 2013-04-04 17:57:01 -0700 | [diff] [blame] | 2089 | .extern artQuickProxyInvokeHandler |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2090 | ENTRY art_quick_proxy_invoke_handler |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2091 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2092 | move $a2, rSELF # pass Thread::Current |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2093 | la $t9, artQuickProxyInvokeHandler |
| 2094 | jalr $t9 # (Method* proxy method, receiver, Thread*, SP) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2095 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2096 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2097 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2098 | bnez $t7, 1f |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2099 | # don't care if $v0 and/or $v1 are modified, when exception branch taken |
| 2100 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2101 | jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2102 | nop |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2103 | 1: |
| 2104 | DELIVER_PENDING_EXCEPTION |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2105 | END art_quick_proxy_invoke_handler |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2106 | |
| Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 2107 | /* |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2108 | * Called to resolve an imt conflict. |
| 2109 | * a0 is the conflict ArtMethod. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2110 | * t7 is a hidden argument that holds the target interface method's dex method index. |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2111 | * |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2112 | * Note that this stub writes to v0-v1, a0, t2-t9, f0-f7. |
| Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 2113 | */ |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2114 | .extern artLookupResolvedMethod |
| 2115 | .extern __atomic_load_8 # For int64_t std::atomic::load(std::memory_order). |
| Douglas Leung | 13738bf | 2014-10-27 14:44:47 -0700 | [diff] [blame] | 2116 | ENTRY art_quick_imt_conflict_trampoline |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2117 | SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY /* save_s4_thru_s8 */ 0 |
| 2118 | |
| 2119 | lw $t8, FRAME_SIZE_SAVE_REFS_AND_ARGS($sp) # $t8 = referrer. |
| Vladimir Marko | 5122e6b | 2017-08-17 16:10:09 +0100 | [diff] [blame] | 2120 | // If the method is obsolete, just go through the dex cache miss slow path. |
| 2121 | // The obsolete flag is set with suspended threads, so we do not need an acquire operation here. |
| 2122 | lw $t9, ART_METHOD_ACCESS_FLAGS_OFFSET($t8) # $t9 = access flags. |
| 2123 | sll $t9, $t9, 31 - ACC_OBSOLETE_METHOD_SHIFT # Move obsolete method bit to sign bit. |
| 2124 | bltz $t9, .Limt_conflict_trampoline_dex_cache_miss |
| 2125 | lw $t8, ART_METHOD_DECLARING_CLASS_OFFSET($t8) # $t8 = declaring class (no read barrier). |
| 2126 | lw $t8, MIRROR_CLASS_DEX_CACHE_OFFSET($t8) # $t8 = dex cache (without read barrier). |
| 2127 | UNPOISON_HEAP_REF $t8 |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2128 | la $t9, __atomic_load_8 |
| 2129 | addiu $sp, $sp, -ARG_SLOT_SIZE # Reserve argument slots on the stack. |
| 2130 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| Vladimir Marko | 5122e6b | 2017-08-17 16:10:09 +0100 | [diff] [blame] | 2131 | lw $t8, MIRROR_DEX_CACHE_RESOLVED_METHODS_OFFSET($t8) # $t8 = dex cache methods array. |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2132 | |
| 2133 | move $s2, $t7 # $s2 = method index (callee-saved). |
| 2134 | lw $s3, ART_METHOD_JNI_OFFSET_32($a0) # $s3 = ImtConflictTable (callee-saved). |
| 2135 | |
| 2136 | sll $t7, $t7, 32 - METHOD_DEX_CACHE_HASH_BITS # $t7 = slot index in top bits, zeroes below. |
| 2137 | srl $t7, $t7, 32 - METHOD_DEX_CACHE_HASH_BITS - (POINTER_SIZE_SHIFT + 1) |
| 2138 | # $t7 = slot offset. |
| 2139 | |
| 2140 | li $a1, STD_MEMORY_ORDER_RELAXED # $a1 = std::memory_order_relaxed. |
| 2141 | jalr $t9 # [$v0, $v1] = __atomic_load_8($a0, $a1). |
| 2142 | addu $a0, $t8, $t7 # $a0 = DexCache method slot address. |
| 2143 | |
| 2144 | bne $v1, $s2, .Limt_conflict_trampoline_dex_cache_miss # Branch if method index miss. |
| 2145 | addiu $sp, $sp, ARG_SLOT_SIZE # Remove argument slots from the stack. |
| 2146 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2147 | |
| 2148 | .Limt_table_iterate: |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2149 | lw $t8, 0($s3) # Load next entry in ImtConflictTable. |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2150 | # Branch if found. |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2151 | beq $t8, $v0, .Limt_table_found |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2152 | nop |
| 2153 | # If the entry is null, the interface method is not in the ImtConflictTable. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2154 | beqz $t8, .Lconflict_trampoline |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2155 | nop |
| 2156 | # Iterate over the entries of the ImtConflictTable. |
| 2157 | b .Limt_table_iterate |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2158 | addiu $s3, $s3, 2 * __SIZEOF_POINTER__ # Iterate to the next entry. |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2159 | |
| 2160 | .Limt_table_found: |
| 2161 | # We successfully hit an entry in the table. Load the target method and jump to it. |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2162 | .cfi_remember_state |
| 2163 | lw $a0, __SIZEOF_POINTER__($s3) |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2164 | lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2165 | RESTORE_SAVE_REFS_AND_ARGS_FRAME /* restore_s4_thru_s8 */ 0, /* remove_arg_slots */ 0 |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2166 | jalr $zero, $t9 |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2167 | nop |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2168 | .cfi_restore_state |
| Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2169 | |
| 2170 | .Lconflict_trampoline: |
| 2171 | # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method. |
| Alexey Frunze | 279cfba | 2017-07-22 00:24:43 -0700 | [diff] [blame] | 2172 | .cfi_remember_state |
| 2173 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_GP # Restore clobbered $gp. |
| 2174 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_A1 # Restore this. |
| 2175 | move $a0, $v0 # Load interface method. |
| 2176 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline, /* save_s4_thru_s8_only */ 1 |
| 2177 | .cfi_restore_state |
| 2178 | |
| 2179 | .Limt_conflict_trampoline_dex_cache_miss: |
| 2180 | # We're not creating a proper runtime method frame here, |
| 2181 | # artLookupResolvedMethod() is not allowed to walk the stack. |
| 2182 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_GP # Restore clobbered $gp. |
| 2183 | lw $a1, FRAME_SIZE_SAVE_REFS_AND_ARGS($sp) # $a1 = referrer. |
| 2184 | la $t9, artLookupResolvedMethod |
| 2185 | addiu $sp, $sp, -ARG_SLOT_SIZE # Reserve argument slots on the stack. |
| 2186 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| 2187 | jalr $t9 # (uint32_t method_index, ArtMethod* referrer). |
| 2188 | move $a0, $s2 # $a0 = method index. |
| 2189 | |
| 2190 | # If the method wasn't resolved, skip the lookup and go to artInvokeInterfaceTrampoline(). |
| 2191 | beqz $v0, .Lconflict_trampoline |
| 2192 | addiu $sp, $sp, ARG_SLOT_SIZE # Remove argument slots from the stack. |
| 2193 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 2194 | |
| 2195 | b .Limt_table_iterate |
| 2196 | nop |
| Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 2197 | END art_quick_imt_conflict_trampoline |
| 2198 | |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2199 | .extern artQuickResolutionTrampoline |
| 2200 | ENTRY art_quick_resolution_trampoline |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2201 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2202 | move $a2, rSELF # pass Thread::Current |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2203 | la $t9, artQuickResolutionTrampoline |
| 2204 | jalr $t9 # (Method* called, receiver, Thread*, SP) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2205 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2206 | beqz $v0, 1f |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2207 | lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0 |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2208 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Ian Rogers | 65d1b22 | 2013-09-27 10:59:41 -0700 | [diff] [blame] | 2209 | move $t9, $v0 # code pointer must be in $t9 to generate the global pointer |
| Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 2210 | jalr $zero, $t9 # tail call to method |
| Mathieu Chartier | 1984152 | 2013-10-22 11:29:00 -0700 | [diff] [blame] | 2211 | nop |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2212 | 1: |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2213 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2214 | DELIVER_PENDING_EXCEPTION |
| 2215 | END art_quick_resolution_trampoline |
| 2216 | |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2217 | .extern artQuickGenericJniTrampoline |
| 2218 | .extern artQuickGenericJniEndTrampoline |
| 2219 | ENTRY art_quick_generic_jni_trampoline |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2220 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2221 | move $s8, $sp # save $sp to $s8 |
| 2222 | move $s3, $gp # save $gp to $s3 |
| 2223 | |
| 2224 | # prepare for call to artQuickGenericJniTrampoline(Thread*, SP) |
| 2225 | move $a0, rSELF # pass Thread::Current |
| 2226 | addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots) |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2227 | la $t9, artQuickGenericJniTrampoline |
| 2228 | jalr $t9 # (Thread*, SP) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2229 | addiu $sp, $sp, -5120 # reserve space on the stack |
| 2230 | |
| 2231 | # The C call will have registered the complete save-frame on success. |
| 2232 | # The result of the call is: |
| 2233 | # v0: ptr to native code, 0 on error. |
| 2234 | # v1: ptr to the bottom of the used area of the alloca, can restore stack till here. |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2235 | beq $v0, $zero, 2f # check entry error |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2236 | move $t9, $v0 # save the code ptr |
| 2237 | move $sp, $v1 # release part of the alloca |
| 2238 | |
| 2239 | # Load parameters from stack into registers |
| 2240 | lw $a0, 0($sp) |
| 2241 | lw $a1, 4($sp) |
| 2242 | lw $a2, 8($sp) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2243 | lw $a3, 12($sp) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2244 | |
| 2245 | # artQuickGenericJniTrampoline sets bit 0 of the native code address to 1 |
| 2246 | # when the first two arguments are both single precision floats. This lets |
| 2247 | # us extract them properly from the stack and load into floating point |
| 2248 | # registers. |
| 2249 | MTD $a0, $a1, $f12, $f13 |
| 2250 | andi $t0, $t9, 1 |
| 2251 | xor $t9, $t9, $t0 |
| 2252 | bnez $t0, 1f |
| 2253 | mtc1 $a1, $f14 |
| 2254 | MTD $a2, $a3, $f14, $f15 |
| 2255 | |
| 2256 | 1: |
| 2257 | jalr $t9 # native call |
| 2258 | nop |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2259 | addiu $sp, $sp, 16 # remove arg slots |
| 2260 | |
| 2261 | move $gp, $s3 # restore $gp from $s3 |
| 2262 | |
| 2263 | # result sign extension is handled in C code |
| 2264 | # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f) |
| 2265 | move $a0, rSELF # pass Thread::Current |
| 2266 | move $a2, $v0 # pass result |
| 2267 | move $a3, $v1 |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 2268 | addiu $sp, $sp, -32 # reserve arg slots |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2269 | la $t9, artQuickGenericJniEndTrampoline |
| 2270 | jalr $t9 |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2271 | s.d $f0, 16($sp) # pass result_f |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2272 | |
| 2273 | lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2274 | bne $t0, $zero, 2f # check for pending exceptions |
| Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2275 | |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2276 | move $sp, $s8 # tear down the alloca |
| 2277 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2278 | # tear down the callee-save frame |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2279 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2280 | |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2281 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2282 | jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2283 | nop |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2284 | |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2285 | 2: |
| Alexey Frunze | c61c076 | 2017-04-10 13:54:23 -0700 | [diff] [blame] | 2286 | lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) |
| 2287 | move $gp, $s3 # restore $gp from $s3 |
| Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2288 | # This will create a new save-all frame, required by the runtime. |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2289 | DELIVER_PENDING_EXCEPTION |
| 2290 | END art_quick_generic_jni_trampoline |
| Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 2291 | |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2292 | .extern artQuickToInterpreterBridge |
| 2293 | ENTRY art_quick_to_interpreter_bridge |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2294 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2295 | move $a1, rSELF # pass Thread::Current |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2296 | la $t9, artQuickToInterpreterBridge |
| 2297 | jalr $t9 # (Method* method, Thread*, SP) |
| Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2298 | addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2299 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2300 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2301 | bnez $t7, 1f |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2302 | # don't care if $v0 and/or $v1 are modified, when exception branch taken |
| 2303 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2304 | jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2305 | nop |
| Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 2306 | 1: |
| 2307 | DELIVER_PENDING_EXCEPTION |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2308 | END art_quick_to_interpreter_bridge |
| Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 2309 | |
| Alex Light | db01a09 | 2017-04-03 15:39:55 -0700 | [diff] [blame] | 2310 | .extern artInvokeObsoleteMethod |
| 2311 | ENTRY art_invoke_obsolete_method_stub |
| 2312 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| 2313 | la $t9, artInvokeObsoleteMethod |
| 2314 | jalr $t9 # (Method* method, Thread* self) |
| 2315 | move $a1, rSELF # pass Thread::Current |
| 2316 | END art_invoke_obsolete_method_stub |
| 2317 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2318 | /* |
| jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame] | 2319 | * Routine that intercepts method calls and returns. |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2320 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2321 | .extern artInstrumentationMethodEntryFromCode |
| 2322 | .extern artInstrumentationMethodExitFromCode |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2323 | ENTRY art_quick_instrumentation_entry |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2324 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
| Alexey Frunze | 60454cb | 2017-08-09 21:28:30 -0700 | [diff] [blame] | 2325 | sw $a0, 28($sp) # save arg0 in free arg slot |
| 2326 | addiu $a3, $sp, ARG_SLOT_SIZE # Pass $sp. |
| 2327 | la $t9, artInstrumentationMethodEntryFromCode |
| 2328 | jalr $t9 # (Method*, Object*, Thread*, SP) |
| 2329 | move $a2, rSELF # pass Thread::Current |
| 2330 | beqz $v0, .Ldeliver_instrumentation_entry_exception |
| 2331 | move $t9, $v0 # $t9 holds reference to code |
| 2332 | lw $a0, 28($sp) # restore arg0 from free arg slot |
| Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2333 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Alexey Frunze | 60454cb | 2017-08-09 21:28:30 -0700 | [diff] [blame] | 2334 | la $ra, art_quick_instrumentation_exit |
| 2335 | jalr $zero, $t9 # call method, returning to art_quick_instrumentation_exit |
| Goran Jakovljevic | 25e4d1e | 2017-06-14 13:47:44 +0200 | [diff] [blame] | 2336 | nop |
| 2337 | .Ldeliver_instrumentation_entry_exception: |
| Goran Jakovljevic | 25e4d1e | 2017-06-14 13:47:44 +0200 | [diff] [blame] | 2338 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| Goran Jakovljevic | 25e4d1e | 2017-06-14 13:47:44 +0200 | [diff] [blame] | 2339 | DELIVER_PENDING_EXCEPTION |
| Alexey Frunze | 60454cb | 2017-08-09 21:28:30 -0700 | [diff] [blame] | 2340 | END art_quick_instrumentation_entry |
| 2341 | |
| 2342 | ENTRY_NO_GP art_quick_instrumentation_exit |
| 2343 | move $ra, $zero # RA points here, so clobber with 0 for later checks. |
| 2344 | SETUP_SAVE_EVERYTHING_FRAME # Allocates ARG_SLOT_SIZE bytes at the bottom of the stack. |
| 2345 | move $s2, $gp # Preserve $gp across the call for exception delivery. |
| 2346 | |
| 2347 | addiu $a3, $sp, ARG_SLOT_SIZE+16 # Pass fpr_res pointer ($f0 in SAVE_EVERYTHING_FRAME). |
| 2348 | addiu $a2, $sp, ARG_SLOT_SIZE+148 # Pass gpr_res pointer ($v0 in SAVE_EVERYTHING_FRAME). |
| 2349 | addiu $a1, $sp, ARG_SLOT_SIZE # Pass $sp. |
| 2350 | la $t9, artInstrumentationMethodExitFromCode |
| 2351 | jalr $t9 # (Thread*, SP, gpr_res*, fpr_res*) |
| 2352 | move $a0, rSELF # Pass Thread::Current. |
| 2353 | |
| 2354 | beqz $v0, .Ldo_deliver_instrumentation_exception |
| 2355 | move $gp, $s2 # Deliver exception if we got nullptr as function. |
| 2356 | bnez $v1, .Ldeoptimize |
| 2357 | |
| 2358 | # Normal return. |
| 2359 | sw $v0, (ARG_SLOT_SIZE+FRAME_SIZE_SAVE_EVERYTHING-4)($sp) # Set return pc. |
| 2360 | RESTORE_SAVE_EVERYTHING_FRAME |
| 2361 | jalr $zero, $ra |
| 2362 | nop |
| 2363 | .Ldo_deliver_instrumentation_exception: |
| 2364 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 2365 | .Ldeoptimize: |
| 2366 | b art_quick_deoptimize |
| 2367 | sw $v1, (ARG_SLOT_SIZE+FRAME_SIZE_SAVE_EVERYTHING-4)($sp) |
| 2368 | # Fake a call from instrumentation return pc. |
| Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2369 | END art_quick_instrumentation_exit |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2370 | |
| jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2371 | /* |
| Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 2372 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 2373 | * will long jump to the upcall with a special exception of -1. |
| jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2374 | */ |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2375 | .extern artDeoptimize |
| Alexey Frunze | 60454cb | 2017-08-09 21:28:30 -0700 | [diff] [blame] | 2376 | ENTRY_NO_GP_CUSTOM_CFA art_quick_deoptimize, ARG_SLOT_SIZE+FRAME_SIZE_SAVE_EVERYTHING |
| 2377 | # SETUP_SAVE_EVERYTHING_FRAME has been done by art_quick_instrumentation_exit. |
| 2378 | .cfi_rel_offset 31, ARG_SLOT_SIZE+252 |
| 2379 | .cfi_rel_offset 30, ARG_SLOT_SIZE+248 |
| 2380 | .cfi_rel_offset 28, ARG_SLOT_SIZE+244 |
| 2381 | .cfi_rel_offset 25, ARG_SLOT_SIZE+240 |
| 2382 | .cfi_rel_offset 24, ARG_SLOT_SIZE+236 |
| 2383 | .cfi_rel_offset 23, ARG_SLOT_SIZE+232 |
| 2384 | .cfi_rel_offset 22, ARG_SLOT_SIZE+228 |
| 2385 | .cfi_rel_offset 21, ARG_SLOT_SIZE+224 |
| 2386 | .cfi_rel_offset 20, ARG_SLOT_SIZE+220 |
| 2387 | .cfi_rel_offset 19, ARG_SLOT_SIZE+216 |
| 2388 | .cfi_rel_offset 18, ARG_SLOT_SIZE+212 |
| 2389 | .cfi_rel_offset 17, ARG_SLOT_SIZE+208 |
| 2390 | .cfi_rel_offset 16, ARG_SLOT_SIZE+204 |
| 2391 | .cfi_rel_offset 15, ARG_SLOT_SIZE+200 |
| 2392 | .cfi_rel_offset 14, ARG_SLOT_SIZE+196 |
| 2393 | .cfi_rel_offset 13, ARG_SLOT_SIZE+192 |
| 2394 | .cfi_rel_offset 12, ARG_SLOT_SIZE+188 |
| 2395 | .cfi_rel_offset 11, ARG_SLOT_SIZE+184 |
| 2396 | .cfi_rel_offset 10, ARG_SLOT_SIZE+180 |
| 2397 | .cfi_rel_offset 9, ARG_SLOT_SIZE+176 |
| 2398 | .cfi_rel_offset 8, ARG_SLOT_SIZE+172 |
| 2399 | .cfi_rel_offset 7, ARG_SLOT_SIZE+168 |
| 2400 | .cfi_rel_offset 6, ARG_SLOT_SIZE+164 |
| 2401 | .cfi_rel_offset 5, ARG_SLOT_SIZE+160 |
| 2402 | .cfi_rel_offset 4, ARG_SLOT_SIZE+156 |
| 2403 | .cfi_rel_offset 3, ARG_SLOT_SIZE+152 |
| 2404 | .cfi_rel_offset 2, ARG_SLOT_SIZE+148 |
| 2405 | .cfi_rel_offset 1, ARG_SLOT_SIZE+144 |
| 2406 | |
| 2407 | la $t9, artDeoptimize |
| 2408 | jalr $t9 # (Thread*) |
| 2409 | move $a0, rSELF # pass Thread::current |
| 2410 | break |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2411 | END art_quick_deoptimize |
| jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2412 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2413 | /* |
| Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2414 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
| 2415 | * will long jump to the upcall with a special exception of -1. |
| 2416 | */ |
| 2417 | .extern artDeoptimizeFromCompiledCode |
| Alexey Frunze | 60454cb | 2017-08-09 21:28:30 -0700 | [diff] [blame] | 2418 | ENTRY_NO_GP art_quick_deoptimize_from_compiled_code |
| Vladimir Marko | 239d6ea | 2016-09-05 10:44:04 +0100 | [diff] [blame] | 2419 | SETUP_SAVE_EVERYTHING_FRAME |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2420 | la $t9, artDeoptimizeFromCompiledCode |
| Nicolas Geoffray | 4e92c3c | 2017-05-08 09:34:26 +0100 | [diff] [blame] | 2421 | jalr $t9 # (DeoptimizationKind, Thread*) |
| 2422 | move $a1, rSELF # pass Thread::current |
| Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2423 | END art_quick_deoptimize_from_compiled_code |
| 2424 | |
| 2425 | /* |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2426 | * Long integer shift. This is different from the generic 32/64-bit |
| 2427 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2428 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2429 | * 6 bits. |
| 2430 | * On entry: |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2431 | * $a0: low word |
| 2432 | * $a1: high word |
| 2433 | * $a2: shift count |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2434 | */ |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2435 | ENTRY_NO_GP art_quick_shl_long |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2436 | /* shl-long vAA, vBB, vCC */ |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2437 | sll $v0, $a0, $a2 # rlo<- alo << (shift&31) |
| 2438 | not $v1, $a2 # rhi<- 31-shift (shift is 5b) |
| 2439 | srl $a0, 1 |
| 2440 | srl $a0, $v1 # alo<- alo >> (32-(shift&31)) |
| 2441 | sll $v1, $a1, $a2 # rhi<- ahi << (shift&31) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2442 | andi $a2, 0x20 # shift< shift & 0x20 |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2443 | beqz $a2, 1f |
| 2444 | or $v1, $a0 # rhi<- rhi | alo |
| 2445 | |
| 2446 | move $v1, $v0 # rhi<- rlo (if shift&0x20) |
| 2447 | move $v0, $zero # rlo<- 0 (if shift&0x20) |
| 2448 | |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2449 | 1: jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2450 | nop |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2451 | END art_quick_shl_long |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2452 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2453 | /* |
| 2454 | * Long integer shift. This is different from the generic 32/64-bit |
| 2455 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2456 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2457 | * 6 bits. |
| 2458 | * On entry: |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2459 | * $a0: low word |
| 2460 | * $a1: high word |
| 2461 | * $a2: shift count |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2462 | */ |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2463 | ENTRY_NO_GP art_quick_shr_long |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2464 | sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31) |
| 2465 | srl $v0, $a0, $a2 # rlo<- alo >> (shift&31) |
| 2466 | sra $a3, $a1, 31 # $a3<- sign(ah) |
| 2467 | not $a0, $a2 # alo<- 31-shift (shift is 5b) |
| 2468 | sll $a1, 1 |
| 2469 | sll $a1, $a0 # ahi<- ahi << (32-(shift&31)) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2470 | andi $a2, 0x20 # shift & 0x20 |
| Douglas Leung | 475cfd8 | 2014-12-16 20:15:41 -0800 | [diff] [blame] | 2471 | beqz $a2, 1f |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2472 | or $v0, $a1 # rlo<- rlo | ahi |
| 2473 | |
| 2474 | move $v0, $v1 # rlo<- rhi (if shift&0x20) |
| 2475 | move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20) |
| 2476 | |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2477 | 1: jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2478 | nop |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2479 | END art_quick_shr_long |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2480 | |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2481 | /* |
| 2482 | * Long integer shift. This is different from the generic 32/64-bit |
| 2483 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2484 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2485 | * 6 bits. |
| 2486 | * On entry: |
| Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2487 | * $a0: low word |
| 2488 | * $a1: high word |
| 2489 | * $a2: shift count |
| buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2490 | */ |
| 2491 | /* ushr-long vAA, vBB, vCC */ |
| Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2492 | ENTRY_NO_GP art_quick_ushr_long |
| jeffhao | fc6a30e | 2012-10-18 18:24:15 -0700 | [diff] [blame] | 2493 | srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2494 | srl $v0, $a0, $a2 # rlo<- alo >> (shift&31) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2495 | not $a0, $a2 # alo<- 31-shift (shift is 5b) |
| 2496 | sll $a1, 1 |
| 2497 | sll $a1, $a0 # ahi<- ahi << (32-(shift&31)) |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2498 | andi $a2, 0x20 # shift & 0x20 |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2499 | beqz $a2, 1f |
| 2500 | or $v0, $a1 # rlo<- rlo | ahi |
| 2501 | |
| 2502 | move $v0, $v1 # rlo<- rhi (if shift&0x20) |
| 2503 | move $v1, $zero # rhi<- 0 (if shift&0x20) |
| 2504 | |
| Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2505 | 1: jalr $zero, $ra |
| Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2506 | nop |
| Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2507 | END art_quick_ushr_long |
| jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2508 | |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2509 | /* java.lang.String.indexOf(int ch, int fromIndex=0) */ |
| 2510 | ENTRY_NO_GP art_quick_indexof |
| 2511 | /* $a0 holds address of "this" */ |
| 2512 | /* $a1 holds "ch" */ |
| 2513 | /* $a2 holds "fromIndex" */ |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2514 | #if (STRING_COMPRESSION_FEATURE) |
| 2515 | lw $a3, MIRROR_STRING_COUNT_OFFSET($a0) # 'count' field of this |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2516 | #else |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2517 | lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2518 | #endif |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2519 | slt $t1, $a2, $zero # if fromIndex < 0 |
| Goran Jakovljevic | cdb23d6 | 2017-02-28 14:58:01 +0100 | [diff] [blame] | 2520 | #if defined(_MIPS_ARCH_MIPS32R6) |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2521 | seleqz $a2, $a2, $t1 # fromIndex = 0; |
| 2522 | #else |
| 2523 | movn $a2, $zero, $t1 # fromIndex = 0; |
| 2524 | #endif |
| Goran Jakovljevic | cdb23d6 | 2017-02-28 14:58:01 +0100 | [diff] [blame] | 2525 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2526 | #if (STRING_COMPRESSION_FEATURE) |
| 2527 | srl $t0, $a3, 1 # $a3 holds count (with flag) and $t0 holds actual length |
| 2528 | #endif |
| 2529 | subu $t0, $t0, $a2 # this.length() - fromIndex |
| 2530 | blez $t0, 6f # if this.length()-fromIndex <= 0 |
| 2531 | li $v0, -1 # return -1; |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2532 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2533 | #if (STRING_COMPRESSION_FEATURE) |
| 2534 | sll $a3, $a3, 31 # Extract compression flag. |
| 2535 | beqz $a3, .Lstring_indexof_compressed |
| 2536 | move $t2, $a0 # Save a copy in $t2 to later compute result (in branch delay slot). |
| 2537 | #endif |
| 2538 | sll $v0, $a2, 1 # $a0 += $a2 * 2 |
| 2539 | addu $a0, $a0, $v0 # " ditto " |
| 2540 | move $v0, $a2 # Set i to fromIndex. |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2541 | |
| 2542 | 1: |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2543 | lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch |
| 2544 | beq $t3, $a1, 6f # return i; |
| 2545 | addu $a0, $a0, 2 # i++ |
| 2546 | subu $t0, $t0, 1 # this.length() - i |
| 2547 | bnez $t0, 1b # while this.length() - i > 0 |
| 2548 | addu $v0, $v0, 1 # i++ |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2549 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2550 | li $v0, -1 # if this.length() - i <= 0 |
| 2551 | # return -1; |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2552 | |
| 2553 | 6: |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2554 | j $ra |
| 2555 | nop |
| 2556 | |
| 2557 | #if (STRING_COMPRESSION_FEATURE) |
| 2558 | .Lstring_indexof_compressed: |
| 2559 | addu $a0, $a0, $a2 # $a0 += $a2 |
| 2560 | |
| 2561 | .Lstring_indexof_compressed_loop: |
| 2562 | lbu $t3, MIRROR_STRING_VALUE_OFFSET($a0) |
| 2563 | beq $t3, $a1, .Lstring_indexof_compressed_matched |
| 2564 | subu $t0, $t0, 1 |
| 2565 | bgtz $t0, .Lstring_indexof_compressed_loop |
| 2566 | addu $a0, $a0, 1 |
| 2567 | |
| 2568 | .Lstring_indexof_nomatch: |
| 2569 | jalr $zero, $ra |
| 2570 | li $v0, -1 # return -1; |
| 2571 | |
| 2572 | .Lstring_indexof_compressed_matched: |
| 2573 | jalr $zero, $ra |
| 2574 | subu $v0, $a0, $t2 # return (current - start); |
| 2575 | #endif |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2576 | END art_quick_indexof |
| 2577 | |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2578 | /* java.lang.String.compareTo(String anotherString) */ |
| 2579 | ENTRY_NO_GP art_quick_string_compareto |
| 2580 | /* $a0 holds address of "this" */ |
| 2581 | /* $a1 holds address of "anotherString" */ |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2582 | beq $a0, $a1, .Lstring_compareto_length_diff # this and anotherString are the same object |
| 2583 | move $a3, $a2 # trick to return 0 (it returns a2 - a3) |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2584 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2585 | #if (STRING_COMPRESSION_FEATURE) |
| 2586 | lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # 'count' field of this |
| 2587 | lw $t1, MIRROR_STRING_COUNT_OFFSET($a1) # 'count' field of anotherString |
| 2588 | sra $a2, $t0, 1 # this.length() |
| 2589 | sra $a3, $t1, 1 # anotherString.length() |
| 2590 | #else |
| 2591 | lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
| 2592 | lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length() |
| 2593 | #endif |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2594 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2595 | MINu $t2, $a2, $a3 |
| 2596 | # $t2 now holds min(this.length(),anotherString.length()) |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2597 | |
| Goran Jakovljevic | f94fa81 | 2017-02-10 17:48:52 +0100 | [diff] [blame] | 2598 | # while min(this.length(),anotherString.length())-i != 0 |
| 2599 | beqz $t2, .Lstring_compareto_length_diff # if $t2==0 |
| 2600 | nop # return (this.length() - anotherString.length()) |
| 2601 | |
| 2602 | #if (STRING_COMPRESSION_FEATURE) |
| 2603 | # Differ cases: |
| 2604 | sll $t3, $t0, 31 |
| 2605 | beqz $t3, .Lstring_compareto_this_is_compressed |
| 2606 | sll $t3, $t1, 31 # In branch delay slot. |
| 2607 | beqz $t3, .Lstring_compareto_that_is_compressed |
| 2608 | nop |
| 2609 | b .Lstring_compareto_both_not_compressed |
| 2610 | nop |
| 2611 | |
| 2612 | .Lstring_compareto_this_is_compressed: |
| 2613 | beqz $t3, .Lstring_compareto_both_compressed |
| 2614 | nop |
| 2615 | /* If (this->IsCompressed() && that->IsCompressed() == false) */ |
| 2616 | .Lstring_compareto_loop_comparison_this_compressed: |
| 2617 | lbu $t0, MIRROR_STRING_VALUE_OFFSET($a0) |
| 2618 | lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1) |
| 2619 | bne $t0, $t1, .Lstring_compareto_char_diff |
| 2620 | addiu $a0, $a0, 1 # point at this.charAt(i++) - compressed |
| 2621 | subu $t2, $t2, 1 # new value of min(this.length(),anotherString.length())-i |
| 2622 | bnez $t2, .Lstring_compareto_loop_comparison_this_compressed |
| 2623 | addiu $a1, $a1, 2 # point at anotherString.charAt(i++) - uncompressed |
| 2624 | jalr $zero, $ra |
| 2625 | subu $v0, $a2, $a3 # return (this.length() - anotherString.length()) |
| 2626 | |
| 2627 | .Lstring_compareto_that_is_compressed: |
| 2628 | lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) |
| 2629 | lbu $t1, MIRROR_STRING_VALUE_OFFSET($a1) |
| 2630 | bne $t0, $t1, .Lstring_compareto_char_diff |
| 2631 | addiu $a0, $a0, 2 # point at this.charAt(i++) - uncompressed |
| 2632 | subu $t2, $t2, 1 # new value of min(this.length(),anotherString.length())-i |
| 2633 | bnez $t2, .Lstring_compareto_that_is_compressed |
| 2634 | addiu $a1, $a1, 1 # point at anotherString.charAt(i++) - compressed |
| 2635 | jalr $zero, $ra |
| 2636 | subu $v0, $a2, $a3 # return (this.length() - anotherString.length()) |
| 2637 | |
| 2638 | .Lstring_compareto_both_compressed: |
| 2639 | lbu $t0, MIRROR_STRING_VALUE_OFFSET($a0) |
| 2640 | lbu $t1, MIRROR_STRING_VALUE_OFFSET($a1) |
| 2641 | bne $t0, $t1, .Lstring_compareto_char_diff |
| 2642 | addiu $a0, $a0, 1 # point at this.charAt(i++) - compressed |
| 2643 | subu $t2, $t2, 1 # new value of min(this.length(),anotherString.length())-i |
| 2644 | bnez $t2, .Lstring_compareto_both_compressed |
| 2645 | addiu $a1, $a1, 1 # point at anotherString.charAt(i++) - compressed |
| 2646 | jalr $zero, $ra |
| 2647 | subu $v0, $a2, $a3 # return (this.length() - anotherString.length()) |
| 2648 | #endif |
| 2649 | |
| 2650 | .Lstring_compareto_both_not_compressed: |
| 2651 | lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i) |
| 2652 | lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1) |
| 2653 | bne $t0, $t1, .Lstring_compareto_char_diff # if this.charAt(i) != anotherString.charAt(i) |
| 2654 | # return (this.charAt(i) - anotherString.charAt(i)) |
| 2655 | addiu $a0, $a0, 2 # point at this.charAt(i++) |
| 2656 | subu $t2, $t2, 1 # new value of min(this.length(),anotherString.length())-i |
| 2657 | bnez $t2, .Lstring_compareto_both_not_compressed |
| 2658 | addiu $a1, $a1, 2 # point at anotherString.charAt(i++) |
| 2659 | |
| 2660 | .Lstring_compareto_length_diff: |
| 2661 | jalr $zero, $ra |
| 2662 | subu $v0, $a2, $a3 # return (this.length() - anotherString.length()) |
| 2663 | |
| 2664 | .Lstring_compareto_char_diff: |
| 2665 | jalr $zero, $ra |
| 2666 | subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i)) |
| Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2667 | END art_quick_string_compareto |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2668 | |
| Alexey Frunze | 1595815 | 2017-02-09 19:08:30 -0800 | [diff] [blame] | 2669 | /* |
| 2670 | * Create a function `name` calling the ReadBarrier::Mark routine, |
| 2671 | * getting its argument and returning its result through register |
| 2672 | * `reg`, saving and restoring all caller-save registers. |
| 2673 | */ |
| 2674 | .macro READ_BARRIER_MARK_REG name, reg |
| 2675 | ENTRY \name |
| Alexey Frunze | a3cb132 | 2017-05-01 18:49:46 -0700 | [diff] [blame] | 2676 | // Null check so that we can load the lock word. |
| 2677 | bnez \reg, .Lnot_null_\name |
| 2678 | nop |
| 2679 | .Lret_rb_\name: |
| 2680 | jalr $zero, $ra |
| 2681 | nop |
| 2682 | .Lnot_null_\name: |
| 2683 | // Check lock word for mark bit, if marked return. |
| 2684 | lw $t9, MIRROR_OBJECT_LOCK_WORD_OFFSET(\reg) |
| 2685 | .set push |
| 2686 | .set noat |
| 2687 | sll $at, $t9, 31 - LOCK_WORD_MARK_BIT_SHIFT # Move mark bit to sign bit. |
| 2688 | bltz $at, .Lret_rb_\name |
| 2689 | #if (LOCK_WORD_STATE_SHIFT != 30) || (LOCK_WORD_STATE_FORWARDING_ADDRESS != 3) |
| 2690 | // The below code depends on the lock word state being in the highest bits |
| 2691 | // and the "forwarding address" state having all bits set. |
| 2692 | #error "Unexpected lock word state shift or forwarding address state value." |
| 2693 | #endif |
| 2694 | // Test that both the forwarding state bits are 1. |
| 2695 | sll $at, $t9, 1 |
| 2696 | and $at, $at, $t9 # Sign bit = 1 IFF both bits are 1. |
| 2697 | bltz $at, .Lret_forwarding_address\name |
| 2698 | nop |
| 2699 | .set pop |
| 2700 | |
| 2701 | addiu $sp, $sp, -160 # Includes 16 bytes of space for argument registers a0-a3. |
| Alexey Frunze | 1595815 | 2017-02-09 19:08:30 -0800 | [diff] [blame] | 2702 | .cfi_adjust_cfa_offset 160 |
| 2703 | |
| 2704 | sw $ra, 156($sp) |
| 2705 | .cfi_rel_offset 31, 156 |
| 2706 | sw $t8, 152($sp) |
| 2707 | .cfi_rel_offset 24, 152 |
| 2708 | sw $t7, 148($sp) |
| 2709 | .cfi_rel_offset 15, 148 |
| 2710 | sw $t6, 144($sp) |
| 2711 | .cfi_rel_offset 14, 144 |
| 2712 | sw $t5, 140($sp) |
| 2713 | .cfi_rel_offset 13, 140 |
| 2714 | sw $t4, 136($sp) |
| 2715 | .cfi_rel_offset 12, 136 |
| 2716 | sw $t3, 132($sp) |
| 2717 | .cfi_rel_offset 11, 132 |
| 2718 | sw $t2, 128($sp) |
| 2719 | .cfi_rel_offset 10, 128 |
| 2720 | sw $t1, 124($sp) |
| 2721 | .cfi_rel_offset 9, 124 |
| 2722 | sw $t0, 120($sp) |
| 2723 | .cfi_rel_offset 8, 120 |
| 2724 | sw $a3, 116($sp) |
| 2725 | .cfi_rel_offset 7, 116 |
| 2726 | sw $a2, 112($sp) |
| 2727 | .cfi_rel_offset 6, 112 |
| 2728 | sw $a1, 108($sp) |
| 2729 | .cfi_rel_offset 5, 108 |
| 2730 | sw $a0, 104($sp) |
| 2731 | .cfi_rel_offset 4, 104 |
| 2732 | sw $v1, 100($sp) |
| 2733 | .cfi_rel_offset 3, 100 |
| 2734 | sw $v0, 96($sp) |
| 2735 | .cfi_rel_offset 2, 96 |
| 2736 | |
| 2737 | la $t9, artReadBarrierMark |
| 2738 | |
| 2739 | sdc1 $f18, 88($sp) |
| 2740 | sdc1 $f16, 80($sp) |
| 2741 | sdc1 $f14, 72($sp) |
| 2742 | sdc1 $f12, 64($sp) |
| 2743 | sdc1 $f10, 56($sp) |
| 2744 | sdc1 $f8, 48($sp) |
| 2745 | sdc1 $f6, 40($sp) |
| 2746 | sdc1 $f4, 32($sp) |
| 2747 | sdc1 $f2, 24($sp) |
| 2748 | |
| 2749 | .ifnc \reg, $a0 |
| 2750 | move $a0, \reg # pass obj from `reg` in a0 |
| 2751 | .endif |
| 2752 | jalr $t9 # v0 <- artReadBarrierMark(obj) |
| 2753 | sdc1 $f0, 16($sp) # in delay slot |
| 2754 | |
| 2755 | lw $ra, 156($sp) |
| 2756 | .cfi_restore 31 |
| 2757 | lw $t8, 152($sp) |
| 2758 | .cfi_restore 24 |
| 2759 | lw $t7, 148($sp) |
| 2760 | .cfi_restore 15 |
| 2761 | lw $t6, 144($sp) |
| 2762 | .cfi_restore 14 |
| 2763 | lw $t5, 140($sp) |
| 2764 | .cfi_restore 13 |
| 2765 | lw $t4, 136($sp) |
| 2766 | .cfi_restore 12 |
| 2767 | lw $t3, 132($sp) |
| 2768 | .cfi_restore 11 |
| 2769 | lw $t2, 128($sp) |
| 2770 | .cfi_restore 10 |
| 2771 | lw $t1, 124($sp) |
| 2772 | .cfi_restore 9 |
| 2773 | lw $t0, 120($sp) |
| 2774 | .cfi_restore 8 |
| 2775 | lw $a3, 116($sp) |
| 2776 | .cfi_restore 7 |
| 2777 | lw $a2, 112($sp) |
| 2778 | .cfi_restore 6 |
| 2779 | lw $a1, 108($sp) |
| 2780 | .cfi_restore 5 |
| 2781 | lw $a0, 104($sp) |
| 2782 | .cfi_restore 4 |
| 2783 | lw $v1, 100($sp) |
| 2784 | .cfi_restore 3 |
| 2785 | |
| 2786 | .ifnc \reg, $v0 |
| 2787 | move \reg, $v0 # `reg` <- v0 |
| 2788 | lw $v0, 96($sp) |
| 2789 | .cfi_restore 2 |
| 2790 | .endif |
| 2791 | |
| 2792 | ldc1 $f18, 88($sp) |
| 2793 | ldc1 $f16, 80($sp) |
| 2794 | ldc1 $f14, 72($sp) |
| 2795 | ldc1 $f12, 64($sp) |
| 2796 | ldc1 $f10, 56($sp) |
| 2797 | ldc1 $f8, 48($sp) |
| 2798 | ldc1 $f6, 40($sp) |
| 2799 | ldc1 $f4, 32($sp) |
| 2800 | ldc1 $f2, 24($sp) |
| 2801 | ldc1 $f0, 16($sp) |
| 2802 | |
| 2803 | jalr $zero, $ra |
| 2804 | addiu $sp, $sp, 160 |
| 2805 | .cfi_adjust_cfa_offset -160 |
| Alexey Frunze | a3cb132 | 2017-05-01 18:49:46 -0700 | [diff] [blame] | 2806 | |
| 2807 | .Lret_forwarding_address\name: |
| 2808 | jalr $zero, $ra |
| 2809 | // Shift left by the forwarding address shift. This clears out the state bits since they are |
| 2810 | // in the top 2 bits of the lock word. |
| 2811 | sll \reg, $t9, LOCK_WORD_STATE_FORWARDING_ADDRESS_SHIFT |
| Alexey Frunze | 1595815 | 2017-02-09 19:08:30 -0800 | [diff] [blame] | 2812 | END \name |
| 2813 | .endm |
| 2814 | |
| 2815 | // Note that art_quick_read_barrier_mark_regXX corresponds to register XX+1. |
| 2816 | // ZERO (register 0) is reserved. |
| 2817 | // AT (register 1) is reserved as a temporary/scratch register. |
| 2818 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg01, $v0 |
| 2819 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg02, $v1 |
| 2820 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg03, $a0 |
| 2821 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg04, $a1 |
| 2822 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg05, $a2 |
| 2823 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg06, $a3 |
| 2824 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg07, $t0 |
| 2825 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg08, $t1 |
| 2826 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg09, $t2 |
| 2827 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg10, $t3 |
| 2828 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg11, $t4 |
| 2829 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg12, $t5 |
| 2830 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg13, $t6 |
| 2831 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg14, $t7 |
| 2832 | // S0 and S1 (registers 16 and 17) are reserved as suspended and thread registers. |
| 2833 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg17, $s2 |
| 2834 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg18, $s3 |
| 2835 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg19, $s4 |
| 2836 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg20, $s5 |
| 2837 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg21, $s6 |
| 2838 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg22, $s7 |
| 2839 | // T8 and T9 (registers 24 and 25) are reserved as temporary/scratch registers. |
| 2840 | // K0, K1, GP, SP (registers 26 - 29) are reserved. |
| 2841 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg29, $s8 |
| 2842 | // RA (register 31) is reserved. |
| 2843 | |
| Alexey Frunze | 4147fcc | 2017-06-17 19:57:27 -0700 | [diff] [blame] | 2844 | // Caller code: |
| 2845 | // Short constant offset/index: |
| 2846 | // R2: | R6: |
| 2847 | // lw $t9, pReadBarrierMarkReg00 |
| 2848 | // beqz $t9, skip_call | beqzc $t9, skip_call |
| 2849 | // addiu $t9, $t9, thunk_disp | nop |
| 2850 | // jalr $t9 | jialc $t9, thunk_disp |
| 2851 | // nop | |
| 2852 | // skip_call: | skip_call: |
| 2853 | // lw `out`, ofs(`obj`) | lw `out`, ofs(`obj`) |
| 2854 | // [subu `out`, $zero, `out`] | [subu `out`, $zero, `out`] # Unpoison reference. |
| 2855 | .macro BRB_FIELD_SHORT_OFFSET_ENTRY obj |
| 2856 | 1: |
| 2857 | # Explicit null check. May be redundant (for array elements or when the field |
| 2858 | # offset is larger than the page size, 4KB). |
| 2859 | # $ra will be adjusted to point to lw's stack map when throwing NPE. |
| 2860 | beqz \obj, .Lintrospection_throw_npe |
| 2861 | #if defined(_MIPS_ARCH_MIPS32R6) |
| 2862 | lapc $gp, .Lintrospection_exits # $gp = address of .Lintrospection_exits. |
| 2863 | #else |
| 2864 | addiu $gp, $t9, (.Lintrospection_exits - 1b) # $gp = address of .Lintrospection_exits. |
| 2865 | #endif |
| 2866 | .set push |
| 2867 | .set noat |
| 2868 | lw $at, MIRROR_OBJECT_LOCK_WORD_OFFSET(\obj) |
| 2869 | sll $at, $at, 31 - LOCK_WORD_READ_BARRIER_STATE_SHIFT # Move barrier state bit |
| 2870 | # to sign bit. |
| 2871 | bltz $at, .Lintrospection_field_array # If gray, load reference, mark. |
| 2872 | move $t8, \obj # Move `obj` to $t8 for common code. |
| 2873 | .set pop |
| 2874 | jalr $zero, $ra # Otherwise, load-load barrier and return. |
| 2875 | sync |
| 2876 | .endm |
| 2877 | |
| 2878 | // Caller code (R2): |
| 2879 | // Long constant offset/index: | Variable index: |
| 2880 | // lw $t9, pReadBarrierMarkReg00 |
| 2881 | // lui $t8, ofs_hi | sll $t8, `index`, 2 |
| 2882 | // beqz $t9, skip_call | beqz $t9, skip_call |
| 2883 | // addiu $t9, $t9, thunk_disp | addiu $t9, $t9, thunk_disp |
| 2884 | // jalr $t9 | jalr $t9 |
| 2885 | // skip_call: | skip_call: |
| 2886 | // addu $t8, $t8, `obj` | addu $t8, $t8, `obj` |
| 2887 | // lw `out`, ofs_lo($t8) | lw `out`, ofs($t8) |
| 2888 | // [subu `out`, $zero, `out`] | [subu `out`, $zero, `out`] # Unpoison reference. |
| 2889 | // |
| 2890 | // Caller code (R6): |
| 2891 | // Long constant offset/index: | Variable index: |
| 2892 | // lw $t9, pReadBarrierMarkReg00 |
| 2893 | // beqz $t9, skip_call | beqz $t9, skip_call |
| 2894 | // aui $t8, `obj`, ofs_hi | lsa $t8, `index`, `obj`, 2 |
| 2895 | // jialc $t9, thunk_disp | jialc $t9, thunk_disp |
| 2896 | // skip_call: | skip_call: |
| 2897 | // lw `out`, ofs_lo($t8) | lw `out`, ofs($t8) |
| 2898 | // [subu `out`, $zero, `out`] | [subu `out`, $zero, `out`] # Unpoison reference. |
| 2899 | .macro BRB_FIELD_LONG_OFFSET_ENTRY obj |
| 2900 | 1: |
| 2901 | # No explicit null check for variable indices or large constant indices/offsets |
| 2902 | # as it must have been done earlier. |
| 2903 | #if defined(_MIPS_ARCH_MIPS32R6) |
| 2904 | lapc $gp, .Lintrospection_exits # $gp = address of .Lintrospection_exits. |
| 2905 | #else |
| 2906 | addiu $gp, $t9, (.Lintrospection_exits - 1b) # $gp = address of .Lintrospection_exits. |
| 2907 | #endif |
| 2908 | .set push |
| 2909 | .set noat |
| 2910 | lw $at, MIRROR_OBJECT_LOCK_WORD_OFFSET(\obj) |
| 2911 | sll $at, $at, 31 - LOCK_WORD_READ_BARRIER_STATE_SHIFT # Move barrier state bit |
| 2912 | # to sign bit. |
| 2913 | bltz $at, .Lintrospection_field_array # If gray, load reference, mark. |
| 2914 | nop |
| 2915 | .set pop |
| 2916 | jalr $zero, $ra # Otherwise, load-load barrier and return. |
| 2917 | sync |
| 2918 | break # Padding to 8 instructions. |
| 2919 | .endm |
| 2920 | |
| 2921 | .macro BRB_GC_ROOT_ENTRY root |
| 2922 | 1: |
| 2923 | #if defined(_MIPS_ARCH_MIPS32R6) |
| 2924 | lapc $gp, .Lintrospection_exit_\root # $gp = exit point address. |
| 2925 | #else |
| 2926 | addiu $gp, $t9, (.Lintrospection_exit_\root - 1b) # $gp = exit point address. |
| 2927 | #endif |
| 2928 | bnez \root, .Lintrospection_common |
| 2929 | move $t8, \root # Move reference to $t8 for common code. |
| 2930 | jalr $zero, $ra # Return if null. |
| 2931 | # The next instruction (from the following BRB_GC_ROOT_ENTRY) fills the delay slot. |
| 2932 | # This instruction has no effect (actual NOP for the last entry; otherwise changes $gp, |
| 2933 | # which is unused after that anyway). |
| 2934 | .endm |
| 2935 | |
| 2936 | .macro BRB_FIELD_EXIT out |
| 2937 | .Lintrospection_exit_\out: |
| 2938 | jalr $zero, $ra |
| 2939 | move \out, $t8 # Return reference in expected register. |
| 2940 | .endm |
| 2941 | |
| 2942 | .macro BRB_FIELD_EXIT_BREAK |
| 2943 | break |
| 2944 | break |
| 2945 | .endm |
| 2946 | |
| 2947 | ENTRY_NO_GP art_quick_read_barrier_mark_introspection |
| 2948 | # Entry points for offsets/indices not fitting into int16_t and for variable indices. |
| 2949 | BRB_FIELD_LONG_OFFSET_ENTRY $v0 |
| 2950 | BRB_FIELD_LONG_OFFSET_ENTRY $v1 |
| 2951 | BRB_FIELD_LONG_OFFSET_ENTRY $a0 |
| 2952 | BRB_FIELD_LONG_OFFSET_ENTRY $a1 |
| 2953 | BRB_FIELD_LONG_OFFSET_ENTRY $a2 |
| 2954 | BRB_FIELD_LONG_OFFSET_ENTRY $a3 |
| 2955 | BRB_FIELD_LONG_OFFSET_ENTRY $t0 |
| 2956 | BRB_FIELD_LONG_OFFSET_ENTRY $t1 |
| 2957 | BRB_FIELD_LONG_OFFSET_ENTRY $t2 |
| 2958 | BRB_FIELD_LONG_OFFSET_ENTRY $t3 |
| 2959 | BRB_FIELD_LONG_OFFSET_ENTRY $t4 |
| 2960 | BRB_FIELD_LONG_OFFSET_ENTRY $t5 |
| 2961 | BRB_FIELD_LONG_OFFSET_ENTRY $t6 |
| 2962 | BRB_FIELD_LONG_OFFSET_ENTRY $t7 |
| 2963 | BRB_FIELD_LONG_OFFSET_ENTRY $s2 |
| 2964 | BRB_FIELD_LONG_OFFSET_ENTRY $s3 |
| 2965 | BRB_FIELD_LONG_OFFSET_ENTRY $s4 |
| 2966 | BRB_FIELD_LONG_OFFSET_ENTRY $s5 |
| 2967 | BRB_FIELD_LONG_OFFSET_ENTRY $s6 |
| 2968 | BRB_FIELD_LONG_OFFSET_ENTRY $s7 |
| 2969 | BRB_FIELD_LONG_OFFSET_ENTRY $s8 |
| 2970 | |
| 2971 | # Entry points for offsets/indices fitting into int16_t. |
| 2972 | BRB_FIELD_SHORT_OFFSET_ENTRY $v0 |
| 2973 | BRB_FIELD_SHORT_OFFSET_ENTRY $v1 |
| 2974 | BRB_FIELD_SHORT_OFFSET_ENTRY $a0 |
| 2975 | BRB_FIELD_SHORT_OFFSET_ENTRY $a1 |
| 2976 | BRB_FIELD_SHORT_OFFSET_ENTRY $a2 |
| 2977 | BRB_FIELD_SHORT_OFFSET_ENTRY $a3 |
| 2978 | BRB_FIELD_SHORT_OFFSET_ENTRY $t0 |
| 2979 | BRB_FIELD_SHORT_OFFSET_ENTRY $t1 |
| 2980 | BRB_FIELD_SHORT_OFFSET_ENTRY $t2 |
| 2981 | BRB_FIELD_SHORT_OFFSET_ENTRY $t3 |
| 2982 | BRB_FIELD_SHORT_OFFSET_ENTRY $t4 |
| 2983 | BRB_FIELD_SHORT_OFFSET_ENTRY $t5 |
| 2984 | BRB_FIELD_SHORT_OFFSET_ENTRY $t6 |
| 2985 | BRB_FIELD_SHORT_OFFSET_ENTRY $t7 |
| 2986 | BRB_FIELD_SHORT_OFFSET_ENTRY $s2 |
| 2987 | BRB_FIELD_SHORT_OFFSET_ENTRY $s3 |
| 2988 | BRB_FIELD_SHORT_OFFSET_ENTRY $s4 |
| 2989 | BRB_FIELD_SHORT_OFFSET_ENTRY $s5 |
| 2990 | BRB_FIELD_SHORT_OFFSET_ENTRY $s6 |
| 2991 | BRB_FIELD_SHORT_OFFSET_ENTRY $s7 |
| 2992 | BRB_FIELD_SHORT_OFFSET_ENTRY $s8 |
| 2993 | |
| 2994 | .global art_quick_read_barrier_mark_introspection_gc_roots |
| 2995 | art_quick_read_barrier_mark_introspection_gc_roots: |
| 2996 | # Entry points for GC roots. |
| 2997 | BRB_GC_ROOT_ENTRY $v0 |
| 2998 | BRB_GC_ROOT_ENTRY $v1 |
| 2999 | BRB_GC_ROOT_ENTRY $a0 |
| 3000 | BRB_GC_ROOT_ENTRY $a1 |
| 3001 | BRB_GC_ROOT_ENTRY $a2 |
| 3002 | BRB_GC_ROOT_ENTRY $a3 |
| 3003 | BRB_GC_ROOT_ENTRY $t0 |
| 3004 | BRB_GC_ROOT_ENTRY $t1 |
| 3005 | BRB_GC_ROOT_ENTRY $t2 |
| 3006 | BRB_GC_ROOT_ENTRY $t3 |
| 3007 | BRB_GC_ROOT_ENTRY $t4 |
| 3008 | BRB_GC_ROOT_ENTRY $t5 |
| 3009 | BRB_GC_ROOT_ENTRY $t6 |
| 3010 | BRB_GC_ROOT_ENTRY $t7 |
| 3011 | BRB_GC_ROOT_ENTRY $s2 |
| 3012 | BRB_GC_ROOT_ENTRY $s3 |
| 3013 | BRB_GC_ROOT_ENTRY $s4 |
| 3014 | BRB_GC_ROOT_ENTRY $s5 |
| 3015 | BRB_GC_ROOT_ENTRY $s6 |
| 3016 | BRB_GC_ROOT_ENTRY $s7 |
| 3017 | BRB_GC_ROOT_ENTRY $s8 |
| 3018 | .global art_quick_read_barrier_mark_introspection_end_of_entries |
| 3019 | art_quick_read_barrier_mark_introspection_end_of_entries: |
| 3020 | nop # Fill the delay slot of the last BRB_GC_ROOT_ENTRY. |
| 3021 | |
| 3022 | .Lintrospection_throw_npe: |
| 3023 | b art_quick_throw_null_pointer_exception |
| 3024 | addiu $ra, $ra, 4 # Skip lw, make $ra point to lw's stack map. |
| 3025 | |
| 3026 | .set push |
| 3027 | .set noat |
| 3028 | |
| 3029 | // Fields and array elements. |
| 3030 | |
| 3031 | .Lintrospection_field_array: |
| 3032 | // Get the field/element address using $t8 and the offset from the lw instruction. |
| 3033 | lh $at, 0($ra) # $ra points to lw: $at = field/element offset. |
| 3034 | addiu $ra, $ra, 4 + HEAP_POISON_INSTR_SIZE # Skip lw(+subu). |
| 3035 | addu $t8, $t8, $at # $t8 = field/element address. |
| 3036 | |
| 3037 | // Calculate the address of the exit point, store it in $gp and load the reference into $t8. |
| 3038 | lb $at, (-HEAP_POISON_INSTR_SIZE - 2)($ra) # $ra-HEAP_POISON_INSTR_SIZE-4 points to |
| 3039 | # "lw `out`, ...". |
| 3040 | andi $at, $at, 31 # Extract `out` from lw. |
| 3041 | sll $at, $at, 3 # Multiply `out` by the exit point size (BRB_FIELD_EXIT* macros). |
| 3042 | |
| 3043 | lw $t8, 0($t8) # $t8 = reference. |
| 3044 | UNPOISON_HEAP_REF $t8 |
| 3045 | |
| 3046 | // Return if null reference. |
| 3047 | bnez $t8, .Lintrospection_common |
| 3048 | addu $gp, $gp, $at # $gp = address of the exit point. |
| 3049 | |
| 3050 | // Early return through the exit point. |
| 3051 | .Lintrospection_return_early: |
| 3052 | jalr $zero, $gp # Move $t8 to `out` and return. |
| 3053 | nop |
| 3054 | |
| 3055 | // Code common for GC roots, fields and array elements. |
| 3056 | |
| 3057 | .Lintrospection_common: |
| 3058 | // Check lock word for mark bit, if marked return. |
| 3059 | lw $t9, MIRROR_OBJECT_LOCK_WORD_OFFSET($t8) |
| 3060 | sll $at, $t9, 31 - LOCK_WORD_MARK_BIT_SHIFT # Move mark bit to sign bit. |
| 3061 | bltz $at, .Lintrospection_return_early |
| 3062 | #if (LOCK_WORD_STATE_SHIFT != 30) || (LOCK_WORD_STATE_FORWARDING_ADDRESS != 3) |
| 3063 | // The below code depends on the lock word state being in the highest bits |
| 3064 | // and the "forwarding address" state having all bits set. |
| 3065 | #error "Unexpected lock word state shift or forwarding address state value." |
| 3066 | #endif |
| 3067 | // Test that both the forwarding state bits are 1. |
| 3068 | sll $at, $t9, 1 |
| 3069 | and $at, $at, $t9 # Sign bit = 1 IFF both bits are 1. |
| 3070 | bgez $at, .Lintrospection_mark |
| 3071 | nop |
| 3072 | |
| 3073 | .set pop |
| 3074 | |
| 3075 | // Shift left by the forwarding address shift. This clears out the state bits since they are |
| 3076 | // in the top 2 bits of the lock word. |
| 3077 | jalr $zero, $gp # Move $t8 to `out` and return. |
| 3078 | sll $t8, $t9, LOCK_WORD_STATE_FORWARDING_ADDRESS_SHIFT |
| 3079 | |
| 3080 | .Lintrospection_mark: |
| 3081 | // Partially set up the stack frame preserving only $ra. |
| 3082 | addiu $sp, $sp, -160 # Includes 16 bytes of space for argument registers $a0-$a3. |
| 3083 | .cfi_adjust_cfa_offset 160 |
| 3084 | sw $ra, 156($sp) |
| 3085 | .cfi_rel_offset 31, 156 |
| 3086 | |
| 3087 | // Set up $gp, clobbering $ra and using the branch delay slot for a useful instruction. |
| 3088 | bal 1f |
| 3089 | sw $gp, 152($sp) # Preserve the exit point address. |
| 3090 | 1: |
| 3091 | .cpload $ra |
| 3092 | |
| 3093 | // Finalize the stack frame and call. |
| 3094 | sw $t7, 148($sp) |
| 3095 | .cfi_rel_offset 15, 148 |
| 3096 | sw $t6, 144($sp) |
| 3097 | .cfi_rel_offset 14, 144 |
| 3098 | sw $t5, 140($sp) |
| 3099 | .cfi_rel_offset 13, 140 |
| 3100 | sw $t4, 136($sp) |
| 3101 | .cfi_rel_offset 12, 136 |
| 3102 | sw $t3, 132($sp) |
| 3103 | .cfi_rel_offset 11, 132 |
| 3104 | sw $t2, 128($sp) |
| 3105 | .cfi_rel_offset 10, 128 |
| 3106 | sw $t1, 124($sp) |
| 3107 | .cfi_rel_offset 9, 124 |
| 3108 | sw $t0, 120($sp) |
| 3109 | .cfi_rel_offset 8, 120 |
| 3110 | sw $a3, 116($sp) |
| 3111 | .cfi_rel_offset 7, 116 |
| 3112 | sw $a2, 112($sp) |
| 3113 | .cfi_rel_offset 6, 112 |
| 3114 | sw $a1, 108($sp) |
| 3115 | .cfi_rel_offset 5, 108 |
| 3116 | sw $a0, 104($sp) |
| 3117 | .cfi_rel_offset 4, 104 |
| 3118 | sw $v1, 100($sp) |
| 3119 | .cfi_rel_offset 3, 100 |
| 3120 | sw $v0, 96($sp) |
| 3121 | .cfi_rel_offset 2, 96 |
| 3122 | |
| 3123 | la $t9, artReadBarrierMark |
| 3124 | |
| 3125 | sdc1 $f18, 88($sp) |
| 3126 | sdc1 $f16, 80($sp) |
| 3127 | sdc1 $f14, 72($sp) |
| 3128 | sdc1 $f12, 64($sp) |
| 3129 | sdc1 $f10, 56($sp) |
| 3130 | sdc1 $f8, 48($sp) |
| 3131 | sdc1 $f6, 40($sp) |
| 3132 | sdc1 $f4, 32($sp) |
| 3133 | sdc1 $f2, 24($sp) |
| 3134 | sdc1 $f0, 16($sp) |
| 3135 | |
| 3136 | jalr $t9 # $v0 <- artReadBarrierMark(reference) |
| 3137 | move $a0, $t8 # Pass reference in $a0. |
| 3138 | move $t8, $v0 |
| 3139 | |
| 3140 | lw $ra, 156($sp) |
| 3141 | .cfi_restore 31 |
| 3142 | lw $gp, 152($sp) # $gp = address of the exit point. |
| 3143 | lw $t7, 148($sp) |
| 3144 | .cfi_restore 15 |
| 3145 | lw $t6, 144($sp) |
| 3146 | .cfi_restore 14 |
| 3147 | lw $t5, 140($sp) |
| 3148 | .cfi_restore 13 |
| 3149 | lw $t4, 136($sp) |
| 3150 | .cfi_restore 12 |
| 3151 | lw $t3, 132($sp) |
| 3152 | .cfi_restore 11 |
| 3153 | lw $t2, 128($sp) |
| 3154 | .cfi_restore 10 |
| 3155 | lw $t1, 124($sp) |
| 3156 | .cfi_restore 9 |
| 3157 | lw $t0, 120($sp) |
| 3158 | .cfi_restore 8 |
| 3159 | lw $a3, 116($sp) |
| 3160 | .cfi_restore 7 |
| 3161 | lw $a2, 112($sp) |
| 3162 | .cfi_restore 6 |
| 3163 | lw $a1, 108($sp) |
| 3164 | .cfi_restore 5 |
| 3165 | lw $a0, 104($sp) |
| 3166 | .cfi_restore 4 |
| 3167 | lw $v1, 100($sp) |
| 3168 | .cfi_restore 3 |
| 3169 | lw $v0, 96($sp) |
| 3170 | .cfi_restore 2 |
| 3171 | |
| 3172 | ldc1 $f18, 88($sp) |
| 3173 | ldc1 $f16, 80($sp) |
| 3174 | ldc1 $f14, 72($sp) |
| 3175 | ldc1 $f12, 64($sp) |
| 3176 | ldc1 $f10, 56($sp) |
| 3177 | ldc1 $f8, 48($sp) |
| 3178 | ldc1 $f6, 40($sp) |
| 3179 | ldc1 $f4, 32($sp) |
| 3180 | ldc1 $f2, 24($sp) |
| 3181 | ldc1 $f0, 16($sp) |
| 3182 | |
| 3183 | // Return through the exit point. |
| 3184 | jalr $zero, $gp # Move $t8 to `out` and return. |
| 3185 | addiu $sp, $sp, 160 |
| 3186 | .cfi_adjust_cfa_offset -160 |
| 3187 | |
| 3188 | .Lintrospection_exits: |
| 3189 | BRB_FIELD_EXIT_BREAK |
| 3190 | BRB_FIELD_EXIT_BREAK |
| 3191 | BRB_FIELD_EXIT $v0 |
| 3192 | BRB_FIELD_EXIT $v1 |
| 3193 | BRB_FIELD_EXIT $a0 |
| 3194 | BRB_FIELD_EXIT $a1 |
| 3195 | BRB_FIELD_EXIT $a2 |
| 3196 | BRB_FIELD_EXIT $a3 |
| 3197 | BRB_FIELD_EXIT $t0 |
| 3198 | BRB_FIELD_EXIT $t1 |
| 3199 | BRB_FIELD_EXIT $t2 |
| 3200 | BRB_FIELD_EXIT $t3 |
| 3201 | BRB_FIELD_EXIT $t4 |
| 3202 | BRB_FIELD_EXIT $t5 |
| 3203 | BRB_FIELD_EXIT $t6 |
| 3204 | BRB_FIELD_EXIT $t7 |
| 3205 | BRB_FIELD_EXIT_BREAK |
| 3206 | BRB_FIELD_EXIT_BREAK |
| 3207 | BRB_FIELD_EXIT $s2 |
| 3208 | BRB_FIELD_EXIT $s3 |
| 3209 | BRB_FIELD_EXIT $s4 |
| 3210 | BRB_FIELD_EXIT $s5 |
| 3211 | BRB_FIELD_EXIT $s6 |
| 3212 | BRB_FIELD_EXIT $s7 |
| 3213 | BRB_FIELD_EXIT_BREAK |
| 3214 | BRB_FIELD_EXIT_BREAK |
| 3215 | BRB_FIELD_EXIT_BREAK |
| 3216 | BRB_FIELD_EXIT_BREAK |
| 3217 | BRB_FIELD_EXIT_BREAK |
| 3218 | BRB_FIELD_EXIT_BREAK |
| 3219 | BRB_FIELD_EXIT $s8 |
| 3220 | BRB_FIELD_EXIT_BREAK |
| 3221 | END art_quick_read_barrier_mark_introspection |
| 3222 | |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3223 | .extern artInvokePolymorphic |
| 3224 | ENTRY art_quick_invoke_polymorphic |
| 3225 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
| 3226 | move $a2, rSELF # Make $a2 an alias for the current Thread. |
| Alexey Frunze | c480b98 | 2017-01-16 19:03:21 -0800 | [diff] [blame] | 3227 | addiu $a3, $sp, ARG_SLOT_SIZE # Make $a3 a pointer to the saved frame context. |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3228 | sw $zero, 20($sp) # Initialize JValue result. |
| 3229 | sw $zero, 16($sp) |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3230 | la $t9, artInvokePolymorphic |
| 3231 | jalr $t9 # (result, receiver, Thread*, context) |
| Alexey Frunze | c480b98 | 2017-01-16 19:03:21 -0800 | [diff] [blame] | 3232 | addiu $a0, $sp, 16 # Make $a0 a pointer to the JValue result |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3233 | .macro MATCH_RETURN_TYPE c, handler |
| 3234 | li $t0, \c |
| 3235 | beq $v0, $t0, \handler |
| 3236 | .endm |
| 3237 | MATCH_RETURN_TYPE 'V', .Lcleanup_and_return |
| 3238 | MATCH_RETURN_TYPE 'L', .Lstore_int_result |
| 3239 | MATCH_RETURN_TYPE 'I', .Lstore_int_result |
| 3240 | MATCH_RETURN_TYPE 'J', .Lstore_long_result |
| 3241 | MATCH_RETURN_TYPE 'B', .Lstore_int_result |
| 3242 | MATCH_RETURN_TYPE 'C', .Lstore_char_result |
| 3243 | MATCH_RETURN_TYPE 'D', .Lstore_double_result |
| 3244 | MATCH_RETURN_TYPE 'F', .Lstore_float_result |
| 3245 | MATCH_RETURN_TYPE 'S', .Lstore_int_result |
| Alexey Frunze | c480b98 | 2017-01-16 19:03:21 -0800 | [diff] [blame] | 3246 | MATCH_RETURN_TYPE 'Z', .Lstore_boolean_result |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3247 | .purgem MATCH_RETURN_TYPE |
| 3248 | nop |
| 3249 | b .Lcleanup_and_return |
| 3250 | nop |
| 3251 | .Lstore_boolean_result: |
| Alexey Frunze | c480b98 | 2017-01-16 19:03:21 -0800 | [diff] [blame] | 3252 | b .Lcleanup_and_return |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3253 | lbu $v0, 16($sp) # Move byte from JValue result to return value register. |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3254 | .Lstore_char_result: |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3255 | b .Lcleanup_and_return |
| Alexey Frunze | c480b98 | 2017-01-16 19:03:21 -0800 | [diff] [blame] | 3256 | lhu $v0, 16($sp) # Move char from JValue result to return value register. |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3257 | .Lstore_double_result: |
| 3258 | .Lstore_float_result: |
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame^] | 3259 | CHECK_ALIGNMENT $sp, $t0 |
| 3260 | ldc1 $f0, 16($sp) # Move double/float from JValue result to return value register. |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3261 | b .Lcleanup_and_return |
| 3262 | nop |
| 3263 | .Lstore_long_result: |
| 3264 | lw $v1, 20($sp) # Move upper bits from JValue result to return value register. |
| 3265 | // Fall-through for lower bits. |
| 3266 | .Lstore_int_result: |
| 3267 | lw $v0, 16($sp) # Move lower bits from JValue result to return value register. |
| 3268 | // Fall-through to clean up and return. |
| 3269 | .Lcleanup_and_return: |
| Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 3270 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # Load Thread::Current()->exception_ |
| 3271 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| 3272 | bnez $t7, 1f # Success if no exception is pending. |
| 3273 | nop |
| 3274 | jalr $zero, $ra |
| 3275 | nop |
| 3276 | 1: |
| 3277 | DELIVER_PENDING_EXCEPTION |
| 3278 | END art_quick_invoke_polymorphic |