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 |
Andreas Gampe | a4e0e67 | 2015-05-27 18:31:42 -0700 | [diff] [blame] | 40 | addiu $sp, $sp, -96 |
| 41 | .cfi_adjust_cfa_offset 96 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 42 | |
| 43 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 44 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 96) |
| 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 | |
Andreas Gampe | a4e0e67 | 2015-05-27 18:31:42 -0700 | [diff] [blame] | 48 | sw $ra, 92($sp) |
| 49 | .cfi_rel_offset 31, 92 |
| 50 | sw $s8, 88($sp) |
| 51 | .cfi_rel_offset 30, 88 |
| 52 | sw $gp, 84($sp) |
| 53 | .cfi_rel_offset 28, 84 |
| 54 | sw $s7, 80($sp) |
| 55 | .cfi_rel_offset 23, 80 |
| 56 | sw $s6, 76($sp) |
| 57 | .cfi_rel_offset 22, 76 |
| 58 | sw $s5, 72($sp) |
| 59 | .cfi_rel_offset 21, 72 |
| 60 | sw $s4, 68($sp) |
| 61 | .cfi_rel_offset 20, 68 |
| 62 | sw $s3, 64($sp) |
| 63 | .cfi_rel_offset 19, 64 |
| 64 | sw $s2, 60($sp) |
| 65 | .cfi_rel_offset 18, 60 |
| 66 | sw $s1, 56($sp) |
| 67 | .cfi_rel_offset 17, 56 |
| 68 | sw $s0, 52($sp) |
| 69 | .cfi_rel_offset 16, 52 |
| 70 | |
| 71 | SDu $f30, $f31, 44, $sp, $t1 |
| 72 | SDu $f28, $f29, 36, $sp, $t1 |
| 73 | SDu $f26, $f27, 28, $sp, $t1 |
| 74 | SDu $f24, $f25, 20, $sp, $t1 |
| 75 | SDu $f22, $f23, 12, $sp, $t1 |
| 76 | SDu $f20, $f21, 4, $sp, $t1 |
| 77 | |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 78 | # 1 word for holding Method* |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 79 | |
Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 80 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 81 | lw $t0, 0($t0) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 82 | lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET($t0) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 83 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 84 | 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] | 85 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 86 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 87 | .endm |
| 88 | |
| 89 | /* |
| 90 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 91 | * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly). Restoration assumes non-moving GC. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 92 | * Does not include rSUSPEND or rSELF |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 93 | * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method* |
| 94 | * Clobbers $t0 and $sp |
| 95 | * 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] | 96 | * Reserves FRAME_SIZE_SAVE_REFS_ONLY + ARG_SLOT_SIZE bytes on the stack |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 97 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 98 | .macro SETUP_SAVE_REFS_ONLY_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 99 | addiu $sp, $sp, -48 |
| 100 | .cfi_adjust_cfa_offset 48 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 101 | |
| 102 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 103 | #if (FRAME_SIZE_SAVE_REFS_ONLY != 48) |
| 104 | #error "FRAME_SIZE_SAVE_REFS_ONLY(MIPS) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 105 | #endif |
| 106 | |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 107 | sw $ra, 44($sp) |
| 108 | .cfi_rel_offset 31, 44 |
| 109 | sw $s8, 40($sp) |
| 110 | .cfi_rel_offset 30, 40 |
| 111 | sw $gp, 36($sp) |
| 112 | .cfi_rel_offset 28, 36 |
| 113 | sw $s7, 32($sp) |
| 114 | .cfi_rel_offset 23, 32 |
| 115 | sw $s6, 28($sp) |
| 116 | .cfi_rel_offset 22, 28 |
| 117 | sw $s5, 24($sp) |
| 118 | .cfi_rel_offset 21, 24 |
| 119 | sw $s4, 20($sp) |
| 120 | .cfi_rel_offset 20, 20 |
| 121 | sw $s3, 16($sp) |
| 122 | .cfi_rel_offset 19, 16 |
| 123 | sw $s2, 12($sp) |
| 124 | .cfi_rel_offset 18, 12 |
| 125 | # 2 words for alignment and bottom word will hold Method* |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 126 | |
Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 127 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 128 | lw $t0, 0($t0) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 129 | lw $t0, RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET($t0) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 130 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 131 | 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] | 132 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 133 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 134 | .endm |
| 135 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 136 | .macro RESTORE_SAVE_REFS_ONLY_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 137 | addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack |
| 138 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 139 | lw $ra, 44($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 140 | .cfi_restore 31 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 141 | lw $s8, 40($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 142 | .cfi_restore 30 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 143 | lw $gp, 36($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 144 | .cfi_restore 28 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 145 | lw $s7, 32($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 146 | .cfi_restore 23 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 147 | lw $s6, 28($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 148 | .cfi_restore 22 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 149 | lw $s5, 24($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 150 | .cfi_restore 21 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 151 | lw $s4, 20($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 152 | .cfi_restore 20 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 153 | lw $s3, 16($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 154 | .cfi_restore 19 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 155 | lw $s2, 12($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 156 | .cfi_restore 18 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 157 | addiu $sp, $sp, 48 |
| 158 | .cfi_adjust_cfa_offset -48 |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 159 | .endm |
| 160 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 161 | .macro RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN |
| 162 | RESTORE_SAVE_REFS_ONLY_FRAME |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 163 | jalr $zero, $ra |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 164 | nop |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 165 | .endm |
| 166 | |
| 167 | /* |
| 168 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 169 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 170 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 171 | * (26 total + 1 word padding + method*) |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 172 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 173 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 174 | addiu $sp, $sp, -112 |
| 175 | .cfi_adjust_cfa_offset 112 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 176 | |
| 177 | // Ugly compile-time check, but we only have the preprocessor. |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 178 | #if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 112) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 179 | #error "FRAME_SIZE_SAVE_REFS_AND_ARGS(MIPS) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 180 | #endif |
| 181 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 182 | sw $ra, 108($sp) |
| 183 | .cfi_rel_offset 31, 108 |
| 184 | sw $s8, 104($sp) |
| 185 | .cfi_rel_offset 30, 104 |
| 186 | sw $gp, 100($sp) |
| 187 | .cfi_rel_offset 28, 100 |
| 188 | sw $s7, 96($sp) |
| 189 | .cfi_rel_offset 23, 96 |
| 190 | sw $s6, 92($sp) |
| 191 | .cfi_rel_offset 22, 92 |
| 192 | sw $s5, 88($sp) |
| 193 | .cfi_rel_offset 21, 88 |
| 194 | sw $s4, 84($sp) |
| 195 | .cfi_rel_offset 20, 84 |
| 196 | sw $s3, 80($sp) |
| 197 | .cfi_rel_offset 19, 80 |
| 198 | sw $s2, 76($sp) |
| 199 | .cfi_rel_offset 18, 76 |
| 200 | sw $t1, 72($sp) |
| 201 | .cfi_rel_offset 9, 72 |
| 202 | sw $t0, 68($sp) |
| 203 | .cfi_rel_offset 8, 68 |
| 204 | sw $a3, 64($sp) |
| 205 | .cfi_rel_offset 7, 64 |
| 206 | sw $a2, 60($sp) |
| 207 | .cfi_rel_offset 6, 60 |
| 208 | sw $a1, 56($sp) |
| 209 | .cfi_rel_offset 5, 56 |
| 210 | SDu $f18, $f19, 48, $sp, $t8 |
| 211 | SDu $f16, $f17, 40, $sp, $t8 |
| 212 | SDu $f14, $f15, 32, $sp, $t8 |
| 213 | SDu $f12, $f13, 24, $sp, $t8 |
| 214 | SDu $f10, $f11, 16, $sp, $t8 |
| 215 | SDu $f8, $f9, 8, $sp, $t8 |
jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 216 | # bottom will hold Method* |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 217 | .endm |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 218 | |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 219 | /* |
| 220 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 221 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC. |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 222 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 223 | * (26 total + 1 word padding + method*) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 224 | * Clobbers $t0 and $sp |
| 225 | * 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] | 226 | * 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] | 227 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 228 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME |
| 229 | SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY |
Douglas Leung | 4af77b7 | 2014-10-22 16:32:28 -0700 | [diff] [blame] | 230 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 231 | lw $t0, 0($t0) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 232 | lw $t0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET($t0) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 233 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 234 | 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] | 235 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 236 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| 237 | .endm |
| 238 | |
| 239 | /* |
| 240 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 241 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC. |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 242 | * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19 |
| 243 | * (26 total + 1 word padding + method*) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 244 | * Clobbers $sp |
| 245 | * Use $a0 as the Method* and loads it into bottom of stack. |
| 246 | * 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] | 247 | * 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] | 248 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 249 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
| 250 | SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 251 | sw $a0, 0($sp) # Place Method* at bottom of stack. |
| 252 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 253 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 254 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 255 | .endm |
| 256 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 257 | .macro RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 258 | addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack |
| 259 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 260 | lw $ra, 108($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 261 | .cfi_restore 31 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 262 | lw $s8, 104($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 263 | .cfi_restore 30 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 264 | lw $gp, 100($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 265 | .cfi_restore 28 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 266 | lw $s7, 96($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 267 | .cfi_restore 23 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 268 | lw $s6, 92($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 269 | .cfi_restore 22 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 270 | lw $s5, 88($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 271 | .cfi_restore 21 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 272 | lw $s4, 84($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 273 | .cfi_restore 20 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 274 | lw $s3, 80($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 275 | .cfi_restore 19 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 276 | lw $s2, 76($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 277 | .cfi_restore 18 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 278 | lw $t1, 72($sp) |
| 279 | .cfi_restore 9 |
| 280 | lw $t0, 68($sp) |
| 281 | .cfi_restore 8 |
| 282 | lw $a3, 64($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 283 | .cfi_restore 7 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 284 | lw $a2, 60($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 285 | .cfi_restore 6 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 286 | lw $a1, 56($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 287 | .cfi_restore 5 |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 288 | LDu $f18, $f19, 48, $sp, $t8 |
| 289 | LDu $f16, $f17, 40, $sp, $t8 |
| 290 | LDu $f14, $f15, 32, $sp, $t8 |
| 291 | LDu $f12, $f13, 24, $sp, $t8 |
| 292 | LDu $f10, $f11, 16, $sp, $t8 |
| 293 | LDu $f8, $f9, 8, $sp, $t8 |
| 294 | addiu $sp, $sp, 112 # pop frame |
| 295 | .cfi_adjust_cfa_offset -112 |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 296 | .endm |
| 297 | |
| 298 | /* |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 299 | * Macro that sets up the callee save frame to conform with |
| 300 | * Runtime::CreateCalleeSaveMethod(kSaveEverything). |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 301 | * when the $sp has already been decremented by FRAME_SIZE_SAVE_EVERYTHING. |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 302 | * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31; |
| 303 | * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method* |
| 304 | * Clobbers $t0 and $t1. |
| 305 | * 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] | 306 | * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack. |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 307 | * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP. |
| 308 | */ |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 309 | .macro SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 310 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 311 | #if (FRAME_SIZE_SAVE_EVERYTHING != 256) |
| 312 | #error "FRAME_SIZE_SAVE_EVERYTHING(MIPS) size not as expected." |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 313 | #endif |
| 314 | |
| 315 | sw $ra, 252($sp) |
| 316 | .cfi_rel_offset 31, 252 |
| 317 | sw $fp, 248($sp) |
| 318 | .cfi_rel_offset 30, 248 |
| 319 | sw $gp, 244($sp) |
| 320 | .cfi_rel_offset 28, 244 |
| 321 | sw $t9, 240($sp) |
| 322 | .cfi_rel_offset 25, 240 |
| 323 | sw $t8, 236($sp) |
| 324 | .cfi_rel_offset 24, 236 |
| 325 | sw $s7, 232($sp) |
| 326 | .cfi_rel_offset 23, 232 |
| 327 | sw $s6, 228($sp) |
| 328 | .cfi_rel_offset 22, 228 |
| 329 | sw $s5, 224($sp) |
| 330 | .cfi_rel_offset 21, 224 |
| 331 | sw $s4, 220($sp) |
| 332 | .cfi_rel_offset 20, 220 |
| 333 | sw $s3, 216($sp) |
| 334 | .cfi_rel_offset 19, 216 |
| 335 | sw $s2, 212($sp) |
| 336 | .cfi_rel_offset 18, 212 |
| 337 | sw $s1, 208($sp) |
| 338 | .cfi_rel_offset 17, 208 |
| 339 | sw $s0, 204($sp) |
| 340 | .cfi_rel_offset 16, 204 |
| 341 | sw $t7, 200($sp) |
| 342 | .cfi_rel_offset 15, 200 |
| 343 | sw $t6, 196($sp) |
| 344 | .cfi_rel_offset 14, 196 |
| 345 | sw $t5, 192($sp) |
| 346 | .cfi_rel_offset 13, 192 |
| 347 | sw $t4, 188($sp) |
| 348 | .cfi_rel_offset 12, 188 |
| 349 | sw $t3, 184($sp) |
| 350 | .cfi_rel_offset 11, 184 |
| 351 | sw $t2, 180($sp) |
| 352 | .cfi_rel_offset 10, 180 |
| 353 | sw $t1, 176($sp) |
| 354 | .cfi_rel_offset 9, 176 |
| 355 | sw $t0, 172($sp) |
| 356 | .cfi_rel_offset 8, 172 |
| 357 | sw $a3, 168($sp) |
| 358 | .cfi_rel_offset 7, 168 |
| 359 | sw $a2, 164($sp) |
| 360 | .cfi_rel_offset 6, 164 |
| 361 | sw $a1, 160($sp) |
| 362 | .cfi_rel_offset 5, 160 |
| 363 | sw $a0, 156($sp) |
| 364 | .cfi_rel_offset 4, 156 |
| 365 | sw $v1, 152($sp) |
| 366 | .cfi_rel_offset 3, 152 |
| 367 | sw $v0, 148($sp) |
| 368 | .cfi_rel_offset 2, 148 |
| 369 | |
| 370 | // Set up $gp, clobbering $ra and using the branch delay slot for a useful instruction. |
| 371 | bal 1f |
Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 372 | .set push |
| 373 | .set noat |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 374 | sw $at, 144($sp) |
| 375 | .cfi_rel_offset 1, 144 |
Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 376 | .set pop |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 377 | 1: |
| 378 | .cpload $ra |
| 379 | |
| 380 | SDu $f30, $f31, 136, $sp, $t1 |
| 381 | SDu $f28, $f29, 128, $sp, $t1 |
| 382 | SDu $f26, $f27, 120, $sp, $t1 |
| 383 | SDu $f24, $f25, 112, $sp, $t1 |
| 384 | SDu $f22, $f23, 104, $sp, $t1 |
| 385 | SDu $f20, $f21, 96, $sp, $t1 |
| 386 | SDu $f18, $f19, 88, $sp, $t1 |
| 387 | SDu $f16, $f17, 80, $sp, $t1 |
| 388 | SDu $f14, $f15, 72, $sp, $t1 |
| 389 | SDu $f12, $f13, 64, $sp, $t1 |
| 390 | SDu $f10, $f11, 56, $sp, $t1 |
| 391 | SDu $f8, $f9, 48, $sp, $t1 |
| 392 | SDu $f6, $f7, 40, $sp, $t1 |
| 393 | SDu $f4, $f5, 32, $sp, $t1 |
| 394 | SDu $f2, $f3, 24, $sp, $t1 |
| 395 | SDu $f0, $f1, 16, $sp, $t1 |
| 396 | |
| 397 | # 3 words padding and 1 word for holding Method* |
| 398 | |
| 399 | lw $t0, %got(_ZN3art7Runtime9instance_E)($gp) |
| 400 | lw $t0, 0($t0) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 401 | lw $t0, RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET($t0) |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 402 | sw $t0, 0($sp) # Place Method* at bottom of stack. |
| 403 | sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame. |
| 404 | addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack |
| 405 | .cfi_adjust_cfa_offset ARG_SLOT_SIZE |
| 406 | .endm |
| 407 | |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 408 | /* |
| 409 | * Macro that sets up the callee save frame to conform with |
| 410 | * Runtime::CreateCalleeSaveMethod(kSaveEverything). |
| 411 | * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31; |
| 412 | * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method* |
| 413 | * Clobbers $t0 and $t1. |
| 414 | * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots. |
| 415 | * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack. |
| 416 | * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP. |
| 417 | */ |
| 418 | .macro SETUP_SAVE_EVERYTHING_FRAME |
| 419 | addiu $sp, $sp, -(FRAME_SIZE_SAVE_EVERYTHING) |
| 420 | .cfi_adjust_cfa_offset (FRAME_SIZE_SAVE_EVERYTHING) |
| 421 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP |
| 422 | .endm |
| 423 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 424 | .macro RESTORE_SAVE_EVERYTHING_FRAME |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 425 | addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack |
| 426 | .cfi_adjust_cfa_offset -ARG_SLOT_SIZE |
| 427 | |
| 428 | LDu $f30, $f31, 136, $sp, $t1 |
| 429 | LDu $f28, $f29, 128, $sp, $t1 |
| 430 | LDu $f26, $f27, 120, $sp, $t1 |
| 431 | LDu $f24, $f25, 112, $sp, $t1 |
| 432 | LDu $f22, $f23, 104, $sp, $t1 |
| 433 | LDu $f20, $f21, 96, $sp, $t1 |
| 434 | LDu $f18, $f19, 88, $sp, $t1 |
| 435 | LDu $f16, $f17, 80, $sp, $t1 |
| 436 | LDu $f14, $f15, 72, $sp, $t1 |
| 437 | LDu $f12, $f13, 64, $sp, $t1 |
| 438 | LDu $f10, $f11, 56, $sp, $t1 |
| 439 | LDu $f8, $f9, 48, $sp, $t1 |
| 440 | LDu $f6, $f7, 40, $sp, $t1 |
| 441 | LDu $f4, $f5, 32, $sp, $t1 |
| 442 | LDu $f2, $f3, 24, $sp, $t1 |
| 443 | LDu $f0, $f1, 16, $sp, $t1 |
| 444 | |
| 445 | lw $ra, 252($sp) |
| 446 | .cfi_restore 31 |
| 447 | lw $fp, 248($sp) |
| 448 | .cfi_restore 30 |
| 449 | lw $gp, 244($sp) |
| 450 | .cfi_restore 28 |
| 451 | lw $t9, 240($sp) |
| 452 | .cfi_restore 25 |
| 453 | lw $t8, 236($sp) |
| 454 | .cfi_restore 24 |
| 455 | lw $s7, 232($sp) |
| 456 | .cfi_restore 23 |
| 457 | lw $s6, 228($sp) |
| 458 | .cfi_restore 22 |
| 459 | lw $s5, 224($sp) |
| 460 | .cfi_restore 21 |
| 461 | lw $s4, 220($sp) |
| 462 | .cfi_restore 20 |
| 463 | lw $s3, 216($sp) |
| 464 | .cfi_restore 19 |
| 465 | lw $s2, 212($sp) |
| 466 | .cfi_restore 18 |
| 467 | lw $s1, 208($sp) |
| 468 | .cfi_restore 17 |
| 469 | lw $s0, 204($sp) |
| 470 | .cfi_restore 16 |
| 471 | lw $t7, 200($sp) |
| 472 | .cfi_restore 15 |
| 473 | lw $t6, 196($sp) |
| 474 | .cfi_restore 14 |
| 475 | lw $t5, 192($sp) |
| 476 | .cfi_restore 13 |
| 477 | lw $t4, 188($sp) |
| 478 | .cfi_restore 12 |
| 479 | lw $t3, 184($sp) |
| 480 | .cfi_restore 11 |
| 481 | lw $t2, 180($sp) |
| 482 | .cfi_restore 10 |
| 483 | lw $t1, 176($sp) |
| 484 | .cfi_restore 9 |
| 485 | lw $t0, 172($sp) |
| 486 | .cfi_restore 8 |
| 487 | lw $a3, 168($sp) |
| 488 | .cfi_restore 7 |
| 489 | lw $a2, 164($sp) |
| 490 | .cfi_restore 6 |
| 491 | lw $a1, 160($sp) |
| 492 | .cfi_restore 5 |
| 493 | lw $a0, 156($sp) |
| 494 | .cfi_restore 4 |
| 495 | lw $v1, 152($sp) |
| 496 | .cfi_restore 3 |
| 497 | lw $v0, 148($sp) |
| 498 | .cfi_restore 2 |
Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 499 | .set push |
| 500 | .set noat |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 501 | lw $at, 144($sp) |
| 502 | .cfi_restore 1 |
Goran Jakovljevic | 2e42cf1 | 2016-08-09 15:15:39 +0200 | [diff] [blame] | 503 | .set pop |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 504 | |
| 505 | addiu $sp, $sp, 256 # pop frame |
| 506 | .cfi_adjust_cfa_offset -256 |
| 507 | .endm |
| 508 | |
| 509 | /* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 510 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 511 | * exception is Thread::Current()->exception_ |
| 512 | */ |
| 513 | .macro DELIVER_PENDING_EXCEPTION |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 514 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME # save callee saves for throw |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 515 | la $t9, artDeliverPendingExceptionFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 516 | jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 517 | move $a0, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 518 | .endm |
| 519 | |
| 520 | .macro RETURN_IF_NO_EXCEPTION |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 521 | lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 522 | RESTORE_SAVE_REFS_ONLY_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 523 | bnez $t0, 1f # success if no exception is pending |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 524 | nop |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 525 | jalr $zero, $ra |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 526 | nop |
| 527 | 1: |
| 528 | DELIVER_PENDING_EXCEPTION |
| 529 | .endm |
| 530 | |
| 531 | .macro RETURN_IF_ZERO |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 532 | RESTORE_SAVE_REFS_ONLY_FRAME |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 533 | bnez $v0, 1f # success? |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 534 | nop |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 535 | jalr $zero, $ra # return on success |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 536 | nop |
| 537 | 1: |
| 538 | DELIVER_PENDING_EXCEPTION |
| 539 | .endm |
| 540 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 541 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 542 | RESTORE_SAVE_REFS_ONLY_FRAME |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 543 | beqz $v0, 1f # success? |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 544 | nop |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 545 | jalr $zero, $ra # return on success |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 546 | nop |
| 547 | 1: |
| 548 | DELIVER_PENDING_EXCEPTION |
| 549 | .endm |
| 550 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 551 | /* |
Goran Jakovljevic | 3bc1381 | 2016-03-22 17:16:05 +0100 | [diff] [blame] | 552 | * On stack replacement stub. |
| 553 | * On entry: |
| 554 | * a0 = stack to copy |
| 555 | * a1 = size of stack |
| 556 | * a2 = pc to call |
| 557 | * a3 = JValue* result |
| 558 | * [sp + 16] = shorty |
| 559 | * [sp + 20] = thread |
| 560 | */ |
| 561 | ENTRY art_quick_osr_stub |
| 562 | // Save callee general purpose registers, RA and GP. |
| 563 | addiu $sp, $sp, -48 |
| 564 | .cfi_adjust_cfa_offset 48 |
| 565 | sw $ra, 44($sp) |
| 566 | .cfi_rel_offset 31, 44 |
| 567 | sw $s8, 40($sp) |
| 568 | .cfi_rel_offset 30, 40 |
| 569 | sw $gp, 36($sp) |
| 570 | .cfi_rel_offset 28, 36 |
| 571 | sw $s7, 32($sp) |
| 572 | .cfi_rel_offset 23, 32 |
| 573 | sw $s6, 28($sp) |
| 574 | .cfi_rel_offset 22, 28 |
| 575 | sw $s5, 24($sp) |
| 576 | .cfi_rel_offset 21, 24 |
| 577 | sw $s4, 20($sp) |
| 578 | .cfi_rel_offset 20, 20 |
| 579 | sw $s3, 16($sp) |
| 580 | .cfi_rel_offset 19, 16 |
| 581 | sw $s2, 12($sp) |
| 582 | .cfi_rel_offset 18, 12 |
| 583 | sw $s1, 8($sp) |
| 584 | .cfi_rel_offset 17, 8 |
| 585 | sw $s0, 4($sp) |
| 586 | .cfi_rel_offset 16, 4 |
| 587 | |
| 588 | move $s8, $sp # Save the stack pointer |
| 589 | move $s7, $a1 # Save size of stack |
| 590 | move $s6, $a2 # Save the pc to call |
| 591 | lw rSELF, 48+20($sp) # Save managed thread pointer into rSELF |
| 592 | addiu $t0, $sp, -12 # Reserve space for stack pointer, |
| 593 | # JValue* result, and ArtMethod* slot. |
| 594 | srl $t0, $t0, 4 # Align stack pointer to 16 bytes |
| 595 | sll $sp, $t0, 4 # Update stack pointer |
| 596 | sw $s8, 4($sp) # Save old stack pointer |
| 597 | sw $a3, 8($sp) # Save JValue* result |
| 598 | sw $zero, 0($sp) # Store null for ArtMethod* at bottom of frame |
| 599 | subu $sp, $a1 # Reserve space for callee stack |
| 600 | move $a2, $a1 |
| 601 | move $a1, $a0 |
| 602 | move $a0, $sp |
| 603 | la $t9, memcpy |
| 604 | jalr $t9 # memcpy (dest a0, src a1, bytes a2) |
| 605 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 606 | bal .Losr_entry # Call the method |
| 607 | addiu $sp, $sp, 16 # restore stack after memcpy |
| 608 | lw $a2, 8($sp) # Restore JValue* result |
| 609 | lw $sp, 4($sp) # Restore saved stack pointer |
| 610 | lw $a0, 48+16($sp) # load shorty |
| 611 | lbu $a0, 0($a0) # load return type |
| 612 | li $a1, 'D' # put char 'D' into a1 |
| 613 | beq $a0, $a1, .Losr_fp_result # Test if result type char == 'D' |
| 614 | li $a1, 'F' # put char 'F' into a1 |
| 615 | beq $a0, $a1, .Losr_fp_result # Test if result type char == 'F' |
| 616 | nop |
| 617 | sw $v0, 0($a2) |
| 618 | b .Losr_exit |
| 619 | sw $v1, 4($a2) # store v0/v1 into result |
| 620 | .Losr_fp_result: |
| 621 | SDu $f0, $f1, 0, $a2, $t0 # store f0/f1 into result |
| 622 | .Losr_exit: |
| 623 | lw $ra, 44($sp) |
| 624 | .cfi_restore 31 |
| 625 | lw $s8, 40($sp) |
| 626 | .cfi_restore 30 |
| 627 | lw $gp, 36($sp) |
| 628 | .cfi_restore 28 |
| 629 | lw $s7, 32($sp) |
| 630 | .cfi_restore 23 |
| 631 | lw $s6, 28($sp) |
| 632 | .cfi_restore 22 |
| 633 | lw $s5, 24($sp) |
| 634 | .cfi_restore 21 |
| 635 | lw $s4, 20($sp) |
| 636 | .cfi_restore 20 |
| 637 | lw $s3, 16($sp) |
| 638 | .cfi_restore 19 |
| 639 | lw $s2, 12($sp) |
| 640 | .cfi_restore 18 |
| 641 | lw $s1, 8($sp) |
| 642 | .cfi_restore 17 |
| 643 | lw $s0, 4($sp) |
| 644 | .cfi_restore 16 |
| 645 | jalr $zero, $ra |
| 646 | addiu $sp, $sp, 48 |
| 647 | .cfi_adjust_cfa_offset -48 |
| 648 | .Losr_entry: |
| 649 | addiu $s7, $s7, -4 |
| 650 | addu $t0, $s7, $sp |
| 651 | move $t9, $s6 |
| 652 | jalr $zero, $t9 |
| 653 | sw $ra, 0($t0) # Store RA per the compiler ABI |
| 654 | END art_quick_osr_stub |
| 655 | |
| 656 | /* |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 657 | * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_ |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 658 | * FIXME: just guessing about the shape of the jmpbuf. Where will pc be? |
| 659 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 660 | ENTRY art_quick_do_long_jump |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 661 | LDu $f0, $f1, 0*8, $a1, $t1 |
| 662 | LDu $f2, $f3, 1*8, $a1, $t1 |
| 663 | LDu $f4, $f5, 2*8, $a1, $t1 |
| 664 | LDu $f6, $f7, 3*8, $a1, $t1 |
| 665 | LDu $f8, $f9, 4*8, $a1, $t1 |
| 666 | LDu $f10, $f11, 5*8, $a1, $t1 |
| 667 | LDu $f12, $f13, 6*8, $a1, $t1 |
| 668 | LDu $f14, $f15, 7*8, $a1, $t1 |
| 669 | LDu $f16, $f17, 8*8, $a1, $t1 |
| 670 | LDu $f18, $f19, 9*8, $a1, $t1 |
| 671 | LDu $f20, $f21, 10*8, $a1, $t1 |
| 672 | LDu $f22, $f23, 11*8, $a1, $t1 |
| 673 | LDu $f24, $f25, 12*8, $a1, $t1 |
| 674 | LDu $f26, $f27, 13*8, $a1, $t1 |
| 675 | LDu $f28, $f29, 14*8, $a1, $t1 |
| 676 | LDu $f30, $f31, 15*8, $a1, $t1 |
| 677 | |
Chris Dearman | 748dd95 | 2014-05-23 10:47:01 -0700 | [diff] [blame] | 678 | .set push |
| 679 | .set nomacro |
| 680 | .set noat |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 681 | lw $at, 4($a0) |
Chris Dearman | 748dd95 | 2014-05-23 10:47:01 -0700 | [diff] [blame] | 682 | .set pop |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 683 | lw $v0, 8($a0) |
| 684 | lw $v1, 12($a0) |
| 685 | lw $a1, 20($a0) |
| 686 | lw $a2, 24($a0) |
| 687 | lw $a3, 28($a0) |
| 688 | lw $t0, 32($a0) |
| 689 | lw $t1, 36($a0) |
| 690 | lw $t2, 40($a0) |
| 691 | lw $t3, 44($a0) |
| 692 | lw $t4, 48($a0) |
| 693 | lw $t5, 52($a0) |
| 694 | lw $t6, 56($a0) |
| 695 | lw $t7, 60($a0) |
| 696 | lw $s0, 64($a0) |
| 697 | lw $s1, 68($a0) |
| 698 | lw $s2, 72($a0) |
| 699 | lw $s3, 76($a0) |
| 700 | lw $s4, 80($a0) |
| 701 | lw $s5, 84($a0) |
| 702 | lw $s6, 88($a0) |
| 703 | lw $s7, 92($a0) |
| 704 | lw $t8, 96($a0) |
| 705 | lw $t9, 100($a0) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 706 | lw $gp, 112($a0) |
| 707 | lw $sp, 116($a0) |
| 708 | lw $fp, 120($a0) |
| 709 | lw $ra, 124($a0) |
| 710 | lw $a0, 16($a0) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 711 | 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] | 712 | jalr $zero, $t9 # do long jump |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 713 | move $v1, $zero |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 714 | END art_quick_do_long_jump |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 715 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 716 | /* |
| 717 | * Called by managed code, saves most registers (forms basis of long jump context) and passes |
| 718 | * 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] | 719 | * the bottom of the thread. On entry a0 holds Throwable* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 720 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 721 | ENTRY art_quick_deliver_exception |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 722 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 723 | la $t9, artDeliverExceptionFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 724 | jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 725 | move $a1, rSELF # pass Thread::Current |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 726 | END art_quick_deliver_exception |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 727 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 728 | /* |
| 729 | * Called by managed code to create and deliver a NullPointerException |
| 730 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 731 | .extern artThrowNullPointerExceptionFromCode |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 732 | ENTRY_NO_GP art_quick_throw_null_pointer_exception |
| 733 | // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK, |
| 734 | // even after clobbering any registers we don't need to preserve, such as $gp or $t0. |
| 735 | SETUP_SAVE_EVERYTHING_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 736 | la $t9, artThrowNullPointerExceptionFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 737 | jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 738 | move $a0, rSELF # pass Thread::Current |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 739 | END art_quick_throw_null_pointer_exception |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 740 | |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 741 | |
| 742 | /* |
| 743 | * Call installed by a signal handler to create and deliver a NullPointerException. |
| 744 | */ |
| 745 | .extern artThrowNullPointerExceptionFromSignal |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 746 | ENTRY_NO_GP_CUSTOM_CFA art_quick_throw_null_pointer_exception_from_signal, FRAME_SIZE_SAVE_EVERYTHING |
| 747 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP |
| 748 | # Retrieve the fault address from the padding where the signal handler stores it. |
| 749 | lw $a0, (ARG_SLOT_SIZE + __SIZEOF_POINTER__)($sp) |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 750 | la $t9, artThrowNullPointerExceptionFromSignal |
| 751 | jalr $zero, $t9 # artThrowNullPointerExceptionFromSignal(uintptr_t, Thread*) |
| 752 | move $a1, rSELF # pass Thread::Current |
| 753 | END art_quick_throw_null_pointer_exception_from_signal |
| 754 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 755 | /* |
| 756 | * Called by managed code to create and deliver an ArithmeticException |
| 757 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 758 | .extern artThrowDivZeroFromCode |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 759 | ENTRY_NO_GP art_quick_throw_div_zero |
| 760 | SETUP_SAVE_EVERYTHING_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 761 | la $t9, artThrowDivZeroFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 762 | jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 763 | move $a0, rSELF # pass Thread::Current |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 764 | END art_quick_throw_div_zero |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 765 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 766 | /* |
| 767 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException |
| 768 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 769 | .extern artThrowArrayBoundsFromCode |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 770 | ENTRY_NO_GP art_quick_throw_array_bounds |
| 771 | // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK, |
| 772 | // even after clobbering any registers we don't need to preserve, such as $gp or $t0. |
| 773 | SETUP_SAVE_EVERYTHING_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 774 | la $t9, artThrowArrayBoundsFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 775 | jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 776 | move $a2, rSELF # pass Thread::Current |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 777 | END art_quick_throw_array_bounds |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 778 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 779 | /* |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 780 | * Called by managed code to create and deliver a StringIndexOutOfBoundsException |
| 781 | * as if thrown from a call to String.charAt(). |
| 782 | */ |
| 783 | .extern artThrowStringBoundsFromCode |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 784 | ENTRY_NO_GP art_quick_throw_string_bounds |
| 785 | SETUP_SAVE_EVERYTHING_FRAME |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 786 | la $t9, artThrowStringBoundsFromCode |
| 787 | jalr $zero, $t9 # artThrowStringBoundsFromCode(index, limit, Thread*) |
| 788 | move $a2, rSELF # pass Thread::Current |
| 789 | END art_quick_throw_string_bounds |
| 790 | |
| 791 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 792 | * Called by managed code to create and deliver a StackOverflowError. |
| 793 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 794 | .extern artThrowStackOverflowFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 795 | ENTRY art_quick_throw_stack_overflow |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 796 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 797 | la $t9, artThrowStackOverflowFromCode |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 798 | jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 799 | move $a0, rSELF # pass Thread::Current |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 800 | END art_quick_throw_stack_overflow |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 801 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 802 | /* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 803 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 804 | * 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] | 805 | * 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] | 806 | * 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] | 807 | * |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 808 | * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting |
| 809 | * of the target Method* in $v0 and method->code_ in $v1. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 810 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 811 | * 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] | 812 | * thread and we branch to another stub to deliver it. |
| 813 | * |
| 814 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 815 | * pointing back to the original caller. |
| 816 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 817 | .macro INVOKE_TRAMPOLINE_BODY cxx_name |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 818 | .extern \cxx_name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 819 | SETUP_SAVE_REFS_AND_ARGS_FRAME # save callee saves in case allocation triggers GC |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 820 | move $a2, rSELF # pass Thread::Current |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 821 | la $t9, \cxx_name |
| 822 | jalr $t9 # (method_idx, this, Thread*, $sp) |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 823 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
| 824 | move $a0, $v0 # save target Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 825 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 826 | beqz $v0, 1f |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 827 | move $t9, $v1 # save $v0->code_ |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 828 | jalr $zero, $t9 |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 829 | nop |
| 830 | 1: |
| 831 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 832 | .endm |
| 833 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 834 | ENTRY \c_name |
| 835 | INVOKE_TRAMPOLINE_BODY \cxx_name |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 836 | END \c_name |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 837 | .endm |
| 838 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 839 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 840 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 841 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 842 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 843 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 844 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 845 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 846 | // Each of the following macros expands into four instructions or 16 bytes. |
| 847 | // They are used to build indexable "tables" of code. |
| 848 | |
| 849 | .macro LOAD_WORD_TO_REG reg, next_arg, index_reg, label |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 850 | lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4) |
| 851 | b \label |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 852 | addiu $\index_reg, 16 |
| 853 | .balign 16 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 854 | .endm |
| 855 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 856 | .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] | 857 | lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8) |
| 858 | lw $\reg2, -4($\next_arg) |
| 859 | b \label |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 860 | li $\index_reg, \next_index |
| 861 | .balign 16 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 862 | .endm |
| 863 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 864 | .macro LOAD_FLOAT_TO_REG reg, next_arg, index_reg, label |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 865 | lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4) |
| 866 | b \label |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 867 | addiu $\index_reg, 16 |
| 868 | .balign 16 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 869 | .endm |
| 870 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 871 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 872 | // LDu expands into 3 instructions for 64-bit FPU, so index_reg cannot be updated here. |
| 873 | .macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label |
| 874 | .set reorder # force use of the branch delay slot |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 875 | LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one |
| 876 | # (offset is 8) |
| 877 | b \label |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 878 | .set noreorder |
| 879 | .balign 16 |
| 880 | .endm |
| 881 | #else |
| 882 | // LDu expands into 2 instructions for 32-bit FPU, so index_reg is updated here. |
| 883 | .macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label |
| 884 | LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one |
| 885 | # (offset is 8) |
| 886 | b \label |
| 887 | addiu $\index_reg, 16 |
| 888 | .balign 16 |
| 889 | .endm |
| 890 | #endif |
| 891 | |
| 892 | .macro LOAD_END index_reg, next_index, label |
| 893 | b \label |
| 894 | li $\index_reg, \next_index |
| 895 | .balign 16 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 896 | .endm |
| 897 | |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 898 | #define SPILL_SIZE 32 |
| 899 | |
Jeff Hao | 79fe539 | 2013-04-24 18:41:58 -0700 | [diff] [blame] | 900 | /* |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 901 | * Invocation stub for quick code. |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 902 | * On entry: |
| 903 | * a0 = method pointer |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 904 | * a1 = argument array or null for no argument methods |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 905 | * a2 = size of argument array in bytes |
| 906 | * a3 = (managed) thread pointer |
Jeff Hao | 6474d19 | 2013-03-26 14:08:09 -0700 | [diff] [blame] | 907 | * [sp + 16] = JValue* result |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 908 | * [sp + 20] = shorty |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 909 | */ |
| 910 | ENTRY art_quick_invoke_stub |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 911 | sw $a0, 0($sp) # save out a0 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 912 | addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp |
| 913 | .cfi_adjust_cfa_offset SPILL_SIZE |
| 914 | sw $gp, 16($sp) |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 915 | sw $ra, 12($sp) |
| 916 | .cfi_rel_offset 31, 12 |
| 917 | sw $fp, 8($sp) |
| 918 | .cfi_rel_offset 30, 8 |
| 919 | sw $s1, 4($sp) |
| 920 | .cfi_rel_offset 17, 4 |
| 921 | sw $s0, 0($sp) |
| 922 | .cfi_rel_offset 16, 0 |
| 923 | move $fp, $sp # save sp in fp |
| 924 | .cfi_def_cfa_register 30 |
| 925 | move $s1, $a3 # move managed thread pointer into s1 |
| 926 | addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 927 | addiu $t0, $a2, 4 # create space for ArtMethod* in frame. |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 928 | subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes: |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 929 | srl $t0, $t0, 4 # native calling convention only aligns to 8B, |
| 930 | sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves. |
| 931 | addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 932 | la $t9, memcpy |
| 933 | jalr $t9 # (dest, src, bytes) |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 934 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 935 | addiu $sp, $sp, 16 # restore stack after memcpy |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 936 | lw $gp, 16($fp) # restore $gp |
| 937 | lw $a0, SPILL_SIZE($fp) # restore ArtMethod* |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 938 | lw $a1, 4($sp) # a1 = this* |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 939 | addiu $t8, $sp, 8 # t8 = pointer to the current argument (skip ArtMethod* and this*) |
| 940 | li $t6, 0 # t6 = gpr_index = 0 (corresponds to A2; A0 and A1 are skipped) |
| 941 | li $t7, 0 # t7 = fp_index = 0 |
| 942 | 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] | 943 | # as the $fp is SPILL_SIZE bytes below the $sp on entry) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 944 | addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type) |
| 945 | |
| 946 | // Load the base addresses of tabInt ... tabDouble. |
| 947 | // We will use the register indices (gpr_index, fp_index) to branch. |
| 948 | // Note that the indices are scaled by 16, so they can be added to the bases directly. |
| 949 | #if defined(__mips_isa_rev) && __mips_isa_rev >= 6 |
| 950 | lapc $t2, tabInt |
| 951 | lapc $t3, tabLong |
| 952 | lapc $t4, tabSingle |
| 953 | lapc $t5, tabDouble |
| 954 | #else |
| 955 | bltzal $zero, tabBase # nal |
| 956 | addiu $t2, $ra, %lo(tabInt - tabBase) |
| 957 | tabBase: |
| 958 | addiu $t3, $ra, %lo(tabLong - tabBase) |
| 959 | addiu $t4, $ra, %lo(tabSingle - tabBase) |
| 960 | addiu $t5, $ra, %lo(tabDouble - tabBase) |
| 961 | #endif |
| 962 | |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 963 | loop: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 964 | lbu $ra, 0($t9) # ra = shorty[i] |
| 965 | beqz $ra, loopEnd # finish getting args when shorty[i] == '\0' |
| 966 | addiu $t9, 1 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 967 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 968 | addiu $ra, -'J' |
| 969 | beqz $ra, isLong # branch if result type char == 'J' |
| 970 | addiu $ra, 'J' - 'D' |
| 971 | beqz $ra, isDouble # branch if result type char == 'D' |
| 972 | addiu $ra, 'D' - 'F' |
| 973 | beqz $ra, isSingle # branch if result type char == 'F' |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 974 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 975 | addu $ra, $t2, $t6 |
| 976 | jalr $zero, $ra |
| 977 | addiu $t8, 4 # next_arg = curr_arg + 4 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 978 | |
| 979 | isLong: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 980 | addu $ra, $t3, $t6 |
| 981 | jalr $zero, $ra |
| 982 | addiu $t8, 8 # next_arg = curr_arg + 8 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 983 | |
| 984 | isSingle: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 985 | addu $ra, $t4, $t7 |
| 986 | jalr $zero, $ra |
| 987 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| 988 | |
| 989 | isDouble: |
| 990 | addu $ra, $t5, $t7 |
| 991 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 992 | addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG |
| 993 | #endif |
| 994 | jalr $zero, $ra |
| 995 | addiu $t8, 8 # next_arg = curr_arg + 8 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 996 | |
| 997 | loopEnd: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 998 | 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] | 999 | jalr $t9 # call the method |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1000 | sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1001 | move $sp, $fp # restore the stack |
| 1002 | lw $s0, 0($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1003 | .cfi_restore 16 |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1004 | lw $s1, 4($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1005 | .cfi_restore 17 |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1006 | lw $fp, 8($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1007 | .cfi_restore 30 |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1008 | lw $ra, 12($sp) |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 1009 | .cfi_restore 31 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1010 | addiu $sp, $sp, SPILL_SIZE |
| 1011 | .cfi_adjust_cfa_offset -SPILL_SIZE |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1012 | lw $t0, 16($sp) # get result pointer |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 1013 | lw $t1, 20($sp) # get shorty |
| 1014 | lb $t1, 0($t1) # get result type char |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1015 | li $t2, 'D' # put char 'D' into t2 |
| 1016 | beq $t1, $t2, 5f # branch if result type char == 'D' |
| 1017 | li $t3, 'F' # put char 'F' into t3 |
| 1018 | beq $t1, $t3, 5f # branch if result type char == 'F' |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1019 | sw $v0, 0($t0) # store the result |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1020 | jalr $zero, $ra |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 1021 | sw $v1, 4($t0) # store the other half of the result |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1022 | 5: |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1023 | SDu $f0, $f1, 0, $t0, $t1 # store floating point result |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1024 | jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1025 | nop |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1026 | |
| 1027 | // Note that gpr_index is kept within the range of tabInt and tabLong |
| 1028 | // and fp_index is kept within the range of tabSingle and tabDouble. |
| 1029 | .balign 16 |
| 1030 | tabInt: |
| 1031 | LOAD_WORD_TO_REG a2, t8, t6, loop # a2 = current argument, gpr_index += 16 |
| 1032 | LOAD_WORD_TO_REG a3, t8, t6, loop # a3 = current argument, gpr_index += 16 |
| 1033 | LOAD_WORD_TO_REG t0, t8, t6, loop # t0 = current argument, gpr_index += 16 |
| 1034 | LOAD_WORD_TO_REG t1, t8, t6, loop # t1 = current argument, gpr_index += 16 |
| 1035 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1036 | tabLong: |
| 1037 | LOAD_LONG_TO_REG a2, a3, t8, t6, 2*16, loop # a2_a3 = curr_arg, gpr_index = 2*16 |
| 1038 | LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16 |
| 1039 | LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16 |
| 1040 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1041 | LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16 |
| 1042 | tabSingle: |
| 1043 | LOAD_FLOAT_TO_REG f8, t8, t7, loop # f8 = curr_arg, fp_index += 16 |
| 1044 | LOAD_FLOAT_TO_REG f10, t8, t7, loop # f10 = curr_arg, fp_index += 16 |
| 1045 | LOAD_FLOAT_TO_REG f12, t8, t7, loop # f12 = curr_arg, fp_index += 16 |
| 1046 | LOAD_FLOAT_TO_REG f14, t8, t7, loop # f14 = curr_arg, fp_index += 16 |
| 1047 | LOAD_FLOAT_TO_REG f16, t8, t7, loop # f16 = curr_arg, fp_index += 16 |
| 1048 | LOAD_FLOAT_TO_REG f18, t8, t7, loop # f18 = curr_arg, fp_index += 16 |
| 1049 | LOAD_END t7, 6*16, loop # no more FPR args, fp_index = 6*16 |
| 1050 | tabDouble: |
| 1051 | LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loop # f8_f9 = curr_arg; if FPU32, fp_index += 16 |
| 1052 | LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loop # f10_f11 = curr_arg; if FPU32, fp_index += 16 |
| 1053 | LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loop # f12_f13 = curr_arg; if FPU32, fp_index += 16 |
| 1054 | LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loop # f14_f15 = curr_arg; if FPU32, fp_index += 16 |
| 1055 | LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loop # f16_f17 = curr_arg; if FPU32, fp_index += 16 |
| 1056 | LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loop # f18_f19 = curr_arg; if FPU32, fp_index += 16 |
| 1057 | 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] | 1058 | END art_quick_invoke_stub |
| 1059 | |
| 1060 | /* |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1061 | * Invocation static stub for quick code. |
| 1062 | * On entry: |
| 1063 | * a0 = method pointer |
| 1064 | * a1 = argument array or null for no argument methods |
| 1065 | * a2 = size of argument array in bytes |
| 1066 | * a3 = (managed) thread pointer |
| 1067 | * [sp + 16] = JValue* result |
| 1068 | * [sp + 20] = shorty |
| 1069 | */ |
| 1070 | ENTRY art_quick_invoke_static_stub |
| 1071 | sw $a0, 0($sp) # save out a0 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1072 | addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp |
| 1073 | .cfi_adjust_cfa_offset SPILL_SIZE |
| 1074 | sw $gp, 16($sp) |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1075 | sw $ra, 12($sp) |
| 1076 | .cfi_rel_offset 31, 12 |
| 1077 | sw $fp, 8($sp) |
| 1078 | .cfi_rel_offset 30, 8 |
| 1079 | sw $s1, 4($sp) |
| 1080 | .cfi_rel_offset 17, 4 |
| 1081 | sw $s0, 0($sp) |
| 1082 | .cfi_rel_offset 16, 0 |
| 1083 | move $fp, $sp # save sp in fp |
| 1084 | .cfi_def_cfa_register 30 |
| 1085 | move $s1, $a3 # move managed thread pointer into s1 |
| 1086 | addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval |
| 1087 | addiu $t0, $a2, 4 # create space for ArtMethod* in frame. |
| 1088 | subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes: |
| 1089 | srl $t0, $t0, 4 # native calling convention only aligns to 8B, |
| 1090 | sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves. |
| 1091 | addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1092 | la $t9, memcpy |
| 1093 | jalr $t9 # (dest, src, bytes) |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1094 | addiu $sp, $sp, -16 # make space for argument slots for memcpy |
| 1095 | addiu $sp, $sp, 16 # restore stack after memcpy |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1096 | lw $gp, 16($fp) # restore $gp |
| 1097 | lw $a0, SPILL_SIZE($fp) # restore ArtMethod* |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1098 | addiu $t8, $sp, 4 # t8 = pointer to the current argument (skip ArtMethod*) |
| 1099 | li $t6, 0 # t6 = gpr_index = 0 (corresponds to A1; A0 is skipped) |
| 1100 | li $t7, 0 # t7 = fp_index = 0 |
| 1101 | 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] | 1102 | # as the $fp is SPILL_SIZE bytes below the $sp on entry) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1103 | addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type) |
| 1104 | |
| 1105 | // Load the base addresses of tabIntS ... tabDoubleS. |
| 1106 | // We will use the register indices (gpr_index, fp_index) to branch. |
| 1107 | // Note that the indices are scaled by 16, so they can be added to the bases directly. |
| 1108 | #if defined(__mips_isa_rev) && __mips_isa_rev >= 6 |
| 1109 | lapc $t2, tabIntS |
| 1110 | lapc $t3, tabLongS |
| 1111 | lapc $t4, tabSingleS |
| 1112 | lapc $t5, tabDoubleS |
| 1113 | #else |
| 1114 | bltzal $zero, tabBaseS # nal |
| 1115 | addiu $t2, $ra, %lo(tabIntS - tabBaseS) |
| 1116 | tabBaseS: |
| 1117 | addiu $t3, $ra, %lo(tabLongS - tabBaseS) |
| 1118 | addiu $t4, $ra, %lo(tabSingleS - tabBaseS) |
| 1119 | addiu $t5, $ra, %lo(tabDoubleS - tabBaseS) |
| 1120 | #endif |
| 1121 | |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1122 | loopS: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1123 | lbu $ra, 0($t9) # ra = shorty[i] |
| 1124 | beqz $ra, loopEndS # finish getting args when shorty[i] == '\0' |
| 1125 | addiu $t9, 1 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1126 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1127 | addiu $ra, -'J' |
| 1128 | beqz $ra, isLongS # branch if result type char == 'J' |
| 1129 | addiu $ra, 'J' - 'D' |
| 1130 | beqz $ra, isDoubleS # branch if result type char == 'D' |
| 1131 | addiu $ra, 'D' - 'F' |
| 1132 | beqz $ra, isSingleS # branch if result type char == 'F' |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1133 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1134 | addu $ra, $t2, $t6 |
| 1135 | jalr $zero, $ra |
| 1136 | addiu $t8, 4 # next_arg = curr_arg + 4 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1137 | |
| 1138 | isLongS: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1139 | addu $ra, $t3, $t6 |
| 1140 | jalr $zero, $ra |
| 1141 | addiu $t8, 8 # next_arg = curr_arg + 8 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1142 | |
| 1143 | isSingleS: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1144 | addu $ra, $t4, $t7 |
| 1145 | jalr $zero, $ra |
| 1146 | addiu $t8, 4 # next_arg = curr_arg + 4 |
| 1147 | |
| 1148 | isDoubleS: |
| 1149 | addu $ra, $t5, $t7 |
| 1150 | #if defined(__mips_isa_rev) && __mips_isa_rev > 2 |
| 1151 | addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG |
| 1152 | #endif |
| 1153 | jalr $zero, $ra |
| 1154 | addiu $t8, 8 # next_arg = curr_arg + 8 |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1155 | |
| 1156 | loopEndS: |
| 1157 | lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code |
| 1158 | jalr $t9 # call the method |
| 1159 | sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame |
| 1160 | move $sp, $fp # restore the stack |
| 1161 | lw $s0, 0($sp) |
| 1162 | .cfi_restore 16 |
| 1163 | lw $s1, 4($sp) |
| 1164 | .cfi_restore 17 |
| 1165 | lw $fp, 8($sp) |
| 1166 | .cfi_restore 30 |
| 1167 | lw $ra, 12($sp) |
| 1168 | .cfi_restore 31 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1169 | addiu $sp, $sp, SPILL_SIZE |
| 1170 | .cfi_adjust_cfa_offset -SPILL_SIZE |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1171 | lw $t0, 16($sp) # get result pointer |
| 1172 | lw $t1, 20($sp) # get shorty |
| 1173 | lb $t1, 0($t1) # get result type char |
| 1174 | li $t2, 'D' # put char 'D' into t2 |
| 1175 | beq $t1, $t2, 6f # branch if result type char == 'D' |
| 1176 | li $t3, 'F' # put char 'F' into t3 |
| 1177 | beq $t1, $t3, 6f # branch if result type char == 'F' |
| 1178 | sw $v0, 0($t0) # store the result |
| 1179 | jalr $zero, $ra |
| 1180 | sw $v1, 4($t0) # store the other half of the result |
| 1181 | 6: |
| 1182 | SDu $f0, $f1, 0, $t0, $t1 # store floating point result |
| 1183 | jalr $zero, $ra |
| 1184 | nop |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1185 | |
| 1186 | // Note that gpr_index is kept within the range of tabIntS and tabLongS |
| 1187 | // and fp_index is kept within the range of tabSingleS and tabDoubleS. |
| 1188 | .balign 16 |
| 1189 | tabIntS: |
| 1190 | LOAD_WORD_TO_REG a1, t8, t6, loopS # a1 = current argument, gpr_index += 16 |
| 1191 | LOAD_WORD_TO_REG a2, t8, t6, loopS # a2 = current argument, gpr_index += 16 |
| 1192 | LOAD_WORD_TO_REG a3, t8, t6, loopS # a3 = current argument, gpr_index += 16 |
| 1193 | LOAD_WORD_TO_REG t0, t8, t6, loopS # t0 = current argument, gpr_index += 16 |
| 1194 | LOAD_WORD_TO_REG t1, t8, t6, loopS # t1 = current argument, gpr_index += 16 |
| 1195 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1196 | tabLongS: |
| 1197 | LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16 |
| 1198 | LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16 |
| 1199 | LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16 |
| 1200 | LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16 |
| 1201 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1202 | LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16 |
| 1203 | tabSingleS: |
| 1204 | LOAD_FLOAT_TO_REG f8, t8, t7, loopS # f8 = curr_arg, fp_index += 16 |
| 1205 | LOAD_FLOAT_TO_REG f10, t8, t7, loopS # f10 = curr_arg, fp_index += 16 |
| 1206 | LOAD_FLOAT_TO_REG f12, t8, t7, loopS # f12 = curr_arg, fp_index += 16 |
| 1207 | LOAD_FLOAT_TO_REG f14, t8, t7, loopS # f14 = curr_arg, fp_index += 16 |
| 1208 | LOAD_FLOAT_TO_REG f16, t8, t7, loopS # f16 = curr_arg, fp_index += 16 |
| 1209 | LOAD_FLOAT_TO_REG f18, t8, t7, loopS # f18 = curr_arg, fp_index += 16 |
| 1210 | LOAD_END t7, 6*16, loopS # no more FPR args, fp_index = 6*16 |
| 1211 | tabDoubleS: |
| 1212 | LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loopS # f8_f9 = curr_arg; if FPU32, fp_index += 16 |
| 1213 | LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loopS # f10_f11 = curr_arg; if FPU32, fp_index += 16 |
| 1214 | LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loopS # f12_f13 = curr_arg; if FPU32, fp_index += 16 |
| 1215 | LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loopS # f14_f15 = curr_arg; if FPU32, fp_index += 16 |
| 1216 | LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loopS # f16_f17 = curr_arg; if FPU32, fp_index += 16 |
| 1217 | LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loopS # f18_f19 = curr_arg; if FPU32, fp_index += 16 |
| 1218 | 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] | 1219 | END art_quick_invoke_static_stub |
| 1220 | |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1221 | #undef SPILL_SIZE |
| 1222 | |
Goran Jakovljevic | ff73498 | 2015-08-24 12:58:55 +0000 | [diff] [blame] | 1223 | /* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1224 | * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on |
| 1225 | * failure. |
| 1226 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1227 | .extern artHandleFillArrayDataFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1228 | ENTRY art_quick_handle_fill_data |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1229 | lw $a2, 0($sp) # pass referrer's Method* |
| 1230 | 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] | 1231 | la $t9, artHandleFillArrayDataFromCode |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1232 | jalr $t9 # (payload offset, Array*, method, Thread*) |
| 1233 | move $a3, rSELF # pass Thread::Current |
jeffhao | fc6a30e | 2012-10-18 18:24:15 -0700 | [diff] [blame] | 1234 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1235 | END art_quick_handle_fill_data |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1236 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1237 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1238 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1239 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1240 | .extern artLockObjectFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1241 | ENTRY art_quick_lock_object |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1242 | beqz $a0, art_quick_throw_null_pointer_exception |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1243 | nop |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1244 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1245 | la $t9, artLockObjectFromCode |
| 1246 | jalr $t9 # (Object* obj, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1247 | move $a1, rSELF # pass Thread::Current |
Ian Rogers | 6bcd163 | 2013-10-08 18:50:47 -0700 | [diff] [blame] | 1248 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1249 | END art_quick_lock_object |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1250 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1251 | ENTRY art_quick_lock_object_no_inline |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1252 | beqz $a0, art_quick_throw_null_pointer_exception |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1253 | nop |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1254 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1255 | la $t9, artLockObjectFromCode |
| 1256 | jalr $t9 # (Object* obj, Thread*) |
| 1257 | move $a1, rSELF # pass Thread::Current |
| 1258 | RETURN_IF_ZERO |
| 1259 | END art_quick_lock_object_no_inline |
| 1260 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1261 | /* |
| 1262 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 1263 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1264 | .extern artUnlockObjectFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1265 | ENTRY art_quick_unlock_object |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1266 | beqz $a0, art_quick_throw_null_pointer_exception |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1267 | nop |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1268 | 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] | 1269 | la $t9, artUnlockObjectFromCode |
| 1270 | jalr $t9 # (Object* obj, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1271 | move $a1, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1272 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1273 | END art_quick_unlock_object |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1274 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1275 | ENTRY art_quick_unlock_object_no_inline |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1276 | beqz $a0, art_quick_throw_null_pointer_exception |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1277 | nop |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1278 | 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] | 1279 | la $t9, artUnlockObjectFromCode |
| 1280 | jalr $t9 # (Object* obj, Thread*) |
| 1281 | move $a1, rSELF # pass Thread::Current |
| 1282 | RETURN_IF_ZERO |
| 1283 | END art_quick_unlock_object_no_inline |
| 1284 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1285 | /* |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1286 | * Entry from managed code that calls artInstanceOfFromCode and delivers exception on failure. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1287 | */ |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1288 | .extern artInstanceOfFromCode |
| 1289 | .extern artThrowClassCastExceptionForObject |
| 1290 | ENTRY art_quick_check_instance_of |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1291 | addiu $sp, $sp, -32 |
| 1292 | .cfi_adjust_cfa_offset 32 |
| 1293 | sw $gp, 16($sp) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1294 | sw $ra, 12($sp) |
| 1295 | .cfi_rel_offset 31, 12 |
| 1296 | sw $t9, 8($sp) |
| 1297 | sw $a1, 4($sp) |
| 1298 | sw $a0, 0($sp) |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1299 | la $t9, artInstanceOfFromCode |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1300 | jalr $t9 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1301 | addiu $sp, $sp, -16 # reserve argument slots on the stack |
| 1302 | addiu $sp, $sp, 16 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1303 | lw $gp, 16($sp) |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1304 | beqz $v0, .Lthrow_class_cast_exception |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1305 | lw $ra, 12($sp) |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1306 | jalr $zero, $ra |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1307 | addiu $sp, $sp, 32 |
| 1308 | .cfi_adjust_cfa_offset -32 |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1309 | .Lthrow_class_cast_exception: |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1310 | lw $t9, 8($sp) |
| 1311 | lw $a1, 4($sp) |
| 1312 | lw $a0, 0($sp) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1313 | addiu $sp, $sp, 32 |
| 1314 | .cfi_adjust_cfa_offset -32 |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1315 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1316 | la $t9, artThrowClassCastExceptionForObject |
| 1317 | jalr $zero, $t9 # artThrowClassCastException (Object*, Class*, Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1318 | move $a2, rSELF # pass Thread::Current |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1319 | END art_quick_check_instance_of |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1320 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1321 | /* |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1322 | * Restore rReg's value from offset($sp) if rReg is not the same as rExclude. |
| 1323 | * nReg is the register number for rReg. |
| 1324 | */ |
| 1325 | .macro POP_REG_NE rReg, nReg, offset, rExclude |
| 1326 | .ifnc \rReg, \rExclude |
| 1327 | lw \rReg, \offset($sp) # restore rReg |
| 1328 | .cfi_restore \nReg |
| 1329 | .endif |
| 1330 | .endm |
| 1331 | |
| 1332 | /* |
| 1333 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1334 | * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET. |
| 1335 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1336 | */ |
| 1337 | .macro READ_BARRIER rDest, rObj, offset |
| 1338 | #ifdef USE_READ_BARRIER |
| 1339 | # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment. |
| 1340 | addiu $sp, $sp, -32 |
| 1341 | .cfi_adjust_cfa_offset 32 |
| 1342 | sw $ra, 28($sp) |
| 1343 | .cfi_rel_offset 31, 28 |
| 1344 | sw $t9, 24($sp) |
| 1345 | .cfi_rel_offset 25, 24 |
| 1346 | sw $t1, 20($sp) |
| 1347 | .cfi_rel_offset 9, 20 |
| 1348 | sw $t0, 16($sp) |
| 1349 | .cfi_rel_offset 8, 16 |
| 1350 | sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B) |
| 1351 | .cfi_rel_offset 6, 8 |
| 1352 | sw $a1, 4($sp) |
| 1353 | .cfi_rel_offset 5, 4 |
| 1354 | sw $a0, 0($sp) |
| 1355 | .cfi_rel_offset 4, 0 |
| 1356 | |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1357 | # 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] | 1358 | .ifnc \rObj, $a1 |
| 1359 | move $a1, \rObj # pass rObj |
| 1360 | .endif |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1361 | addiu $a2, $zero, \offset # pass offset |
| 1362 | la $t9, artReadBarrierSlow |
| 1363 | jalr $t9 # artReadBarrierSlow(ref, rObj, offset) |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1364 | addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack |
| 1365 | # before the call to artReadBarrierSlow. |
| 1366 | addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow |
| 1367 | # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning. |
| 1368 | move \rDest, $v0 # save return value in rDest |
| 1369 | # (rDest cannot be v0 in art_quick_aput_obj) |
| 1370 | |
| 1371 | lw $a0, 0($sp) # restore registers except rDest |
| 1372 | # (rDest can only be t0 or t1 in art_quick_aput_obj) |
| 1373 | .cfi_restore 4 |
| 1374 | lw $a1, 4($sp) |
| 1375 | .cfi_restore 5 |
| 1376 | lw $a2, 8($sp) |
| 1377 | .cfi_restore 6 |
| 1378 | POP_REG_NE $t0, 8, 16, \rDest |
| 1379 | POP_REG_NE $t1, 9, 20, \rDest |
| 1380 | lw $t9, 24($sp) |
| 1381 | .cfi_restore 25 |
| 1382 | lw $ra, 28($sp) # restore $ra |
| 1383 | .cfi_restore 31 |
| 1384 | addiu $sp, $sp, 32 |
| 1385 | .cfi_adjust_cfa_offset -32 |
| 1386 | #else |
| 1387 | lw \rDest, \offset(\rObj) |
| 1388 | UNPOISON_HEAP_REF \rDest |
| 1389 | #endif // USE_READ_BARRIER |
| 1390 | .endm |
| 1391 | |
| 1392 | /* |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1393 | * Entry from managed code for array put operations of objects where the value being stored |
| 1394 | * needs to be checked for compatibility. |
| 1395 | * a0 = array, a1 = index, a2 = value |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1396 | */ |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1397 | ENTRY art_quick_aput_obj_with_null_and_bound_check |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1398 | bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1399 | nop |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1400 | b art_quick_throw_null_pointer_exception |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1401 | nop |
| 1402 | END art_quick_aput_obj_with_null_and_bound_check |
| 1403 | |
| 1404 | ENTRY art_quick_aput_obj_with_bound_check |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1405 | lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1406 | sltu $t1, $a1, $t0 |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1407 | bnez $t1, .Lart_quick_aput_obj_gp_set |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1408 | nop |
| 1409 | move $a0, $a1 |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 1410 | b art_quick_throw_array_bounds |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1411 | move $a1, $t0 |
| 1412 | END art_quick_aput_obj_with_bound_check |
| 1413 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1414 | #ifdef USE_READ_BARRIER |
| 1415 | .extern artReadBarrierSlow |
| 1416 | #endif |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1417 | ENTRY art_quick_aput_obj |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1418 | beqz $a2, .Ldo_aput_null |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1419 | nop |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1420 | READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET |
| 1421 | READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET |
| 1422 | READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1423 | 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] | 1424 | nop |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1425 | .Ldo_aput: |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1426 | sll $a1, $a1, 2 |
| 1427 | add $t0, $a0, $a1 |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1428 | POISON_HEAP_REF $a2 |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1429 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1430 | lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF) |
| 1431 | srl $t1, $a0, 7 |
| 1432 | add $t1, $t1, $t0 |
| 1433 | sb $t0, ($t1) |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1434 | jalr $zero, $ra |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1435 | nop |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1436 | .Ldo_aput_null: |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1437 | sll $a1, $a1, 2 |
| 1438 | add $t0, $a0, $a1 |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1439 | sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0) |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1440 | jalr $zero, $ra |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1441 | nop |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1442 | .Lcheck_assignability: |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1443 | addiu $sp, $sp, -32 |
| 1444 | .cfi_adjust_cfa_offset 32 |
| 1445 | sw $ra, 28($sp) |
| 1446 | .cfi_rel_offset 31, 28 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1447 | sw $gp, 16($sp) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1448 | sw $t9, 12($sp) |
| 1449 | sw $a2, 8($sp) |
| 1450 | sw $a1, 4($sp) |
| 1451 | sw $a0, 0($sp) |
| 1452 | move $a1, $t1 |
| 1453 | move $a0, $t0 |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1454 | la $t9, artIsAssignableFromCode |
| 1455 | jalr $t9 # (Class*, Class*) |
| 1456 | addiu $sp, $sp, -16 # reserve argument slots on the stack |
| 1457 | addiu $sp, $sp, 16 |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1458 | lw $ra, 28($sp) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1459 | lw $gp, 16($sp) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1460 | lw $t9, 12($sp) |
| 1461 | lw $a2, 8($sp) |
| 1462 | lw $a1, 4($sp) |
| 1463 | lw $a0, 0($sp) |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1464 | addiu $sp, 32 |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1465 | .cfi_adjust_cfa_offset -32 |
Ian Rogers | 86bcdc2 | 2014-02-21 22:06:38 -0800 | [diff] [blame] | 1466 | bnez $v0, .Ldo_aput |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1467 | nop |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1468 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1469 | move $a1, $a2 |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1470 | la $t9, artThrowArrayStoreException |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1471 | jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1472 | move $a2, rSELF # pass Thread::Current |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1473 | END art_quick_aput_obj |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1474 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1475 | /* |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1476 | * Called by managed code to resolve a static field and load a boolean primitive value. |
| 1477 | */ |
| 1478 | .extern artGetBooleanStaticFromCode |
| 1479 | ENTRY art_quick_get_boolean_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1480 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1481 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1482 | la $t9, artGetBooleanStaticFromCode |
| 1483 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1484 | move $a2, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1485 | RETURN_IF_NO_EXCEPTION |
| 1486 | END art_quick_get_boolean_static |
| 1487 | /* |
| 1488 | * Called by managed code to resolve a static field and load a byte primitive value. |
| 1489 | */ |
| 1490 | .extern artGetByteStaticFromCode |
| 1491 | ENTRY art_quick_get_byte_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1492 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1493 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1494 | la $t9, artGetByteStaticFromCode |
| 1495 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1496 | move $a2, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1497 | RETURN_IF_NO_EXCEPTION |
| 1498 | END art_quick_get_byte_static |
| 1499 | |
| 1500 | /* |
| 1501 | * Called by managed code to resolve a static field and load a char primitive value. |
| 1502 | */ |
| 1503 | .extern artGetCharStaticFromCode |
| 1504 | ENTRY art_quick_get_char_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1505 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1506 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1507 | la $t9, artGetCharStaticFromCode |
| 1508 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1509 | move $a2, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1510 | RETURN_IF_NO_EXCEPTION |
| 1511 | END art_quick_get_char_static |
| 1512 | /* |
| 1513 | * Called by managed code to resolve a static field and load a short primitive value. |
| 1514 | */ |
| 1515 | .extern artGetShortStaticFromCode |
| 1516 | ENTRY art_quick_get_short_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1517 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1518 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1519 | la $t9, artGetShortStaticFromCode |
| 1520 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1521 | move $a2, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1522 | RETURN_IF_NO_EXCEPTION |
| 1523 | END art_quick_get_short_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1524 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1525 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1526 | * Called by managed code to resolve a static field and load a 32-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1527 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1528 | .extern artGet32StaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1529 | ENTRY art_quick_get32_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1530 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1531 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1532 | la $t9, artGet32StaticFromCode |
| 1533 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1534 | move $a2, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1535 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1536 | END art_quick_get32_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1537 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1538 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1539 | * Called by managed code to resolve a static field and load a 64-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1540 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1541 | .extern artGet64StaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1542 | ENTRY art_quick_get64_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1543 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1544 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1545 | la $t9, artGet64StaticFromCode |
| 1546 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1547 | move $a2, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1548 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1549 | END art_quick_get64_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1550 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1551 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1552 | * Called by managed code to resolve a static field and load an object reference. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1553 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1554 | .extern artGetObjStaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1555 | ENTRY art_quick_get_obj_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1556 | lw $a1, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1557 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1558 | la $t9, artGetObjStaticFromCode |
| 1559 | jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1560 | move $a2, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1561 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1562 | END art_quick_get_obj_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1563 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1564 | /* |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1565 | * Called by managed code to resolve an instance field and load a boolean primitive value. |
| 1566 | */ |
| 1567 | .extern artGetBooleanInstanceFromCode |
| 1568 | ENTRY art_quick_get_boolean_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1569 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1570 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1571 | la $t9, artGetBooleanInstanceFromCode |
| 1572 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1573 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1574 | RETURN_IF_NO_EXCEPTION |
| 1575 | END art_quick_get_boolean_instance |
| 1576 | /* |
| 1577 | * Called by managed code to resolve an instance field and load a byte primitive value. |
| 1578 | */ |
| 1579 | .extern artGetByteInstanceFromCode |
| 1580 | ENTRY art_quick_get_byte_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1581 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1582 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1583 | la $t9, artGetByteInstanceFromCode |
| 1584 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1585 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1586 | RETURN_IF_NO_EXCEPTION |
| 1587 | END art_quick_get_byte_instance |
| 1588 | |
| 1589 | /* |
| 1590 | * Called by managed code to resolve an instance field and load a char primitive value. |
| 1591 | */ |
| 1592 | .extern artGetCharInstanceFromCode |
| 1593 | ENTRY art_quick_get_char_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1594 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1595 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1596 | la $t9, artGetCharInstanceFromCode |
| 1597 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1598 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1599 | RETURN_IF_NO_EXCEPTION |
| 1600 | END art_quick_get_char_instance |
| 1601 | /* |
| 1602 | * Called by managed code to resolve an instance field and load a short primitive value. |
| 1603 | */ |
| 1604 | .extern artGetShortInstanceFromCode |
| 1605 | ENTRY art_quick_get_short_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1606 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1607 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1608 | la $t9, artGetShortInstanceFromCode |
| 1609 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1610 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1611 | RETURN_IF_NO_EXCEPTION |
| 1612 | END art_quick_get_short_instance |
| 1613 | |
| 1614 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1615 | * Called by managed code to resolve an instance field and load a 32-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1616 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1617 | .extern artGet32InstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1618 | ENTRY art_quick_get32_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1619 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1620 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1621 | la $t9, artGet32InstanceFromCode |
| 1622 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1623 | move $a3, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1624 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1625 | END art_quick_get32_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1626 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1627 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1628 | * Called by managed code to resolve an instance field and load a 64-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1629 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1630 | .extern artGet64InstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1631 | ENTRY art_quick_get64_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1632 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1633 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1634 | la $t9, artGet64InstanceFromCode |
| 1635 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1636 | move $a3, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1637 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1638 | END art_quick_get64_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1639 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1640 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1641 | * Called by managed code to resolve an instance field and load an object reference. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1642 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1643 | .extern artGetObjInstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1644 | ENTRY art_quick_get_obj_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1645 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1646 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1647 | la $t9, artGetObjInstanceFromCode |
| 1648 | jalr $t9 # (field_idx, Object*, referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1649 | move $a3, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1650 | RETURN_IF_NO_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1651 | END art_quick_get_obj_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1652 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1653 | /* |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1654 | * Called by managed code to resolve a static field and store a 8-bit primitive value. |
| 1655 | */ |
| 1656 | .extern artSet8StaticFromCode |
| 1657 | ENTRY art_quick_set8_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1658 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1659 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1660 | la $t9, artSet8StaticFromCode |
| 1661 | jalr $t9 # (field_idx, new_val, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1662 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1663 | RETURN_IF_ZERO |
| 1664 | END art_quick_set8_static |
| 1665 | |
| 1666 | /* |
| 1667 | * Called by managed code to resolve a static field and store a 16-bit primitive value. |
| 1668 | */ |
| 1669 | .extern artSet16StaticFromCode |
| 1670 | ENTRY art_quick_set16_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1671 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1672 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1673 | la $t9, artSet16StaticFromCode |
| 1674 | jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1675 | move $a3, rSELF # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1676 | RETURN_IF_ZERO |
| 1677 | END art_quick_set16_static |
| 1678 | |
| 1679 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1680 | * Called by managed code to resolve a static field and store a 32-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1681 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1682 | .extern artSet32StaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1683 | ENTRY art_quick_set32_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1684 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1685 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1686 | la $t9, artSet32StaticFromCode |
| 1687 | jalr $t9 # (field_idx, new_val, referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1688 | move $a3, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1689 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1690 | END art_quick_set32_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1691 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1692 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1693 | * Called by managed code to resolve a static field and store a 64-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1694 | */ |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1695 | .extern artSet64StaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1696 | ENTRY art_quick_set64_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1697 | lw $a1, 0($sp) # pass referrer's Method* |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1698 | # 64 bit new_val is in a2:a3 pair |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1699 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1700 | la $t9, artSet64StaticFromCode |
| 1701 | jalr $t9 # (field_idx, referrer, new_val, Thread*) |
jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 1702 | sw rSELF, 16($sp) # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1703 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1704 | END art_quick_set64_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1705 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1706 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1707 | * Called by managed code to resolve a static field and store an object reference. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1708 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1709 | .extern artSetObjStaticFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1710 | ENTRY art_quick_set_obj_static |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1711 | lw $a2, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1712 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1713 | la $t9, artSetObjStaticFromCode |
| 1714 | jalr $t9 # (field_idx, new_val, referrer, Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1715 | move $a3, rSELF # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1716 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1717 | END art_quick_set_obj_static |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1718 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1719 | /* |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1720 | * Called by managed code to resolve an instance field and store a 8-bit primitive value. |
| 1721 | */ |
| 1722 | .extern artSet8InstanceFromCode |
| 1723 | ENTRY art_quick_set8_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1724 | lw $a3, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1725 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1726 | la $t9, artSet8InstanceFromCode |
| 1727 | jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1728 | sw rSELF, 16($sp) # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1729 | RETURN_IF_ZERO |
| 1730 | END art_quick_set8_instance |
| 1731 | |
| 1732 | /* |
| 1733 | * Called by managed code to resolve an instance field and store a 16-bit primitive value. |
| 1734 | */ |
| 1735 | .extern artSet16InstanceFromCode |
| 1736 | ENTRY art_quick_set16_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1737 | lw $a3, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1738 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1739 | la $t9, artSet16InstanceFromCode |
| 1740 | jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1741 | sw rSELF, 16($sp) # pass Thread::Current |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1742 | RETURN_IF_ZERO |
| 1743 | END art_quick_set16_instance |
| 1744 | |
| 1745 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1746 | * Called by managed code to resolve an instance field and store a 32-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1747 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1748 | .extern artSet32InstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1749 | ENTRY art_quick_set32_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1750 | lw $a3, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1751 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1752 | la $t9, artSet32InstanceFromCode |
| 1753 | jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*) |
jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 1754 | sw rSELF, 16($sp) # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1755 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1756 | END art_quick_set32_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1757 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1758 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1759 | * Called by managed code to resolve an instance field and store a 64-bit primitive value. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1760 | */ |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1761 | .extern artSet64InstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1762 | ENTRY art_quick_set64_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1763 | lw $t1, 0($sp) # load referrer's Method* |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1764 | # 64 bit new_val is in a2:a3 pair |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1765 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1766 | sw rSELF, 20($sp) # pass Thread::Current |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1767 | la $t9, artSet64InstanceFromCode |
| 1768 | jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1769 | sw $t1, 16($sp) # pass referrer's Method* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1770 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1771 | END art_quick_set64_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1772 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1773 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1774 | * Called by managed code to resolve an instance field and store an object reference. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1775 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1776 | .extern artSetObjInstanceFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1777 | ENTRY art_quick_set_obj_instance |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1778 | lw $a3, 0($sp) # pass referrer's Method* |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1779 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1780 | la $t9, artSetObjInstanceFromCode |
| 1781 | jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*) |
jeffhao | fa147e2 | 2012-10-12 17:03:32 -0700 | [diff] [blame] | 1782 | sw rSELF, 16($sp) # pass Thread::Current |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1783 | RETURN_IF_ZERO |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1784 | END art_quick_set_obj_instance |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1785 | |
Vladimir Marko | a3c3827 | 2015-04-28 12:37:09 +0100 | [diff] [blame] | 1786 | // Macro to facilitate adding new allocation entrypoints. |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1787 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1788 | .extern \entrypoint |
| 1789 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1790 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1791 | la $t9, \entrypoint |
| 1792 | jalr $t9 |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1793 | move $a1, rSELF # pass Thread::Current |
| 1794 | \return |
| 1795 | END \name |
| 1796 | .endm |
| 1797 | |
Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1798 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
| 1799 | .extern \entrypoint |
| 1800 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1801 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1802 | la $t9, \entrypoint |
| 1803 | jalr $t9 |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1804 | move $a2, rSELF # pass Thread::Current |
Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1805 | \return |
| 1806 | END \name |
| 1807 | .endm |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1808 | |
Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1809 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
| 1810 | .extern \entrypoint |
| 1811 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1812 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1813 | la $t9, \entrypoint |
| 1814 | jalr $t9 |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1815 | move $a3, rSELF # pass Thread::Current |
Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 1816 | \return |
| 1817 | END \name |
| 1818 | .endm |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1819 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1820 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1821 | .extern \entrypoint |
| 1822 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1823 | SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1824 | la $t9, \entrypoint |
| 1825 | jalr $t9 |
Vladimir Marko | a3c3827 | 2015-04-28 12:37:09 +0100 | [diff] [blame] | 1826 | sw rSELF, 16($sp) # pass Thread::Current |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1827 | \return |
| 1828 | END \name |
| 1829 | .endm |
| 1830 | |
Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 1831 | // Generate the allocation entrypoints for each allocator. |
Pavle Batuta | 712c59d | 2015-12-02 18:39:01 +0100 | [diff] [blame] | 1832 | GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1833 | |
Pavle Batuta | 712c59d | 2015-12-02 18:39:01 +0100 | [diff] [blame] | 1834 | |
Nicolas Geoffray | 0d3998b | 2017-01-12 15:35:12 +0000 | [diff] [blame] | 1835 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc, RosAlloc) |
| 1836 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB) |
| 1837 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB) |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1838 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1839 | /* |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1840 | * 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] | 1841 | * exception on error. On success the String is returned. A0 holds the string index. The fast |
| 1842 | * path check for hit in strings cache has already been performed. |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1843 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1844 | ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1845 | |
| 1846 | /* |
| 1847 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 1848 | * initializer and deliver the exception on error. On success the static storage base is |
| 1849 | * returned. |
| 1850 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1851 | ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1852 | |
| 1853 | /* |
| 1854 | * Entry from managed code when dex cache misses for a type_idx. |
| 1855 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1856 | ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1857 | |
| 1858 | /* |
| 1859 | * Entry from managed code when type_idx needs to be checked for access and dex cache may also |
| 1860 | * miss. |
| 1861 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1862 | ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1863 | |
| 1864 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1865 | * 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] | 1866 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1867 | .extern artTestSuspendFromCode |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1868 | ENTRY_NO_GP art_quick_test_suspend |
| 1869 | lh rSUSPEND, THREAD_FLAGS_OFFSET(rSELF) |
| 1870 | bnez rSUSPEND, 1f |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1871 | addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1872 | jalr $zero, $ra |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1873 | nop |
| 1874 | 1: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1875 | SETUP_SAVE_EVERYTHING_FRAME # save everything for stack crawl |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1876 | la $t9, artTestSuspendFromCode |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1877 | jalr $t9 # (Thread*) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1878 | move $a0, rSELF |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1879 | RESTORE_SAVE_EVERYTHING_FRAME |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1880 | jalr $zero, $ra |
| 1881 | nop |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1882 | END art_quick_test_suspend |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1883 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1884 | /* |
| 1885 | * 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] | 1886 | * a0 holds the proxy method; a1, a2 and a3 may contain arguments. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1887 | */ |
Jeff Hao | 5fa60c3 | 2013-04-04 17:57:01 -0700 | [diff] [blame] | 1888 | .extern artQuickProxyInvokeHandler |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1889 | ENTRY art_quick_proxy_invoke_handler |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1890 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1891 | move $a2, rSELF # pass Thread::Current |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1892 | la $t9, artQuickProxyInvokeHandler |
| 1893 | jalr $t9 # (Method* proxy method, receiver, Thread*, SP) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1894 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1895 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1896 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1897 | bnez $t7, 1f |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1898 | # don't care if $v0 and/or $v1 are modified, when exception branch taken |
| 1899 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 1900 | jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 1901 | nop |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1902 | 1: |
| 1903 | DELIVER_PENDING_EXCEPTION |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 1904 | END art_quick_proxy_invoke_handler |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 1905 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1906 | /* |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1907 | * Called to resolve an imt conflict. |
| 1908 | * a0 is the conflict ArtMethod. |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1909 | * 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] | 1910 | * |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1911 | * Note that this stub writes to a0, t7 and t8. |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1912 | */ |
Douglas Leung | 13738bf | 2014-10-27 14:44:47 -0700 | [diff] [blame] | 1913 | ENTRY art_quick_imt_conflict_trampoline |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1914 | lw $t8, 0($sp) # Load referrer. |
| 1915 | lw $t8, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t8) # Load dex cache methods array. |
| 1916 | sll $t7, $t7, POINTER_SIZE_SHIFT # Calculate offset. |
| 1917 | addu $t7, $t8, $t7 # Add offset to base. |
| 1918 | lw $t7, 0($t7) # Load interface method. |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1919 | lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable. |
| 1920 | |
| 1921 | .Limt_table_iterate: |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1922 | lw $t8, 0($a0) # Load next entry in ImtConflictTable. |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1923 | # Branch if found. |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1924 | beq $t8, $t7, .Limt_table_found |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1925 | nop |
| 1926 | # 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] | 1927 | beqz $t8, .Lconflict_trampoline |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1928 | nop |
| 1929 | # Iterate over the entries of the ImtConflictTable. |
| 1930 | b .Limt_table_iterate |
| 1931 | addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry. |
| 1932 | |
| 1933 | .Limt_table_found: |
| 1934 | # We successfully hit an entry in the table. Load the target method and jump to it. |
| 1935 | lw $a0, __SIZEOF_POINTER__($a0) |
| 1936 | lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1937 | jalr $zero, $t9 |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1938 | nop |
| 1939 | |
| 1940 | .Lconflict_trampoline: |
| 1941 | # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method. |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 1942 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1943 | END art_quick_imt_conflict_trampoline |
| 1944 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1945 | .extern artQuickResolutionTrampoline |
| 1946 | ENTRY art_quick_resolution_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1947 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1948 | move $a2, rSELF # pass Thread::Current |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1949 | la $t9, artQuickResolutionTrampoline |
| 1950 | jalr $t9 # (Method* called, receiver, Thread*, SP) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1951 | addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1952 | beqz $v0, 1f |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1953 | lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0 |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1954 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Ian Rogers | 65d1b22 | 2013-09-27 10:59:41 -0700 | [diff] [blame] | 1955 | 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] | 1956 | jalr $zero, $t9 # tail call to method |
Mathieu Chartier | 1984152 | 2013-10-22 11:29:00 -0700 | [diff] [blame] | 1957 | nop |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1958 | 1: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1959 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1960 | DELIVER_PENDING_EXCEPTION |
| 1961 | END art_quick_resolution_trampoline |
| 1962 | |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1963 | .extern artQuickGenericJniTrampoline |
| 1964 | .extern artQuickGenericJniEndTrampoline |
| 1965 | ENTRY art_quick_generic_jni_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1966 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1967 | move $s8, $sp # save $sp to $s8 |
| 1968 | move $s3, $gp # save $gp to $s3 |
| 1969 | |
| 1970 | # prepare for call to artQuickGenericJniTrampoline(Thread*, SP) |
| 1971 | move $a0, rSELF # pass Thread::Current |
| 1972 | addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 1973 | la $t9, artQuickGenericJniTrampoline |
| 1974 | jalr $t9 # (Thread*, SP) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1975 | addiu $sp, $sp, -5120 # reserve space on the stack |
| 1976 | |
| 1977 | # The C call will have registered the complete save-frame on success. |
| 1978 | # The result of the call is: |
| 1979 | # v0: ptr to native code, 0 on error. |
| 1980 | # 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] | 1981 | beq $v0, $zero, 2f # check entry error |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1982 | move $t9, $v0 # save the code ptr |
| 1983 | move $sp, $v1 # release part of the alloca |
| 1984 | |
| 1985 | # Load parameters from stack into registers |
| 1986 | lw $a0, 0($sp) |
| 1987 | lw $a1, 4($sp) |
| 1988 | lw $a2, 8($sp) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 1989 | lw $a3, 12($sp) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 1990 | |
| 1991 | # artQuickGenericJniTrampoline sets bit 0 of the native code address to 1 |
| 1992 | # when the first two arguments are both single precision floats. This lets |
| 1993 | # us extract them properly from the stack and load into floating point |
| 1994 | # registers. |
| 1995 | MTD $a0, $a1, $f12, $f13 |
| 1996 | andi $t0, $t9, 1 |
| 1997 | xor $t9, $t9, $t0 |
| 1998 | bnez $t0, 1f |
| 1999 | mtc1 $a1, $f14 |
| 2000 | MTD $a2, $a3, $f14, $f15 |
| 2001 | |
| 2002 | 1: |
| 2003 | jalr $t9 # native call |
| 2004 | nop |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2005 | addiu $sp, $sp, 16 # remove arg slots |
| 2006 | |
| 2007 | move $gp, $s3 # restore $gp from $s3 |
| 2008 | |
| 2009 | # result sign extension is handled in C code |
| 2010 | # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f) |
| 2011 | move $a0, rSELF # pass Thread::Current |
| 2012 | move $a2, $v0 # pass result |
| 2013 | move $a3, $v1 |
| 2014 | addiu $sp, $sp, -24 # reserve arg slots |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2015 | la $t9, artQuickGenericJniEndTrampoline |
| 2016 | jalr $t9 |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2017 | s.d $f0, 16($sp) # pass result_f |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2018 | |
| 2019 | lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2020 | bne $t0, $zero, 2f # check for pending exceptions |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2021 | |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2022 | move $sp, $s8 # tear down the alloca |
| 2023 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2024 | # tear down the callee-save frame |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2025 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2026 | |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2027 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2028 | jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2029 | nop |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2030 | |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2031 | 2: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2032 | lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) |
| 2033 | # This will create a new save-all frame, required by the runtime. |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2034 | DELIVER_PENDING_EXCEPTION |
| 2035 | END art_quick_generic_jni_trampoline |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 2036 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2037 | .extern artQuickToInterpreterBridge |
| 2038 | ENTRY art_quick_to_interpreter_bridge |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2039 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2040 | move $a1, rSELF # pass Thread::Current |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2041 | la $t9, artQuickToInterpreterBridge |
| 2042 | jalr $t9 # (Method* method, Thread*, SP) |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2043 | addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots) |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2044 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2045 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 2046 | bnez $t7, 1f |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2047 | # don't care if $v0 and/or $v1 are modified, when exception branch taken |
| 2048 | MTD $v0, $v1, $f0, $f1 # move float value to return value |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2049 | jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2050 | nop |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 2051 | 1: |
| 2052 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2053 | END art_quick_to_interpreter_bridge |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 2054 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2055 | /* |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame] | 2056 | * Routine that intercepts method calls and returns. |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2057 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2058 | .extern artInstrumentationMethodEntryFromCode |
| 2059 | .extern artInstrumentationMethodExitFromCode |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2060 | ENTRY art_quick_instrumentation_entry |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2061 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2062 | sw $a0, 28($sp) # save arg0 in free arg slot |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2063 | move $a3, $ra # pass $ra |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2064 | la $t9, artInstrumentationMethodEntryFromCode |
| 2065 | jalr $t9 # (Method*, Object*, Thread*, LR) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 2066 | move $a2, rSELF # pass Thread::Current |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 2067 | move $t9, $v0 # $t9 holds reference to code |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2068 | lw $a0, 28($sp) # restore arg0 from free arg slot |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2069 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
jeffhao | 8161c03 | 2012-10-31 15:50:00 -0700 | [diff] [blame] | 2070 | jalr $t9 # call method |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 2071 | nop |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2072 | END art_quick_instrumentation_entry |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2073 | /* intentional fallthrough */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2074 | .global art_quick_instrumentation_exit |
| 2075 | art_quick_instrumentation_exit: |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2076 | .cfi_startproc |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2077 | addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2078 | .cpload $t9 |
Douglas Leung | c3d131e | 2014-07-16 17:32:41 -0700 | [diff] [blame] | 2079 | move $ra, $zero # link register is to here, so clobber with 0 for later checks |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2080 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2081 | SETUP_SAVE_REFS_ONLY_FRAME |
Douglas Leung | 735b855 | 2014-10-31 12:21:40 -0700 | [diff] [blame] | 2082 | addiu $sp, $sp, -16 # allocate temp storage on the stack |
| 2083 | .cfi_adjust_cfa_offset 16 |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 2084 | sw $v0, ARG_SLOT_SIZE+12($sp) |
| 2085 | .cfi_rel_offset 2, ARG_SLOT_SIZE+12 |
| 2086 | sw $v1, ARG_SLOT_SIZE+8($sp) |
| 2087 | .cfi_rel_offset 3, ARG_SLOT_SIZE+8 |
| 2088 | s.d $f0, ARG_SLOT_SIZE($sp) |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2089 | s.d $f0, 16($sp) # pass fpr result |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 2090 | move $a2, $v0 # pass gpr result |
| 2091 | move $a3, $v1 |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 2092 | addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2093 | la $t9, artInstrumentationMethodExitFromCode |
| 2094 | jalr $t9 # (Thread*, SP, gpr_res, fpr_res) |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2095 | move $a0, rSELF # pass Thread::Current |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 2096 | move $t9, $v0 # set aside returned link register |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2097 | move $ra, $v1 # set link register for deoptimization |
Douglas Leung | f96e8bd | 2015-03-27 15:38:30 -0700 | [diff] [blame] | 2098 | lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values |
| 2099 | lw $v1, ARG_SLOT_SIZE+8($sp) |
| 2100 | l.d $f0, ARG_SLOT_SIZE($sp) |
| 2101 | jalr $zero, $t9 # return |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2102 | addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16 # restore stack |
| 2103 | .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16) |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 2104 | END art_quick_instrumentation_exit |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2105 | |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2106 | /* |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 2107 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 2108 | * will long jump to the upcall with a special exception of -1. |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2109 | */ |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2110 | .extern artDeoptimize |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2111 | ENTRY art_quick_deoptimize |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2112 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2113 | la $t9, artDeoptimize |
| 2114 | jalr $t9 # artDeoptimize(Thread*) |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2115 | # Returns caller method's frame size. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2116 | move $a0, rSELF # pass Thread::current |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2117 | END art_quick_deoptimize |
jeffhao | 12051ea | 2013-01-10 11:24:31 -0800 | [diff] [blame] | 2118 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2119 | /* |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2120 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
| 2121 | * will long jump to the upcall with a special exception of -1. |
| 2122 | */ |
| 2123 | .extern artDeoptimizeFromCompiledCode |
| 2124 | ENTRY art_quick_deoptimize_from_compiled_code |
Vladimir Marko | 239d6ea | 2016-09-05 10:44:04 +0100 | [diff] [blame] | 2125 | SETUP_SAVE_EVERYTHING_FRAME |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2126 | la $t9, artDeoptimizeFromCompiledCode |
| 2127 | jalr $t9 # artDeoptimizeFromCompiledCode(Thread*) |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2128 | # Returns caller method's frame size. |
| 2129 | move $a0, rSELF # pass Thread::current |
| 2130 | END art_quick_deoptimize_from_compiled_code |
| 2131 | |
| 2132 | /* |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2133 | * Long integer shift. This is different from the generic 32/64-bit |
| 2134 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2135 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2136 | * 6 bits. |
| 2137 | * On entry: |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2138 | * $a0: low word |
| 2139 | * $a1: high word |
| 2140 | * $a2: shift count |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2141 | */ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2142 | ENTRY_NO_GP art_quick_shl_long |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2143 | /* shl-long vAA, vBB, vCC */ |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2144 | sll $v0, $a0, $a2 # rlo<- alo << (shift&31) |
| 2145 | not $v1, $a2 # rhi<- 31-shift (shift is 5b) |
| 2146 | srl $a0, 1 |
| 2147 | srl $a0, $v1 # alo<- alo >> (32-(shift&31)) |
| 2148 | sll $v1, $a1, $a2 # rhi<- ahi << (shift&31) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2149 | andi $a2, 0x20 # shift< shift & 0x20 |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2150 | beqz $a2, 1f |
| 2151 | or $v1, $a0 # rhi<- rhi | alo |
| 2152 | |
| 2153 | move $v1, $v0 # rhi<- rlo (if shift&0x20) |
| 2154 | move $v0, $zero # rlo<- 0 (if shift&0x20) |
| 2155 | |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2156 | 1: jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2157 | nop |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2158 | END art_quick_shl_long |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2159 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2160 | /* |
| 2161 | * Long integer shift. This is different from the generic 32/64-bit |
| 2162 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2163 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2164 | * 6 bits. |
| 2165 | * On entry: |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2166 | * $a0: low word |
| 2167 | * $a1: high word |
| 2168 | * $a2: shift count |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2169 | */ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2170 | ENTRY_NO_GP art_quick_shr_long |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2171 | sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31) |
| 2172 | srl $v0, $a0, $a2 # rlo<- alo >> (shift&31) |
| 2173 | sra $a3, $a1, 31 # $a3<- sign(ah) |
| 2174 | not $a0, $a2 # alo<- 31-shift (shift is 5b) |
| 2175 | sll $a1, 1 |
| 2176 | sll $a1, $a0 # ahi<- ahi << (32-(shift&31)) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2177 | andi $a2, 0x20 # shift & 0x20 |
Douglas Leung | 475cfd8 | 2014-12-16 20:15:41 -0800 | [diff] [blame] | 2178 | beqz $a2, 1f |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2179 | or $v0, $a1 # rlo<- rlo | ahi |
| 2180 | |
| 2181 | move $v0, $v1 # rlo<- rhi (if shift&0x20) |
| 2182 | move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20) |
| 2183 | |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2184 | 1: jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2185 | nop |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2186 | END art_quick_shr_long |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2187 | |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2188 | /* |
| 2189 | * Long integer shift. This is different from the generic 32/64-bit |
| 2190 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 2191 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 2192 | * 6 bits. |
| 2193 | * On entry: |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2194 | * $a0: low word |
| 2195 | * $a1: high word |
| 2196 | * $a2: shift count |
buzbee | 5bc5a7b | 2012-03-07 15:52:59 -0800 | [diff] [blame] | 2197 | */ |
| 2198 | /* ushr-long vAA, vBB, vCC */ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2199 | ENTRY_NO_GP art_quick_ushr_long |
jeffhao | fc6a30e | 2012-10-18 18:24:15 -0700 | [diff] [blame] | 2200 | srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2201 | srl $v0, $a0, $a2 # rlo<- alo >> (shift&31) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2202 | not $a0, $a2 # alo<- 31-shift (shift is 5b) |
| 2203 | sll $a1, 1 |
| 2204 | sll $a1, $a0 # ahi<- ahi << (32-(shift&31)) |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2205 | andi $a2, 0x20 # shift & 0x20 |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2206 | beqz $a2, 1f |
| 2207 | or $v0, $a1 # rlo<- rlo | ahi |
| 2208 | |
| 2209 | move $v0, $v1 # rlo<- rhi (if shift&0x20) |
| 2210 | move $v1, $zero # rhi<- 0 (if shift&0x20) |
| 2211 | |
Andreas Gampe | 8d36591 | 2015-01-13 11:32:32 -0800 | [diff] [blame] | 2212 | 1: jalr $zero, $ra |
Duane Sand | e34652f | 2014-11-04 11:09:36 -0800 | [diff] [blame] | 2213 | nop |
Jeff Hao | d4c3f7d | 2013-02-14 14:14:44 -0800 | [diff] [blame] | 2214 | END art_quick_ushr_long |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 2215 | |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2216 | /* java.lang.String.indexOf(int ch, int fromIndex=0) */ |
| 2217 | ENTRY_NO_GP art_quick_indexof |
| 2218 | /* $a0 holds address of "this" */ |
| 2219 | /* $a1 holds "ch" */ |
| 2220 | /* $a2 holds "fromIndex" */ |
| 2221 | lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2222 | slt $t1, $a2, $zero # if fromIndex < 0 |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2223 | #if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2224 | seleqz $a2, $a2, $t1 # fromIndex = 0; |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2225 | #else |
Goran Jakovljevic | 590b136 | 2016-03-21 14:24:43 +0100 | [diff] [blame] | 2226 | movn $a2, $zero, $t1 # fromIndex = 0; |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2227 | #endif |
| 2228 | subu $t0, $t0, $a2 # this.length() - fromIndex |
| 2229 | blez $t0, 6f # if this.length()-fromIndex <= 0 |
| 2230 | li $v0, -1 # return -1; |
| 2231 | |
| 2232 | sll $v0, $a2, 1 # $a0 += $a2 * 2 |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2233 | addu $a0, $a0, $v0 # " ditto " |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2234 | move $v0, $a2 # Set i to fromIndex. |
| 2235 | |
| 2236 | 1: |
| 2237 | lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch |
| 2238 | beq $t3, $a1, 6f # return i; |
| 2239 | addu $a0, $a0, 2 # i++ |
| 2240 | subu $t0, $t0, 1 # this.length() - i |
| 2241 | bnez $t0, 1b # while this.length() - i > 0 |
| 2242 | addu $v0, $v0, 1 # i++ |
| 2243 | |
| 2244 | li $v0, -1 # if this.length() - i <= 0 |
| 2245 | # return -1; |
| 2246 | |
| 2247 | 6: |
| 2248 | j $ra |
| 2249 | nop |
| 2250 | END art_quick_indexof |
| 2251 | |
Chris Larsen | cf283da | 2016-01-19 16:45:35 -0800 | [diff] [blame] | 2252 | /* java.lang.String.compareTo(String anotherString) */ |
| 2253 | ENTRY_NO_GP art_quick_string_compareto |
| 2254 | /* $a0 holds address of "this" */ |
| 2255 | /* $a1 holds address of "anotherString" */ |
| 2256 | beq $a0, $a1, 9f # this and anotherString are the same object |
| 2257 | move $v0, $zero |
| 2258 | |
| 2259 | lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length() |
| 2260 | lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length() |
| 2261 | MINu $t2, $a2, $a3 |
| 2262 | # $t2 now holds min(this.length(),anotherString.length()) |
| 2263 | |
| 2264 | beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0 |
| 2265 | subu $v0, $a2, $a3 # if $t2==0 return |
| 2266 | # (this.length() - anotherString.length()) |
| 2267 | 1: |
| 2268 | lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i) |
| 2269 | lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1) |
| 2270 | bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i) |
| 2271 | subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i)) |
| 2272 | addiu $a0, $a0, 2 # point at this.charAt(i++) |
| 2273 | subu $t2, $t2, 1 # new value of |
| 2274 | # min(this.length(),anotherString.length())-i |
| 2275 | bnez $t2, 1b |
| 2276 | addiu $a1, $a1, 2 # point at anotherString.charAt(i++) |
| 2277 | subu $v0, $a2, $a3 |
| 2278 | |
| 2279 | 9: |
| 2280 | j $ra |
| 2281 | nop |
| 2282 | END art_quick_string_compareto |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2283 | |
| 2284 | .extern artInvokePolymorphic |
| 2285 | ENTRY art_quick_invoke_polymorphic |
| 2286 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
| 2287 | move $a2, rSELF # Make $a2 an alias for the current Thread. |
| 2288 | move $a3, $sp # Make $a3 a pointer to the saved frame context. |
| 2289 | addiu $sp, $sp, -24 # Reserve space for JValue result and 4 words for callee. |
| 2290 | .cfi_adjust_cfa_offset 24 |
| 2291 | sw $zero, 20($sp) # Initialize JValue result. |
| 2292 | sw $zero, 16($sp) |
| 2293 | addiu $a0, $sp, 16 # Make $a0 a pointer to the JValue result |
| 2294 | la $t9, artInvokePolymorphic |
| 2295 | jalr $t9 # (result, receiver, Thread*, context) |
| 2296 | nop |
| 2297 | .macro MATCH_RETURN_TYPE c, handler |
| 2298 | li $t0, \c |
| 2299 | beq $v0, $t0, \handler |
| 2300 | .endm |
| 2301 | MATCH_RETURN_TYPE 'V', .Lcleanup_and_return |
| 2302 | MATCH_RETURN_TYPE 'L', .Lstore_int_result |
| 2303 | MATCH_RETURN_TYPE 'I', .Lstore_int_result |
| 2304 | MATCH_RETURN_TYPE 'J', .Lstore_long_result |
| 2305 | MATCH_RETURN_TYPE 'B', .Lstore_int_result |
| 2306 | MATCH_RETURN_TYPE 'C', .Lstore_char_result |
| 2307 | MATCH_RETURN_TYPE 'D', .Lstore_double_result |
| 2308 | MATCH_RETURN_TYPE 'F', .Lstore_float_result |
| 2309 | MATCH_RETURN_TYPE 'S', .Lstore_int_result |
| 2310 | .purgem MATCH_RETURN_TYPE |
| 2311 | nop |
| 2312 | b .Lcleanup_and_return |
| 2313 | nop |
| 2314 | .Lstore_boolean_result: |
| 2315 | lbu $v0, 16($sp) # Move byte from JValue result to return value register. |
| 2316 | b .Lcleanup_and_return |
| 2317 | nop |
| 2318 | .Lstore_char_result: |
| 2319 | lhu $v0, 16($sp) # Move char from JValue result to return value register. |
| 2320 | b .Lcleanup_and_return |
| 2321 | nop |
| 2322 | .Lstore_double_result: |
| 2323 | .Lstore_float_result: |
| 2324 | LDu $f0, $f1, 16, $sp, $t0 # Move double/float from JValue result to return value register. |
| 2325 | b .Lcleanup_and_return |
| 2326 | nop |
| 2327 | .Lstore_long_result: |
| 2328 | lw $v1, 20($sp) # Move upper bits from JValue result to return value register. |
| 2329 | // Fall-through for lower bits. |
| 2330 | .Lstore_int_result: |
| 2331 | lw $v0, 16($sp) # Move lower bits from JValue result to return value register. |
| 2332 | // Fall-through to clean up and return. |
| 2333 | .Lcleanup_and_return: |
| 2334 | addiu $sp, $sp, 24 # Remove space for JValue result and the 4 words for the callee. |
| 2335 | .cfi_adjust_cfa_offset -24 |
| 2336 | lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # Load Thread::Current()->exception_ |
| 2337 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
| 2338 | bnez $t7, 1f # Success if no exception is pending. |
| 2339 | nop |
| 2340 | jalr $zero, $ra |
| 2341 | nop |
| 2342 | 1: |
| 2343 | DELIVER_PENDING_EXCEPTION |
| 2344 | END art_quick_invoke_polymorphic |