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