Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "asm_support_arm64.S" |
David Srbecky | 946bb09 | 2018-03-09 17:23:01 +0000 | [diff] [blame] | 18 | #include "interpreter/cfi_asm_support.h" |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 19 | |
| 20 | #include "arch/quick_alloc_entrypoints.S" |
| 21 | |
| 22 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 23 | .macro INCREASE_FRAME frame_adjustment |
| 24 | sub sp, sp, #(\frame_adjustment) |
| 25 | .cfi_adjust_cfa_offset (\frame_adjustment) |
| 26 | .endm |
| 27 | |
| 28 | .macro DECREASE_FRAME frame_adjustment |
| 29 | add sp, sp, #(\frame_adjustment) |
| 30 | .cfi_adjust_cfa_offset -(\frame_adjustment) |
| 31 | .endm |
| 32 | |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 33 | .macro SAVE_REG reg, offset |
| 34 | str \reg, [sp, #(\offset)] |
| 35 | .cfi_rel_offset \reg, (\offset) |
| 36 | .endm |
| 37 | |
| 38 | .macro RESTORE_REG reg, offset |
| 39 | ldr \reg, [sp, #(\offset)] |
| 40 | .cfi_restore \reg |
| 41 | .endm |
| 42 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 43 | .macro SAVE_REG_INCREASE_FRAME reg, frame_adjustment |
| 44 | str \reg, [sp, #-(\frame_adjustment)]! |
| 45 | .cfi_adjust_cfa_offset (\frame_adjustment) |
| 46 | .cfi_rel_offset \reg, 0 |
| 47 | .endm |
| 48 | |
| 49 | .macro RESTORE_REG_DECREASE_FRAME reg, frame_adjustment |
| 50 | ldr \reg, [sp], #(\frame_adjustment) |
| 51 | .cfi_restore \reg |
| 52 | .cfi_adjust_cfa_offset -(\frame_adjustment) |
| 53 | .endm |
| 54 | |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 55 | .macro SAVE_TWO_REGS reg1, reg2, offset |
| 56 | stp \reg1, \reg2, [sp, #(\offset)] |
| 57 | .cfi_rel_offset \reg1, (\offset) |
| 58 | .cfi_rel_offset \reg2, (\offset) + 8 |
| 59 | .endm |
| 60 | |
| 61 | .macro RESTORE_TWO_REGS reg1, reg2, offset |
| 62 | ldp \reg1, \reg2, [sp, #(\offset)] |
| 63 | .cfi_restore \reg1 |
| 64 | .cfi_restore \reg2 |
| 65 | .endm |
| 66 | |
| 67 | .macro SAVE_TWO_REGS_INCREASE_FRAME reg1, reg2, frame_adjustment |
| 68 | stp \reg1, \reg2, [sp, #-(\frame_adjustment)]! |
| 69 | .cfi_adjust_cfa_offset (\frame_adjustment) |
| 70 | .cfi_rel_offset \reg1, 0 |
| 71 | .cfi_rel_offset \reg2, 8 |
| 72 | .endm |
| 73 | |
| 74 | .macro RESTORE_TWO_REGS_DECREASE_FRAME reg1, reg2, frame_adjustment |
| 75 | ldp \reg1, \reg2, [sp], #(\frame_adjustment) |
| 76 | .cfi_restore \reg1 |
| 77 | .cfi_restore \reg2 |
| 78 | .cfi_adjust_cfa_offset -(\frame_adjustment) |
| 79 | .endm |
| 80 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 81 | /* |
| 82 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 83 | * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 84 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 85 | .macro SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| 86 | // art::Runtime** xIP0 = &art::Runtime::instance_ |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 87 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 88 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 89 | |
| 90 | // Our registers aren't intermixed - just spill in order. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 91 | ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 92 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 93 | // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveAllCalleeSaves]; |
| 94 | ldr xIP0, [xIP0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 95 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 96 | INCREASE_FRAME 176 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 97 | |
| 98 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 99 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 176) |
| 100 | #error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(ARM64) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 101 | #endif |
| 102 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 103 | // Stack alignment filler [sp, #8]. |
| 104 | // FP callee-saves. |
| 105 | stp d8, d9, [sp, #16] |
| 106 | stp d10, d11, [sp, #32] |
| 107 | stp d12, d13, [sp, #48] |
| 108 | stp d14, d15, [sp, #64] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 109 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 110 | // GP callee-saves |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 111 | SAVE_TWO_REGS x19, x20, 80 |
| 112 | SAVE_TWO_REGS x21, x22, 96 |
| 113 | SAVE_TWO_REGS x23, x24, 112 |
| 114 | SAVE_TWO_REGS x25, x26, 128 |
| 115 | SAVE_TWO_REGS x27, x28, 144 |
| 116 | SAVE_TWO_REGS x29, xLR, 160 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 117 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 118 | // Store ArtMethod* Runtime::callee_save_methods_[kSaveAllCalleeSaves]. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 119 | str xIP0, [sp] |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 120 | // Place sp in Thread::Current()->top_quick_frame. |
| 121 | mov xIP0, sp |
| 122 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 123 | .endm |
| 124 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 125 | /* |
| 126 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 127 | * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly). |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 128 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 129 | .macro SETUP_SAVE_REFS_ONLY_FRAME |
| 130 | // art::Runtime** xIP0 = &art::Runtime::instance_ |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 131 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 132 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
| 133 | |
| 134 | // Our registers aren't intermixed - just spill in order. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 135 | ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_; |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 136 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 137 | // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveRefOnly]; |
| 138 | ldr xIP0, [xIP0, RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET] |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 139 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 140 | INCREASE_FRAME 96 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 141 | |
| 142 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 143 | #if (FRAME_SIZE_SAVE_REFS_ONLY != 96) |
| 144 | #error "FRAME_SIZE_SAVE_REFS_ONLY(ARM64) size not as expected." |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 145 | #endif |
| 146 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 147 | // GP callee-saves. |
| 148 | // x20 paired with ArtMethod* - see below. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 149 | SAVE_TWO_REGS x21, x22, 16 |
| 150 | SAVE_TWO_REGS x23, x24, 32 |
| 151 | SAVE_TWO_REGS x25, x26, 48 |
| 152 | SAVE_TWO_REGS x27, x28, 64 |
| 153 | SAVE_TWO_REGS x29, xLR, 80 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 154 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 155 | // Store ArtMethod* Runtime::callee_save_methods_[kSaveRefsOnly]. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 156 | // Note: We could avoid saving X20 in the case of Baker read |
| 157 | // barriers, as it is overwritten by REFRESH_MARKING_REGISTER |
| 158 | // later; but it's not worth handling this special case. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 159 | stp xIP0, x20, [sp] |
| 160 | .cfi_rel_offset x20, 8 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 161 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 162 | // Place sp in Thread::Current()->top_quick_frame. |
| 163 | mov xIP0, sp |
| 164 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 165 | .endm |
| 166 | |
| 167 | // TODO: Probably no need to restore registers preserved by aapcs64. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 168 | .macro RESTORE_SAVE_REFS_ONLY_FRAME |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 169 | // Callee-saves. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 170 | // Note: Likewise, we could avoid restoring X20 in the case of Baker |
| 171 | // read barriers, as it is overwritten by REFRESH_MARKING_REGISTER |
| 172 | // later; but it's not worth handling this special case. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 173 | RESTORE_REG x20, 8 |
| 174 | RESTORE_TWO_REGS x21, x22, 16 |
| 175 | RESTORE_TWO_REGS x23, x24, 32 |
| 176 | RESTORE_TWO_REGS x25, x26, 48 |
| 177 | RESTORE_TWO_REGS x27, x28, 64 |
| 178 | RESTORE_TWO_REGS x29, xLR, 80 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 179 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 180 | DECREASE_FRAME 96 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 181 | .endm |
| 182 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 183 | .macro POP_SAVE_REFS_ONLY_FRAME |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 184 | DECREASE_FRAME 96 |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 185 | .endm |
| 186 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 187 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 188 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 189 | INCREASE_FRAME 224 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 190 | |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 191 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 192 | #if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 224) |
| 193 | #error "FRAME_SIZE_SAVE_REFS_AND_ARGS(ARM64) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 194 | #endif |
| 195 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 196 | // Stack alignment filler [sp, #8]. |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 197 | // FP args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 198 | stp d0, d1, [sp, #16] |
| 199 | stp d2, d3, [sp, #32] |
| 200 | stp d4, d5, [sp, #48] |
| 201 | stp d6, d7, [sp, #64] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 202 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 203 | // Core args. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 204 | SAVE_TWO_REGS x1, x2, 80 |
| 205 | SAVE_TWO_REGS x3, x4, 96 |
| 206 | SAVE_TWO_REGS x5, x6, 112 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 207 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 208 | // x7, Callee-saves. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 209 | // Note: We could avoid saving X20 in the case of Baker read |
| 210 | // barriers, as it is overwritten by REFRESH_MARKING_REGISTER |
| 211 | // later; but it's not worth handling this special case. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 212 | SAVE_TWO_REGS x7, x20, 128 |
| 213 | SAVE_TWO_REGS x21, x22, 144 |
| 214 | SAVE_TWO_REGS x23, x24, 160 |
| 215 | SAVE_TWO_REGS x25, x26, 176 |
| 216 | SAVE_TWO_REGS x27, x28, 192 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 217 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 218 | // x29(callee-save) and LR. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 219 | SAVE_TWO_REGS x29, xLR, 208 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 220 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 221 | .endm |
| 222 | |
| 223 | /* |
| 224 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 225 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 226 | * |
| 227 | * TODO This is probably too conservative - saving FP & LR. |
| 228 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 229 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME |
| 230 | // art::Runtime** xIP0 = &art::Runtime::instance_ |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 231 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 232 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 233 | |
| 234 | // Our registers aren't intermixed - just spill in order. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 235 | ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 236 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 237 | // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveRefAndArgs]; |
| 238 | ldr xIP0, [xIP0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 239 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 240 | SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 241 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 242 | str xIP0, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kSaveRefsAndArgs]. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 243 | // Place sp in Thread::Current()->top_quick_frame. |
| 244 | mov xIP0, sp |
| 245 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
| 246 | .endm |
| 247 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 248 | .macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0 |
| 249 | SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 250 | str x0, [sp, #0] // Store ArtMethod* to bottom of stack. |
| 251 | // Place sp in Thread::Current()->top_quick_frame. |
| 252 | mov xIP0, sp |
| 253 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 254 | .endm |
| 255 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 256 | // TODO: Probably no need to restore registers preserved by aapcs64. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 257 | .macro RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 258 | // FP args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 259 | ldp d0, d1, [sp, #16] |
| 260 | ldp d2, d3, [sp, #32] |
| 261 | ldp d4, d5, [sp, #48] |
| 262 | ldp d6, d7, [sp, #64] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 263 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 264 | // Core args. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 265 | RESTORE_TWO_REGS x1, x2, 80 |
| 266 | RESTORE_TWO_REGS x3, x4, 96 |
| 267 | RESTORE_TWO_REGS x5, x6, 112 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 268 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 269 | // x7, Callee-saves. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 270 | // Note: Likewise, we could avoid restoring X20 in the case of Baker |
| 271 | // read barriers, as it is overwritten by REFRESH_MARKING_REGISTER |
| 272 | // later; but it's not worth handling this special case. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 273 | RESTORE_TWO_REGS x7, x20, 128 |
| 274 | RESTORE_TWO_REGS x21, x22, 144 |
| 275 | RESTORE_TWO_REGS x23, x24, 160 |
| 276 | RESTORE_TWO_REGS x25, x26, 176 |
| 277 | RESTORE_TWO_REGS x27, x28, 192 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 278 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 279 | // x29(callee-save) and LR. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 280 | RESTORE_TWO_REGS x29, xLR, 208 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 281 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 282 | DECREASE_FRAME 224 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 283 | .endm |
| 284 | |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 285 | /* |
| 286 | * Macro that sets up the callee save frame to conform with |
| 287 | * Runtime::CreateCalleeSaveMethod(kSaveEverything) |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 288 | * when the SP has already been decremented by FRAME_SIZE_SAVE_EVERYTHING |
| 289 | * and saving registers x29 and LR is handled elsewhere. |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 290 | */ |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 291 | .macro SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP_SKIP_X29_LR runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 292 | // Ugly compile-time check, but we only have the preprocessor. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 293 | #if (FRAME_SIZE_SAVE_EVERYTHING != 512) |
| 294 | #error "FRAME_SIZE_SAVE_EVERYTHING(ARM64) size not as expected." |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 295 | #endif |
| 296 | |
| 297 | // Save FP registers. |
Vladimir Marko | 40df7c1 | 2016-08-22 16:02:12 +0100 | [diff] [blame] | 298 | // For better performance, store d0 and d31 separately, so that all STPs are 16-byte aligned. |
Vladimir Marko | de5f194 | 2016-08-10 12:30:05 +0100 | [diff] [blame] | 299 | str d0, [sp, #8] |
| 300 | stp d1, d2, [sp, #16] |
| 301 | stp d3, d4, [sp, #32] |
| 302 | stp d5, d6, [sp, #48] |
| 303 | stp d7, d8, [sp, #64] |
| 304 | stp d9, d10, [sp, #80] |
| 305 | stp d11, d12, [sp, #96] |
| 306 | stp d13, d14, [sp, #112] |
| 307 | stp d15, d16, [sp, #128] |
| 308 | stp d17, d18, [sp, #144] |
| 309 | stp d19, d20, [sp, #160] |
| 310 | stp d21, d22, [sp, #176] |
| 311 | stp d23, d24, [sp, #192] |
| 312 | stp d25, d26, [sp, #208] |
| 313 | stp d27, d28, [sp, #224] |
| 314 | stp d29, d30, [sp, #240] |
| 315 | str d31, [sp, #256] |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 316 | |
| 317 | // Save core registers. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 318 | SAVE_REG x0, 264 |
| 319 | SAVE_TWO_REGS x1, x2, 272 |
| 320 | SAVE_TWO_REGS x3, x4, 288 |
| 321 | SAVE_TWO_REGS x5, x6, 304 |
| 322 | SAVE_TWO_REGS x7, x8, 320 |
| 323 | SAVE_TWO_REGS x9, x10, 336 |
| 324 | SAVE_TWO_REGS x11, x12, 352 |
| 325 | SAVE_TWO_REGS x13, x14, 368 |
| 326 | SAVE_TWO_REGS x15, x16, 384 |
| 327 | SAVE_TWO_REGS x17, x18, 400 |
| 328 | SAVE_TWO_REGS x19, x20, 416 |
| 329 | SAVE_TWO_REGS x21, x22, 432 |
| 330 | SAVE_TWO_REGS x23, x24, 448 |
| 331 | SAVE_TWO_REGS x25, x26, 464 |
| 332 | SAVE_TWO_REGS x27, x28, 480 |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 333 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 334 | // art::Runtime** xIP0 = &art::Runtime::instance_ |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 335 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 336 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
| 337 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 338 | ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_; |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 339 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 340 | // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveEverything]; |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 341 | ldr xIP0, [xIP0, \runtime_method_offset] |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 342 | |
| 343 | // Store ArtMethod* Runtime::callee_save_methods_[kSaveEverything]. |
| 344 | str xIP0, [sp] |
| 345 | // Place sp in Thread::Current()->top_quick_frame. |
| 346 | mov xIP0, sp |
| 347 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
| 348 | .endm |
| 349 | |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 350 | /* |
| 351 | * Macro that sets up the callee save frame to conform with |
| 352 | * Runtime::CreateCalleeSaveMethod(kSaveEverything) |
| 353 | */ |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 354 | .macro SETUP_SAVE_EVERYTHING_FRAME runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 355 | INCREASE_FRAME 512 |
| 356 | SAVE_TWO_REGS x29, xLR, 496 |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 357 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP_SKIP_X29_LR \runtime_method_offset |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 358 | .endm |
| 359 | |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 360 | .macro RESTORE_SAVE_EVERYTHING_FRAME_KEEP_X0 |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 361 | // Restore FP registers. |
Vladimir Marko | 40df7c1 | 2016-08-22 16:02:12 +0100 | [diff] [blame] | 362 | // For better performance, load d0 and d31 separately, so that all LDPs are 16-byte aligned. |
Vladimir Marko | de5f194 | 2016-08-10 12:30:05 +0100 | [diff] [blame] | 363 | ldr d0, [sp, #8] |
| 364 | ldp d1, d2, [sp, #16] |
| 365 | ldp d3, d4, [sp, #32] |
| 366 | ldp d5, d6, [sp, #48] |
| 367 | ldp d7, d8, [sp, #64] |
| 368 | ldp d9, d10, [sp, #80] |
| 369 | ldp d11, d12, [sp, #96] |
| 370 | ldp d13, d14, [sp, #112] |
| 371 | ldp d15, d16, [sp, #128] |
| 372 | ldp d17, d18, [sp, #144] |
| 373 | ldp d19, d20, [sp, #160] |
| 374 | ldp d21, d22, [sp, #176] |
| 375 | ldp d23, d24, [sp, #192] |
| 376 | ldp d25, d26, [sp, #208] |
| 377 | ldp d27, d28, [sp, #224] |
| 378 | ldp d29, d30, [sp, #240] |
| 379 | ldr d31, [sp, #256] |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 380 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 381 | // Restore core registers, except x0. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 382 | RESTORE_TWO_REGS x1, x2, 272 |
| 383 | RESTORE_TWO_REGS x3, x4, 288 |
| 384 | RESTORE_TWO_REGS x5, x6, 304 |
| 385 | RESTORE_TWO_REGS x7, x8, 320 |
| 386 | RESTORE_TWO_REGS x9, x10, 336 |
| 387 | RESTORE_TWO_REGS x11, x12, 352 |
| 388 | RESTORE_TWO_REGS x13, x14, 368 |
| 389 | RESTORE_TWO_REGS x15, x16, 384 |
| 390 | RESTORE_TWO_REGS x17, x18, 400 |
| 391 | RESTORE_TWO_REGS x19, x20, 416 |
| 392 | RESTORE_TWO_REGS x21, x22, 432 |
| 393 | RESTORE_TWO_REGS x23, x24, 448 |
| 394 | RESTORE_TWO_REGS x25, x26, 464 |
| 395 | RESTORE_TWO_REGS x27, x28, 480 |
| 396 | RESTORE_TWO_REGS x29, xLR, 496 |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 397 | |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 398 | DECREASE_FRAME 512 |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 399 | .endm |
| 400 | |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 401 | .macro RESTORE_SAVE_EVERYTHING_FRAME |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 402 | RESTORE_REG x0, 264 |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 403 | RESTORE_SAVE_EVERYTHING_FRAME_KEEP_X0 |
| 404 | .endm |
| 405 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 406 | // Macro to refresh the Marking Register (W20). |
| 407 | // |
| 408 | // This macro must be called at the end of functions implementing |
| 409 | // entrypoints that possibly (directly or indirectly) perform a |
| 410 | // suspend check (before they return). |
| 411 | .macro REFRESH_MARKING_REGISTER |
| 412 | #if defined(USE_READ_BARRIER) && defined(USE_BAKER_READ_BARRIER) |
| 413 | ldr wMR, [xSELF, #THREAD_IS_GC_MARKING_OFFSET] |
| 414 | #endif |
| 415 | .endm |
| 416 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 417 | .macro RETURN_IF_RESULT_IS_ZERO |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 418 | cbnz x0, 1f // result non-zero branch over |
| 419 | ret // return |
| 420 | 1: |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 421 | .endm |
| 422 | |
| 423 | .macro RETURN_IF_RESULT_IS_NON_ZERO |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 424 | cbz x0, 1f // result zero branch over |
| 425 | ret // return |
| 426 | 1: |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 427 | .endm |
| 428 | |
| 429 | /* |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 430 | * Macro that calls through to artDeliverPendingExceptionFromCode, where the pending |
| 431 | * exception is Thread::Current()->exception_ when the runtime method frame is ready. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 432 | */ |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 433 | .macro DELIVER_PENDING_EXCEPTION_FRAME_READY |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 434 | mov x0, xSELF |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 435 | |
| 436 | // Point of no return. |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 437 | bl artDeliverPendingExceptionFromCode // artDeliverPendingExceptionFromCode(Thread*) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 438 | brk 0 // Unreached |
| 439 | .endm |
| 440 | |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 441 | /* |
| 442 | * Macro that calls through to artDeliverPendingExceptionFromCode, where the pending |
| 443 | * exception is Thread::Current()->exception_. |
| 444 | */ |
| 445 | .macro DELIVER_PENDING_EXCEPTION |
| 446 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
| 447 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 448 | .endm |
| 449 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 450 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg |
| 451 | ldr \reg, [xSELF, # THREAD_EXCEPTION_OFFSET] // Get exception field. |
| 452 | cbnz \reg, 1f |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 453 | ret |
| 454 | 1: |
| 455 | DELIVER_PENDING_EXCEPTION |
| 456 | .endm |
| 457 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 458 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 459 | RETURN_OR_DELIVER_PENDING_EXCEPTION_REG xIP0 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 460 | .endm |
| 461 | |
| 462 | // Same as above with x1. This is helpful in stubs that want to avoid clobbering another register. |
| 463 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 464 | RETURN_OR_DELIVER_PENDING_EXCEPTION_REG x1 |
| 465 | .endm |
| 466 | |
| 467 | .macro RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 468 | cbnz w0, 1f // result non-zero branch over |
| 469 | ret // return |
| 470 | 1: |
| 471 | DELIVER_PENDING_EXCEPTION |
| 472 | .endm |
| 473 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 474 | .macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 475 | .extern \cxx_name |
| 476 | ENTRY \c_name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 477 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 478 | mov x0, xSELF // pass Thread::Current |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 479 | bl \cxx_name // \cxx_name(Thread*) |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 480 | brk 0 |
| 481 | END \c_name |
| 482 | .endm |
| 483 | |
| 484 | .macro NO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING c_name, cxx_name |
| 485 | .extern \cxx_name |
| 486 | ENTRY \c_name |
| 487 | SETUP_SAVE_EVERYTHING_FRAME // save all registers as basis for long jump context |
| 488 | mov x0, xSELF // pass Thread::Current |
| 489 | bl \cxx_name // \cxx_name(Thread*) |
| 490 | brk 0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 491 | END \c_name |
| 492 | .endm |
| 493 | |
| 494 | .macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 495 | .extern \cxx_name |
| 496 | ENTRY \c_name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 497 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 498 | mov x1, xSELF // pass Thread::Current. |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 499 | bl \cxx_name // \cxx_name(arg, Thread*). |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 500 | brk 0 |
| 501 | END \c_name |
| 502 | .endm |
| 503 | |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 504 | .macro TWO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING c_name, cxx_name |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 505 | .extern \cxx_name |
| 506 | ENTRY \c_name |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 507 | SETUP_SAVE_EVERYTHING_FRAME // save all registers as basis for long jump context |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 508 | mov x2, xSELF // pass Thread::Current |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 509 | bl \cxx_name // \cxx_name(arg1, arg2, Thread*) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 510 | brk 0 |
| 511 | END \c_name |
| 512 | .endm |
| 513 | |
| 514 | /* |
| 515 | * Called by managed code, saves callee saves and then calls artThrowException |
| 516 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 517 | */ |
| 518 | ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode |
| 519 | |
| 520 | /* |
| 521 | * Called by managed code to create and deliver a NullPointerException. |
| 522 | */ |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 523 | NO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 524 | |
| 525 | /* |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 526 | * Call installed by a signal handler to create and deliver a NullPointerException. |
| 527 | */ |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 528 | .extern art_quick_throw_null_pointer_exception_from_signal |
| 529 | ENTRY art_quick_throw_null_pointer_exception_from_signal |
| 530 | // The fault handler pushes the gc map address, i.e. "return address", to stack |
| 531 | // and passes the fault address in LR. So we need to set up the CFI info accordingly. |
| 532 | .cfi_def_cfa_offset __SIZEOF_POINTER__ |
| 533 | .cfi_rel_offset lr, 0 |
| 534 | // Save all registers as basis for long jump context. |
| 535 | INCREASE_FRAME (FRAME_SIZE_SAVE_EVERYTHING - __SIZEOF_POINTER__) |
| 536 | SAVE_REG x29, (FRAME_SIZE_SAVE_EVERYTHING - 2 * __SIZEOF_POINTER__) // LR already saved. |
| 537 | SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP_SKIP_X29_LR |
| 538 | mov x0, lr // pass the fault address stored in LR by the fault handler. |
| 539 | mov x1, xSELF // pass Thread::Current. |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 540 | bl artThrowNullPointerExceptionFromSignal // (arg, Thread*). |
Vladimir Marko | 3b7537b | 2016-09-13 11:56:01 +0000 | [diff] [blame] | 541 | brk 0 |
| 542 | END art_quick_throw_null_pointer_exception_from_signal |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 543 | |
| 544 | /* |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 545 | * Called by managed code to create and deliver an ArithmeticException. |
| 546 | */ |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 547 | NO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING art_quick_throw_div_zero, artThrowDivZeroFromCode |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 548 | |
| 549 | /* |
| 550 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 551 | * index, arg2 holds limit. |
| 552 | */ |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 553 | TWO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING art_quick_throw_array_bounds, artThrowArrayBoundsFromCode |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 554 | |
| 555 | /* |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 556 | * Called by managed code to create and deliver a StringIndexOutOfBoundsException |
| 557 | * as if thrown from a call to String.charAt(). Arg1 holds index, arg2 holds limit. |
| 558 | */ |
Vladimir Marko | 804b03f | 2016-09-14 16:26:36 +0100 | [diff] [blame] | 559 | TWO_ARG_RUNTIME_EXCEPTION_SAVE_EVERYTHING art_quick_throw_string_bounds, artThrowStringBoundsFromCode |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 560 | |
| 561 | /* |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 562 | * Called by managed code to create and deliver a StackOverflowError. |
| 563 | */ |
| 564 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode |
| 565 | |
| 566 | /* |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 567 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 568 | * as usual - except instead of loading arg0/x0 with the target Method*, arg0/x0 will contain |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 569 | * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper. |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 570 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/x1. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 571 | * |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 572 | * The helper will attempt to locate the target and return a 128-bit result in x0/x1 consisting |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 573 | * of the target Method* in x0 and method->code_ in x1. |
| 574 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 575 | * If unsuccessful, the helper will return null/????. There will be a pending exception in the |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 576 | * thread and we branch to another stub to deliver it. |
| 577 | * |
| 578 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 579 | * pointing back to the original caller. |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 580 | * |
| 581 | * Adapted from ARM32 code. |
| 582 | * |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 583 | * Clobbers xIP0. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 584 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 585 | .macro INVOKE_TRAMPOLINE_BODY cxx_name |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 586 | .extern \cxx_name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 587 | SETUP_SAVE_REFS_AND_ARGS_FRAME // save callee saves in case allocation triggers GC |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 588 | // Helper signature is always |
| 589 | // (method_idx, *this_object, *caller_method, *self, sp) |
| 590 | |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 591 | mov x2, xSELF // pass Thread::Current |
| 592 | mov x3, sp |
| 593 | bl \cxx_name // (method_idx, this, Thread*, SP) |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 594 | mov xIP0, x1 // save Method*->code_ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 595 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 596 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 597 | cbz x0, 1f // did we find the target? if not go to exception delivery |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 598 | br xIP0 // tail call to target |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 599 | 1: |
| 600 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 601 | .endm |
| 602 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 603 | ENTRY \c_name |
| 604 | INVOKE_TRAMPOLINE_BODY \cxx_name |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 605 | END \c_name |
| 606 | .endm |
| 607 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 608 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 609 | |
| 610 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 611 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 612 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 613 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| 614 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 615 | |
| 616 | .macro INVOKE_STUB_CREATE_FRAME |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 617 | SAVE_SIZE=6*8 // x4, x5, x19, x20, FP, LR saved. |
| 618 | SAVE_TWO_REGS_INCREASE_FRAME x4, x5, SAVE_SIZE |
| 619 | SAVE_TWO_REGS x19, x20, 16 |
| 620 | SAVE_TWO_REGS xFP, xLR, 32 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 621 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 622 | mov xFP, sp // Use xFP for frame pointer, as it's callee-saved. |
| 623 | .cfi_def_cfa_register xFP |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 624 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 625 | add x10, x2, #(__SIZEOF_POINTER__ + 0xf) // Reserve space for ArtMethod*, arguments and |
| 626 | and x10, x10, # ~0xf // round up for 16-byte stack alignment. |
| 627 | sub sp, sp, x10 // Adjust SP for ArtMethod*, args and alignment padding. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 628 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 629 | mov xSELF, x3 // Move thread pointer into SELF register. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 630 | |
| 631 | // Copy arguments into stack frame. |
| 632 | // Use simple copy routine for now. |
| 633 | // 4 bytes per slot. |
| 634 | // X1 - source address |
| 635 | // W2 - args length |
| 636 | // X9 - destination address. |
| 637 | // W10 - temporary |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 638 | add x9, sp, #8 // Destination address is bottom of stack + null. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 639 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 640 | // Copy parameters into the stack. Use numeric label as this is a macro and Clang's assembler |
| 641 | // does not have unique-id variables. |
| 642 | 1: |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 643 | cbz w2, 2f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 644 | sub w2, w2, #4 // Need 65536 bytes of range. |
| 645 | ldr w10, [x1, x2] |
| 646 | str w10, [x9, x2] |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 647 | b 1b |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 648 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 649 | 2: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 650 | // Store null into ArtMethod* at bottom of frame. |
| 651 | str xzr, [sp] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 652 | .endm |
| 653 | |
| 654 | .macro INVOKE_STUB_CALL_AND_RETURN |
| 655 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 656 | REFRESH_MARKING_REGISTER |
| 657 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 658 | // load method-> METHOD_QUICK_CODE_OFFSET |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 659 | ldr x9, [x0, #ART_METHOD_QUICK_CODE_OFFSET_64] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 660 | // Branch to method. |
| 661 | blr x9 |
| 662 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 663 | // Pop the ArtMethod* (null), arguments and alignment padding from the stack. |
| 664 | mov sp, xFP |
| 665 | .cfi_def_cfa_register sp |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 666 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 667 | // Restore saved registers including value address and shorty address. |
| 668 | RESTORE_TWO_REGS x19, x20, 16 |
| 669 | RESTORE_TWO_REGS xFP, xLR, 32 |
| 670 | RESTORE_TWO_REGS_DECREASE_FRAME x4, x5, SAVE_SIZE |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 671 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 672 | // Store result (w0/x0/s0/d0) appropriately, depending on resultType. |
| 673 | ldrb w10, [x5] |
| 674 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 675 | // Check the return type and store the correct register into the jvalue in memory. |
| 676 | // Use numeric label as this is a macro and Clang's assembler does not have unique-id variables. |
| 677 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 678 | // Don't set anything for a void type. |
| 679 | cmp w10, #'V' |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 680 | beq 1f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 681 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 682 | // Is it a double? |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 683 | cmp w10, #'D' |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 684 | beq 2f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 685 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 686 | // Is it a float? |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 687 | cmp w10, #'F' |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 688 | beq 3f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 689 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 690 | // Just store x0. Doesn't matter if it is 64 or 32 bits. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 691 | str x0, [x4] |
| 692 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 693 | 1: // Finish up. |
| 694 | ret |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 695 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 696 | 2: // Store double. |
| 697 | str d0, [x4] |
| 698 | ret |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 699 | |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 700 | 3: // Store float. |
| 701 | str s0, [x4] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 702 | ret |
| 703 | |
| 704 | .endm |
| 705 | |
| 706 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 707 | /* |
| 708 | * extern"C" void art_quick_invoke_stub(ArtMethod *method, x0 |
| 709 | * uint32_t *args, x1 |
| 710 | * uint32_t argsize, w2 |
| 711 | * Thread *self, x3 |
| 712 | * JValue *result, x4 |
| 713 | * char *shorty); x5 |
| 714 | * +----------------------+ |
| 715 | * | | |
| 716 | * | C/C++ frame | |
| 717 | * | LR'' | |
| 718 | * | FP'' | <- SP' |
| 719 | * +----------------------+ |
| 720 | * +----------------------+ |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 721 | * | x28 | <- TODO: Remove callee-saves. |
| 722 | * | : | |
| 723 | * | x19 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 724 | * | SP' | |
| 725 | * | X5 | |
| 726 | * | X4 | Saved registers |
| 727 | * | LR' | |
| 728 | * | FP' | <- FP |
| 729 | * +----------------------+ |
| 730 | * | uint32_t out[n-1] | |
| 731 | * | : : | Outs |
| 732 | * | uint32_t out[0] | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 733 | * | ArtMethod* | <- SP value=null |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 734 | * +----------------------+ |
| 735 | * |
| 736 | * Outgoing registers: |
| 737 | * x0 - Method* |
| 738 | * x1-x7 - integer parameters. |
| 739 | * d0-d7 - Floating point parameters. |
| 740 | * xSELF = self |
| 741 | * SP = & of ArtMethod* |
| 742 | * x1 = "this" pointer. |
| 743 | * |
| 744 | */ |
| 745 | ENTRY art_quick_invoke_stub |
| 746 | // Spill registers as per AACPS64 calling convention. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 747 | INVOKE_STUB_CREATE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 748 | |
| 749 | // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. |
| 750 | // Parse the passed shorty to determine which register to load. |
| 751 | // Load addresses for routines that load WXSD registers. |
| 752 | adr x11, .LstoreW2 |
| 753 | adr x12, .LstoreX2 |
| 754 | adr x13, .LstoreS0 |
| 755 | adr x14, .LstoreD0 |
| 756 | |
| 757 | // Initialize routine offsets to 0 for integers and floats. |
| 758 | // x8 for integers, x15 for floating point. |
| 759 | mov x8, #0 |
| 760 | mov x15, #0 |
| 761 | |
| 762 | add x10, x5, #1 // Load shorty address, plus one to skip return value. |
| 763 | ldr w1, [x9],#4 // Load "this" parameter, and increment arg pointer. |
| 764 | |
| 765 | // Loop to fill registers. |
| 766 | .LfillRegisters: |
| 767 | ldrb w17, [x10], #1 // Load next character in signature, and increment. |
| 768 | cbz w17, .LcallFunction // Exit at end of signature. Shorty 0 terminated. |
| 769 | |
| 770 | cmp w17, #'F' // is this a float? |
| 771 | bne .LisDouble |
| 772 | |
| 773 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 774 | beq .Ladvance4 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 775 | |
| 776 | add x17, x13, x15 // Calculate subroutine to jump to. |
| 777 | br x17 |
| 778 | |
| 779 | .LisDouble: |
| 780 | cmp w17, #'D' // is this a double? |
| 781 | bne .LisLong |
| 782 | |
| 783 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 784 | beq .Ladvance8 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 785 | |
| 786 | add x17, x14, x15 // Calculate subroutine to jump to. |
| 787 | br x17 |
| 788 | |
| 789 | .LisLong: |
| 790 | cmp w17, #'J' // is this a long? |
| 791 | bne .LisOther |
| 792 | |
Andreas Gampe | 9de65ff | 2014-03-21 17:25:57 -0700 | [diff] [blame] | 793 | cmp x8, # 6*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 794 | beq .Ladvance8 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 795 | |
| 796 | add x17, x12, x8 // Calculate subroutine to jump to. |
| 797 | br x17 |
| 798 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 799 | .LisOther: // Everything else takes one vReg. |
Andreas Gampe | 9de65ff | 2014-03-21 17:25:57 -0700 | [diff] [blame] | 800 | cmp x8, # 6*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 801 | beq .Ladvance4 |
| 802 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 803 | add x17, x11, x8 // Calculate subroutine to jump to. |
| 804 | br x17 |
| 805 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 806 | .Ladvance4: |
| 807 | add x9, x9, #4 |
| 808 | b .LfillRegisters |
| 809 | |
| 810 | .Ladvance8: |
| 811 | add x9, x9, #8 |
| 812 | b .LfillRegisters |
| 813 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 814 | // Macro for loading a parameter into a register. |
| 815 | // counter - the register with offset into these tables |
| 816 | // size - the size of the register - 4 or 8 bytes. |
| 817 | // register - the name of the register to be loaded. |
| 818 | .macro LOADREG counter size register return |
| 819 | ldr \register , [x9], #\size |
| 820 | add \counter, \counter, 12 |
| 821 | b \return |
| 822 | .endm |
| 823 | |
| 824 | // Store ints. |
| 825 | .LstoreW2: |
| 826 | LOADREG x8 4 w2 .LfillRegisters |
| 827 | LOADREG x8 4 w3 .LfillRegisters |
| 828 | LOADREG x8 4 w4 .LfillRegisters |
| 829 | LOADREG x8 4 w5 .LfillRegisters |
| 830 | LOADREG x8 4 w6 .LfillRegisters |
| 831 | LOADREG x8 4 w7 .LfillRegisters |
| 832 | |
| 833 | // Store longs. |
| 834 | .LstoreX2: |
| 835 | LOADREG x8 8 x2 .LfillRegisters |
| 836 | LOADREG x8 8 x3 .LfillRegisters |
| 837 | LOADREG x8 8 x4 .LfillRegisters |
| 838 | LOADREG x8 8 x5 .LfillRegisters |
| 839 | LOADREG x8 8 x6 .LfillRegisters |
| 840 | LOADREG x8 8 x7 .LfillRegisters |
| 841 | |
| 842 | // Store singles. |
| 843 | .LstoreS0: |
| 844 | LOADREG x15 4 s0 .LfillRegisters |
| 845 | LOADREG x15 4 s1 .LfillRegisters |
| 846 | LOADREG x15 4 s2 .LfillRegisters |
| 847 | LOADREG x15 4 s3 .LfillRegisters |
| 848 | LOADREG x15 4 s4 .LfillRegisters |
| 849 | LOADREG x15 4 s5 .LfillRegisters |
| 850 | LOADREG x15 4 s6 .LfillRegisters |
| 851 | LOADREG x15 4 s7 .LfillRegisters |
| 852 | |
| 853 | // Store doubles. |
| 854 | .LstoreD0: |
| 855 | LOADREG x15 8 d0 .LfillRegisters |
| 856 | LOADREG x15 8 d1 .LfillRegisters |
| 857 | LOADREG x15 8 d2 .LfillRegisters |
| 858 | LOADREG x15 8 d3 .LfillRegisters |
| 859 | LOADREG x15 8 d4 .LfillRegisters |
| 860 | LOADREG x15 8 d5 .LfillRegisters |
| 861 | LOADREG x15 8 d6 .LfillRegisters |
| 862 | LOADREG x15 8 d7 .LfillRegisters |
| 863 | |
| 864 | |
| 865 | .LcallFunction: |
| 866 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 867 | INVOKE_STUB_CALL_AND_RETURN |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 868 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 869 | END art_quick_invoke_stub |
| 870 | |
| 871 | /* extern"C" |
| 872 | * void art_quick_invoke_static_stub(ArtMethod *method, x0 |
| 873 | * uint32_t *args, x1 |
| 874 | * uint32_t argsize, w2 |
| 875 | * Thread *self, x3 |
| 876 | * JValue *result, x4 |
| 877 | * char *shorty); x5 |
| 878 | */ |
| 879 | ENTRY art_quick_invoke_static_stub |
| 880 | // Spill registers as per AACPS64 calling convention. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 881 | INVOKE_STUB_CREATE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 882 | |
| 883 | // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. |
| 884 | // Parse the passed shorty to determine which register to load. |
| 885 | // Load addresses for routines that load WXSD registers. |
| 886 | adr x11, .LstoreW1_2 |
| 887 | adr x12, .LstoreX1_2 |
| 888 | adr x13, .LstoreS0_2 |
| 889 | adr x14, .LstoreD0_2 |
| 890 | |
| 891 | // Initialize routine offsets to 0 for integers and floats. |
| 892 | // x8 for integers, x15 for floating point. |
| 893 | mov x8, #0 |
| 894 | mov x15, #0 |
| 895 | |
| 896 | add x10, x5, #1 // Load shorty address, plus one to skip return value. |
| 897 | |
| 898 | // Loop to fill registers. |
| 899 | .LfillRegisters2: |
| 900 | ldrb w17, [x10], #1 // Load next character in signature, and increment. |
| 901 | cbz w17, .LcallFunction2 // Exit at end of signature. Shorty 0 terminated. |
| 902 | |
| 903 | cmp w17, #'F' // is this a float? |
| 904 | bne .LisDouble2 |
| 905 | |
| 906 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 907 | beq .Ladvance4_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 908 | |
| 909 | add x17, x13, x15 // Calculate subroutine to jump to. |
| 910 | br x17 |
| 911 | |
| 912 | .LisDouble2: |
| 913 | cmp w17, #'D' // is this a double? |
| 914 | bne .LisLong2 |
| 915 | |
| 916 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 917 | beq .Ladvance8_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 918 | |
| 919 | add x17, x14, x15 // Calculate subroutine to jump to. |
| 920 | br x17 |
| 921 | |
| 922 | .LisLong2: |
| 923 | cmp w17, #'J' // is this a long? |
| 924 | bne .LisOther2 |
| 925 | |
| 926 | cmp x8, # 7*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 927 | beq .Ladvance8_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 928 | |
| 929 | add x17, x12, x8 // Calculate subroutine to jump to. |
| 930 | br x17 |
| 931 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 932 | .LisOther2: // Everything else takes one vReg. |
| 933 | cmp x8, # 7*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 934 | beq .Ladvance4_2 |
| 935 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 936 | add x17, x11, x8 // Calculate subroutine to jump to. |
| 937 | br x17 |
| 938 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 939 | .Ladvance4_2: |
| 940 | add x9, x9, #4 |
| 941 | b .LfillRegisters2 |
| 942 | |
| 943 | .Ladvance8_2: |
| 944 | add x9, x9, #8 |
| 945 | b .LfillRegisters2 |
| 946 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 947 | // Store ints. |
| 948 | .LstoreW1_2: |
| 949 | LOADREG x8 4 w1 .LfillRegisters2 |
| 950 | LOADREG x8 4 w2 .LfillRegisters2 |
| 951 | LOADREG x8 4 w3 .LfillRegisters2 |
| 952 | LOADREG x8 4 w4 .LfillRegisters2 |
| 953 | LOADREG x8 4 w5 .LfillRegisters2 |
| 954 | LOADREG x8 4 w6 .LfillRegisters2 |
| 955 | LOADREG x8 4 w7 .LfillRegisters2 |
| 956 | |
| 957 | // Store longs. |
| 958 | .LstoreX1_2: |
| 959 | LOADREG x8 8 x1 .LfillRegisters2 |
| 960 | LOADREG x8 8 x2 .LfillRegisters2 |
| 961 | LOADREG x8 8 x3 .LfillRegisters2 |
| 962 | LOADREG x8 8 x4 .LfillRegisters2 |
| 963 | LOADREG x8 8 x5 .LfillRegisters2 |
| 964 | LOADREG x8 8 x6 .LfillRegisters2 |
| 965 | LOADREG x8 8 x7 .LfillRegisters2 |
| 966 | |
| 967 | // Store singles. |
| 968 | .LstoreS0_2: |
| 969 | LOADREG x15 4 s0 .LfillRegisters2 |
| 970 | LOADREG x15 4 s1 .LfillRegisters2 |
| 971 | LOADREG x15 4 s2 .LfillRegisters2 |
| 972 | LOADREG x15 4 s3 .LfillRegisters2 |
| 973 | LOADREG x15 4 s4 .LfillRegisters2 |
| 974 | LOADREG x15 4 s5 .LfillRegisters2 |
| 975 | LOADREG x15 4 s6 .LfillRegisters2 |
| 976 | LOADREG x15 4 s7 .LfillRegisters2 |
| 977 | |
| 978 | // Store doubles. |
| 979 | .LstoreD0_2: |
| 980 | LOADREG x15 8 d0 .LfillRegisters2 |
| 981 | LOADREG x15 8 d1 .LfillRegisters2 |
| 982 | LOADREG x15 8 d2 .LfillRegisters2 |
| 983 | LOADREG x15 8 d3 .LfillRegisters2 |
| 984 | LOADREG x15 8 d4 .LfillRegisters2 |
| 985 | LOADREG x15 8 d5 .LfillRegisters2 |
| 986 | LOADREG x15 8 d6 .LfillRegisters2 |
| 987 | LOADREG x15 8 d7 .LfillRegisters2 |
| 988 | |
| 989 | |
| 990 | .LcallFunction2: |
| 991 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 992 | INVOKE_STUB_CALL_AND_RETURN |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 993 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 994 | END art_quick_invoke_static_stub |
| 995 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 996 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 997 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 998 | /* extern"C" void art_quick_osr_stub(void** stack, x0 |
| 999 | * size_t stack_size_in_bytes, x1 |
Vladimir Marko | 7e61411 | 2018-03-06 14:34:06 +0000 | [diff] [blame] | 1000 | * const uint8_t* native_pc, x2 |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1001 | * JValue *result, x3 |
| 1002 | * char *shorty, x4 |
| 1003 | * Thread *self) x5 |
| 1004 | */ |
| 1005 | ENTRY art_quick_osr_stub |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1006 | SAVE_SIZE=14*8 // x3, x4, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, FP, LR saved. |
| 1007 | SAVE_TWO_REGS_INCREASE_FRAME x3, x4, SAVE_SIZE |
| 1008 | SAVE_TWO_REGS x19, x20, 16 |
| 1009 | SAVE_TWO_REGS x21, x22, 32 |
| 1010 | SAVE_TWO_REGS x23, x24, 48 |
| 1011 | SAVE_TWO_REGS x25, x26, 64 |
| 1012 | SAVE_TWO_REGS x27, x28, 80 |
| 1013 | SAVE_TWO_REGS xFP, xLR, 96 |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1014 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1015 | mov xSELF, x5 // Move thread pointer into SELF register. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1016 | REFRESH_MARKING_REGISTER |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1017 | |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1018 | INCREASE_FRAME 16 |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1019 | str xzr, [sp] // Store null for ArtMethod* slot |
| 1020 | // Branch to stub. |
| 1021 | bl .Losr_entry |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1022 | .cfi_remember_state |
| 1023 | DECREASE_FRAME 16 |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1024 | |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1025 | // Restore saved registers including value address and shorty address. |
| 1026 | RESTORE_TWO_REGS x19, x20, 16 |
| 1027 | RESTORE_TWO_REGS x21, x22, 32 |
| 1028 | RESTORE_TWO_REGS x23, x24, 48 |
| 1029 | RESTORE_TWO_REGS x25, x26, 64 |
| 1030 | RESTORE_TWO_REGS x27, x28, 80 |
| 1031 | RESTORE_TWO_REGS xFP, xLR, 96 |
| 1032 | RESTORE_TWO_REGS_DECREASE_FRAME x3, x4, SAVE_SIZE |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1033 | |
| 1034 | // Store result (w0/x0/s0/d0) appropriately, depending on resultType. |
| 1035 | ldrb w10, [x4] |
| 1036 | |
| 1037 | // Check the return type and store the correct register into the jvalue in memory. |
| 1038 | |
| 1039 | // Don't set anything for a void type. |
| 1040 | cmp w10, #'V' |
| 1041 | beq .Losr_exit |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1042 | // Is it a double? |
| 1043 | cmp w10, #'D' |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1044 | beq .Losr_return_double |
| 1045 | // Is it a float? |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1046 | cmp w10, #'F' |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1047 | beq .Losr_return_float |
| 1048 | // Just store x0. Doesn't matter if it is 64 or 32 bits. |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1049 | str x0, [x3] |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1050 | .Losr_exit: |
| 1051 | ret |
| 1052 | .Losr_return_double: |
| 1053 | str d0, [x3] |
| 1054 | ret |
| 1055 | .Losr_return_float: |
| 1056 | str s0, [x3] |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1057 | ret |
| 1058 | |
| 1059 | .Losr_entry: |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1060 | .cfi_restore_state // Reset unwind info so following code unwinds. |
| 1061 | .cfi_def_cfa_offset (SAVE_SIZE+16) // workaround for clang bug: 31975598 |
| 1062 | |
| 1063 | mov x9, sp // Save stack pointer. |
| 1064 | .cfi_def_cfa_register x9 |
| 1065 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1066 | // Update stack pointer for the callee |
| 1067 | sub sp, sp, x1 |
| 1068 | |
| 1069 | // Update link register slot expected by the callee. |
| 1070 | sub w1, w1, #8 |
| 1071 | str lr, [sp, x1] |
| 1072 | |
| 1073 | // Copy arguments into stack frame. |
| 1074 | // Use simple copy routine for now. |
| 1075 | // 4 bytes per slot. |
| 1076 | // X0 - source address |
| 1077 | // W1 - args length |
| 1078 | // SP - destination address. |
| 1079 | // W10 - temporary |
| 1080 | .Losr_loop_entry: |
Vladimir Marko | a26f416 | 2018-03-02 13:53:53 +0000 | [diff] [blame] | 1081 | cbz w1, .Losr_loop_exit |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1082 | sub w1, w1, #4 |
| 1083 | ldr w10, [x0, x1] |
| 1084 | str w10, [sp, x1] |
| 1085 | b .Losr_loop_entry |
| 1086 | |
| 1087 | .Losr_loop_exit: |
| 1088 | // Branch to the OSR entry point. |
| 1089 | br x2 |
| 1090 | |
| 1091 | END art_quick_osr_stub |
| 1092 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1093 | /* |
| 1094 | * On entry x0 is uintptr_t* gprs_ and x1 is uint64_t* fprs_ |
| 1095 | */ |
| 1096 | |
| 1097 | ENTRY art_quick_do_long_jump |
| 1098 | // Load FPRs |
| 1099 | ldp d0, d1, [x1], #16 |
| 1100 | ldp d2, d3, [x1], #16 |
| 1101 | ldp d4, d5, [x1], #16 |
| 1102 | ldp d6, d7, [x1], #16 |
| 1103 | ldp d8, d9, [x1], #16 |
| 1104 | ldp d10, d11, [x1], #16 |
| 1105 | ldp d12, d13, [x1], #16 |
| 1106 | ldp d14, d15, [x1], #16 |
| 1107 | ldp d16, d17, [x1], #16 |
| 1108 | ldp d18, d19, [x1], #16 |
| 1109 | ldp d20, d21, [x1], #16 |
| 1110 | ldp d22, d23, [x1], #16 |
| 1111 | ldp d24, d25, [x1], #16 |
| 1112 | ldp d26, d27, [x1], #16 |
| 1113 | ldp d28, d29, [x1], #16 |
| 1114 | ldp d30, d31, [x1] |
| 1115 | |
| 1116 | // Load GPRs |
| 1117 | // TODO: lots of those are smashed, could optimize. |
| 1118 | add x0, x0, #30*8 |
Andreas Gampe | 639bdd1 | 2015-06-03 11:22:45 -0700 | [diff] [blame] | 1119 | ldp x30, x1, [x0], #-16 // LR & SP |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1120 | ldp x28, x29, [x0], #-16 |
| 1121 | ldp x26, x27, [x0], #-16 |
| 1122 | ldp x24, x25, [x0], #-16 |
| 1123 | ldp x22, x23, [x0], #-16 |
| 1124 | ldp x20, x21, [x0], #-16 |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1125 | ldp x18, x19, [x0], #-16 // X18 & xSELF |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1126 | ldp x16, x17, [x0], #-16 |
| 1127 | ldp x14, x15, [x0], #-16 |
| 1128 | ldp x12, x13, [x0], #-16 |
| 1129 | ldp x10, x11, [x0], #-16 |
| 1130 | ldp x8, x9, [x0], #-16 |
| 1131 | ldp x6, x7, [x0], #-16 |
| 1132 | ldp x4, x5, [x0], #-16 |
| 1133 | ldp x2, x3, [x0], #-16 |
| 1134 | mov sp, x1 |
| 1135 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1136 | REFRESH_MARKING_REGISTER |
| 1137 | |
Andreas Gampe | 639bdd1 | 2015-06-03 11:22:45 -0700 | [diff] [blame] | 1138 | // Need to load PC, it's at the end (after the space for the unused XZR). Use x1. |
| 1139 | ldr x1, [x0, #33*8] |
| 1140 | // And the value of x0. |
| 1141 | ldr x0, [x0] |
| 1142 | |
| 1143 | br x1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1144 | END art_quick_do_long_jump |
| 1145 | |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1146 | /* |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1147 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. x0 holds the |
| 1148 | * possibly null object to lock. |
| 1149 | * |
| 1150 | * Derived from arm32 code. |
| 1151 | */ |
| 1152 | .extern artLockObjectFromCode |
| 1153 | ENTRY art_quick_lock_object |
| 1154 | cbz w0, .Lslow_lock |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1155 | add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1156 | .Lretry_lock: |
| 1157 | ldr w2, [xSELF, #THREAD_ID_OFFSET] // TODO: Can the thread ID really change during the loop? |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1158 | ldaxr w1, [x4] // acquire needed only in most common case |
| 1159 | and w3, w1, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1160 | cbnz w3, .Lnot_unlocked // already thin locked |
| 1161 | // unlocked case - x1: original lock word that's zero except for the read barrier bits. |
| 1162 | orr x2, x1, x2 // x2 holds thread id with count of 0 with preserved read barrier bits |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1163 | stxr w3, w2, [x4] |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1164 | cbnz w3, .Llock_stxr_fail // store failed, retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1165 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1166 | .Lnot_unlocked: // x1: original lock word |
| 1167 | lsr w3, w1, LOCK_WORD_STATE_SHIFT |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1168 | cbnz w3, .Lslow_lock // if either of the top two bits are set, go slow path |
| 1169 | eor w2, w1, w2 // lock_word.ThreadId() ^ self->ThreadId() |
| 1170 | uxth w2, w2 // zero top 16 bits |
| 1171 | cbnz w2, .Lslow_lock // lock word and self thread id's match -> recursive lock |
| 1172 | // else contention, go to slow path |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1173 | and w3, w1, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1174 | add w2, w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count in lock word placing in w2 to check overflow |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1175 | lsr w3, w2, #LOCK_WORD_GC_STATE_SHIFT // if the first gc state bit is set, we overflowed. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1176 | cbnz w3, .Lslow_lock // if we overflow the count go slow path |
| 1177 | add w2, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count for real |
| 1178 | stxr w3, w2, [x4] |
| 1179 | cbnz w3, .Llock_stxr_fail // store failed, retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1180 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1181 | .Llock_stxr_fail: |
| 1182 | b .Lretry_lock // retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1183 | .Lslow_lock: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1184 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case we block |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1185 | mov x1, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1186 | bl artLockObjectFromCode // (Object* obj, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1187 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1188 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1189 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1190 | END art_quick_lock_object |
| 1191 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1192 | ENTRY art_quick_lock_object_no_inline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1193 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case we block |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1194 | mov x1, xSELF // pass Thread::Current |
| 1195 | bl artLockObjectFromCode // (Object* obj, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1196 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1197 | REFRESH_MARKING_REGISTER |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1198 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1199 | END art_quick_lock_object_no_inline |
| 1200 | |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1201 | /* |
| 1202 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 1203 | * x0 holds the possibly null object to lock. |
| 1204 | * |
| 1205 | * Derived from arm32 code. |
| 1206 | */ |
| 1207 | .extern artUnlockObjectFromCode |
| 1208 | ENTRY art_quick_unlock_object |
| 1209 | cbz x0, .Lslow_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1210 | add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore |
| 1211 | .Lretry_unlock: |
| 1212 | #ifndef USE_READ_BARRIER |
| 1213 | ldr w1, [x4] |
| 1214 | #else |
| 1215 | ldxr w1, [x4] // Need to use atomic instructions for read barrier |
| 1216 | #endif |
| 1217 | lsr w2, w1, LOCK_WORD_STATE_SHIFT |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1218 | cbnz w2, .Lslow_unlock // if either of the top two bits are set, go slow path |
| 1219 | ldr w2, [xSELF, #THREAD_ID_OFFSET] |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1220 | and w3, w1, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1221 | eor w3, w3, w2 // lock_word.ThreadId() ^ self->ThreadId() |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1222 | uxth w3, w3 // zero top 16 bits |
| 1223 | cbnz w3, .Lslow_unlock // do lock word and self thread id's match? |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1224 | and w3, w1, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1225 | cmp w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1226 | bpl .Lrecursive_thin_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1227 | // transition to unlocked |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1228 | and w3, w1, #LOCK_WORD_GC_STATE_MASK_SHIFTED // w3: zero except for the preserved read barrier bits |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1229 | #ifndef USE_READ_BARRIER |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1230 | stlr w3, [x4] |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1231 | #else |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1232 | stlxr w2, w3, [x4] // Need to use atomic instructions for read barrier |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1233 | cbnz w2, .Lunlock_stxr_fail // store failed, retry |
| 1234 | #endif |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1235 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1236 | .Lrecursive_thin_unlock: // w1: original lock word |
| 1237 | sub w1, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // decrement count |
| 1238 | #ifndef USE_READ_BARRIER |
| 1239 | str w1, [x4] |
| 1240 | #else |
| 1241 | stxr w2, w1, [x4] // Need to use atomic instructions for read barrier |
| 1242 | cbnz w2, .Lunlock_stxr_fail // store failed, retry |
| 1243 | #endif |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1244 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1245 | .Lunlock_stxr_fail: |
Hans Boehm | 67eda38 | 2017-01-17 15:03:38 -0800 | [diff] [blame] | 1246 | b .Lretry_unlock // retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1247 | .Lslow_unlock: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1248 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case exception allocation triggers GC |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1249 | mov x1, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1250 | bl artUnlockObjectFromCode // (Object* obj, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1251 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1252 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1253 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1254 | END art_quick_unlock_object |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1255 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1256 | ENTRY art_quick_unlock_object_no_inline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1257 | 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] | 1258 | mov x1, xSELF // pass Thread::Current |
| 1259 | bl artUnlockObjectFromCode // (Object* obj, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1260 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1261 | REFRESH_MARKING_REGISTER |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1262 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1263 | END art_quick_unlock_object_no_inline |
| 1264 | |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1265 | /* |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1266 | * Entry from managed code that calls artInstanceOfFromCode and on failure calls |
| 1267 | * artThrowClassCastExceptionForObject. |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1268 | */ |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1269 | .extern artInstanceOfFromCode |
| 1270 | .extern artThrowClassCastExceptionForObject |
| 1271 | ENTRY art_quick_check_instance_of |
Vladimir Marko | 175e786 | 2018-03-27 09:03:13 +0000 | [diff] [blame] | 1272 | // Type check using the bit string passes null as the target class. In that case just throw. |
| 1273 | cbz x1, .Lthrow_class_cast_exception_for_bitstring_check |
| 1274 | |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1275 | // Store arguments and link register |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1276 | // Stack needs to be 16B aligned on calls. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1277 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 32 |
| 1278 | SAVE_REG xLR, 24 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1279 | |
| 1280 | // Call runtime code |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1281 | bl artInstanceOfFromCode |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1282 | |
Vladimir Marko | bf92b3f | 2018-01-17 18:11:30 +0000 | [diff] [blame] | 1283 | // Restore LR. |
| 1284 | RESTORE_REG xLR, 24 |
| 1285 | |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1286 | // Check for exception |
| 1287 | cbz x0, .Lthrow_class_cast_exception |
| 1288 | |
| 1289 | // Restore and return |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 1290 | .cfi_remember_state |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1291 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1292 | ret |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 1293 | .cfi_restore_state // Reset unwind info so following code unwinds. |
Vladimir Marko | 112aa10 | 2016-12-01 11:53:54 +0000 | [diff] [blame] | 1294 | .cfi_def_cfa_offset 32 // workaround for clang bug: 31975598 |
Andreas Gampe | 6b90d42 | 2015-06-26 19:49:24 -0700 | [diff] [blame] | 1295 | |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1296 | .Lthrow_class_cast_exception: |
| 1297 | // Restore |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1298 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1299 | |
Vladimir Marko | 175e786 | 2018-03-27 09:03:13 +0000 | [diff] [blame] | 1300 | .Lthrow_class_cast_exception_for_bitstring_check: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1301 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1302 | mov x2, xSELF // pass Thread::Current |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1303 | bl artThrowClassCastExceptionForObject // (Object*, Class*, Thread*) |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1304 | brk 0 // We should not return here... |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 1305 | END art_quick_check_instance_of |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1306 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1307 | // Restore xReg's value from [sp, #offset] if xReg is not the same as xExclude. |
| 1308 | .macro POP_REG_NE xReg, offset, xExclude |
| 1309 | .ifnc \xReg, \xExclude |
| 1310 | ldr \xReg, [sp, #\offset] // restore xReg |
| 1311 | .cfi_restore \xReg |
| 1312 | .endif |
| 1313 | .endm |
| 1314 | |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 1315 | // Restore xReg1's value from [sp, #offset] if xReg1 is not the same as xExclude. |
| 1316 | // Restore xReg2's value from [sp, #(offset + 8)] if xReg2 is not the same as xExclude. |
| 1317 | .macro POP_REGS_NE xReg1, xReg2, offset, xExclude |
| 1318 | .ifc \xReg1, \xExclude |
| 1319 | ldr \xReg2, [sp, #(\offset + 8)] // restore xReg2 |
| 1320 | .else |
| 1321 | .ifc \xReg2, \xExclude |
| 1322 | ldr \xReg1, [sp, #\offset] // restore xReg1 |
| 1323 | .else |
| 1324 | ldp \xReg1, \xReg2, [sp, #\offset] // restore xReg1 and xReg2 |
| 1325 | .endif |
| 1326 | .endif |
| 1327 | .cfi_restore \xReg1 |
| 1328 | .cfi_restore \xReg2 |
| 1329 | .endm |
| 1330 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1331 | /* |
| 1332 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1333 | * xDest, wDest and xObj are registers, offset is a defined literal such as |
| 1334 | * MIRROR_OBJECT_CLASS_OFFSET. Dest needs both x and w versions of the same register to handle |
| 1335 | * name mismatch between instructions. This macro uses the lower 32b of register when possible. |
| 1336 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1337 | */ |
Mathieu Chartier | 4b5f791 | 2016-07-21 14:59:04 -0700 | [diff] [blame] | 1338 | .macro READ_BARRIER xDest, wDest, xObj, xTemp, wTemp, offset, number |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1339 | #ifdef USE_READ_BARRIER |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1340 | # ifdef USE_BAKER_READ_BARRIER |
Mathieu Chartier | 4b5f791 | 2016-07-21 14:59:04 -0700 | [diff] [blame] | 1341 | ldr \wTemp, [\xObj, #MIRROR_OBJECT_LOCK_WORD_OFFSET] |
| 1342 | tbnz \wTemp, #LOCK_WORD_READ_BARRIER_STATE_SHIFT, .Lrb_slowpath\number |
| 1343 | // False dependency to avoid needing load/load fence. |
| 1344 | add \xObj, \xObj, \xTemp, lsr #32 |
| 1345 | ldr \wDest, [\xObj, #\offset] // Heap reference = 32b. This also zero-extends to \xDest. |
| 1346 | UNPOISON_HEAP_REF \wDest |
| 1347 | b .Lrb_exit\number |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1348 | # endif // USE_BAKER_READ_BARRIER |
Mathieu Chartier | 4b5f791 | 2016-07-21 14:59:04 -0700 | [diff] [blame] | 1349 | .Lrb_slowpath\number: |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1350 | // Store registers used in art_quick_aput_obj (x0-x4, LR), stack is 16B aligned. |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1351 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 48 |
| 1352 | SAVE_TWO_REGS x2, x3, 16 |
| 1353 | SAVE_TWO_REGS x4, xLR, 32 |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1354 | |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1355 | // mov x0, \xRef // pass ref in x0 (no-op for now since parameter ref is unused) |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1356 | .ifnc \xObj, x1 |
| 1357 | mov x1, \xObj // pass xObj |
| 1358 | .endif |
| 1359 | mov w2, #\offset // pass offset |
| 1360 | bl artReadBarrierSlow // artReadBarrierSlow(ref, xObj, offset) |
| 1361 | // No need to unpoison return value in w0, artReadBarrierSlow() would do the unpoisoning. |
| 1362 | .ifnc \wDest, w0 |
| 1363 | mov \wDest, w0 // save return value in wDest |
| 1364 | .endif |
| 1365 | |
| 1366 | // Conditionally restore saved registers |
| 1367 | POP_REG_NE x0, 0, \xDest |
| 1368 | POP_REG_NE x1, 8, \xDest |
| 1369 | POP_REG_NE x2, 16, \xDest |
| 1370 | POP_REG_NE x3, 24, \xDest |
| 1371 | POP_REG_NE x4, 32, \xDest |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1372 | RESTORE_REG xLR, 40 |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 1373 | DECREASE_FRAME 48 |
Mathieu Chartier | 4b5f791 | 2016-07-21 14:59:04 -0700 | [diff] [blame] | 1374 | .Lrb_exit\number: |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1375 | #else |
| 1376 | ldr \wDest, [\xObj, #\offset] // Heap reference = 32b. This also zero-extends to \xDest. |
| 1377 | UNPOISON_HEAP_REF \wDest |
| 1378 | #endif // USE_READ_BARRIER |
| 1379 | .endm |
| 1380 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1381 | #ifdef USE_READ_BARRIER |
| 1382 | .extern artReadBarrierSlow |
| 1383 | #endif |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1384 | ENTRY art_quick_aput_obj |
| 1385 | cbz x2, .Ldo_aput_null |
Mathieu Chartier | 4b5f791 | 2016-07-21 14:59:04 -0700 | [diff] [blame] | 1386 | READ_BARRIER x3, w3, x0, x3, w3, MIRROR_OBJECT_CLASS_OFFSET, 0 // Heap reference = 32b |
| 1387 | // This also zero-extends to x3 |
| 1388 | READ_BARRIER x3, w3, x3, x4, w4, MIRROR_CLASS_COMPONENT_TYPE_OFFSET, 1 // Heap reference = 32b |
| 1389 | // This also zero-extends to x3 |
| 1390 | READ_BARRIER x4, w4, x2, x4, w4, MIRROR_OBJECT_CLASS_OFFSET, 2 // Heap reference = 32b |
| 1391 | // This also zero-extends to x4 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1392 | cmp w3, w4 // value's type == array's component type - trivial assignability |
| 1393 | bne .Lcheck_assignability |
| 1394 | .Ldo_aput: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1395 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1396 | // "Compress" = do nothing |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1397 | POISON_HEAP_REF w2 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1398 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1399 | ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET] |
Mathieu Chartier | afdcbcb | 2017-04-26 16:43:35 -0700 | [diff] [blame] | 1400 | lsr x0, x0, #CARD_TABLE_CARD_SHIFT |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1401 | strb w3, [x3, x0] |
| 1402 | ret |
| 1403 | .Ldo_aput_null: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1404 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1405 | // "Compress" = do nothing |
| 1406 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1407 | ret |
| 1408 | .Lcheck_assignability: |
| 1409 | // Store arguments and link register |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1410 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 32 |
| 1411 | SAVE_TWO_REGS x2, xLR, 16 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1412 | |
| 1413 | // Call runtime code |
| 1414 | mov x0, x3 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended |
| 1415 | mov x1, x4 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended |
| 1416 | bl artIsAssignableFromCode |
| 1417 | |
| 1418 | // Check for exception |
| 1419 | cbz x0, .Lthrow_array_store_exception |
| 1420 | |
| 1421 | // Restore |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 1422 | .cfi_remember_state |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1423 | RESTORE_TWO_REGS x2, xLR, 16 |
| 1424 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1425 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1426 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1427 | // "Compress" = do nothing |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1428 | POISON_HEAP_REF w2 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1429 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1430 | ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET] |
Mathieu Chartier | afdcbcb | 2017-04-26 16:43:35 -0700 | [diff] [blame] | 1431 | lsr x0, x0, #CARD_TABLE_CARD_SHIFT |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1432 | strb w3, [x3, x0] |
| 1433 | ret |
Vladimir Marko | ae6ba1f | 2016-09-09 11:56:05 +0100 | [diff] [blame] | 1434 | .cfi_restore_state // Reset unwind info so following code unwinds. |
Vladimir Marko | 112aa10 | 2016-12-01 11:53:54 +0000 | [diff] [blame] | 1435 | .cfi_def_cfa_offset 32 // workaround for clang bug: 31975598 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1436 | .Lthrow_array_store_exception: |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 1437 | RESTORE_TWO_REGS x2, xLR, 16 |
| 1438 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1439 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1440 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME |
Vladimir Marko | 908eb22 | 2016-09-14 10:29:18 +0100 | [diff] [blame] | 1441 | mov x1, x2 // Pass value. |
| 1442 | mov x2, xSELF // Pass Thread::Current. |
| 1443 | bl artThrowArrayStoreException // (Object*, Object*, Thread*). |
| 1444 | brk 0 // Unreached. |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1445 | END art_quick_aput_obj |
| 1446 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1447 | // Macro to facilitate adding new allocation entrypoints. |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1448 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1449 | .extern \entrypoint |
| 1450 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1451 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1452 | mov x1, xSELF // pass Thread::Current |
| 1453 | bl \entrypoint // (uint32_t type_idx, Method* method, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1454 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1455 | REFRESH_MARKING_REGISTER |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1456 | \return |
| 1457 | END \name |
| 1458 | .endm |
| 1459 | |
| 1460 | // Macro to facilitate adding new allocation entrypoints. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1461 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
| 1462 | .extern \entrypoint |
| 1463 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1464 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1465 | mov x2, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1466 | bl \entrypoint // (uint32_t type_idx, Method* method, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1467 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1468 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1469 | \return |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1470 | END \name |
| 1471 | .endm |
| 1472 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1473 | // Macro to facilitate adding new allocation entrypoints. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1474 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
| 1475 | .extern \entrypoint |
| 1476 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1477 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1478 | mov x3, xSELF // pass Thread::Current |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1479 | bl \entrypoint |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1480 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1481 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1482 | \return |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1483 | END \name |
| 1484 | .endm |
| 1485 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1486 | // Macro to facilitate adding new allocation entrypoints. |
| 1487 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1488 | .extern \entrypoint |
| 1489 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1490 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1491 | mov x4, xSELF // pass Thread::Current |
| 1492 | bl \entrypoint // |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1493 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1494 | REFRESH_MARKING_REGISTER |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1495 | \return |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1496 | END \name |
| 1497 | .endm |
| 1498 | |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1499 | // Macros taking opportunity of code similarities for downcalls. |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1500 | .macro ONE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1501 | .extern \entrypoint |
| 1502 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1503 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1504 | mov x1, xSELF // pass Thread::Current |
| 1505 | bl \entrypoint // (uint32_t type_idx, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1506 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1507 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1508 | \return |
| 1509 | END \name |
| 1510 | .endm |
| 1511 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1512 | .macro TWO_ARG_REF_DOWNCALL name, entrypoint, return |
| 1513 | .extern \entrypoint |
| 1514 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1515 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1516 | mov x2, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1517 | bl \entrypoint |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1518 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1519 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1520 | \return |
| 1521 | END \name |
| 1522 | .endm |
| 1523 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1524 | .macro THREE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1525 | .extern \entrypoint |
| 1526 | ENTRY \name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1527 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1528 | mov x3, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1529 | bl \entrypoint |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1530 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1531 | REFRESH_MARKING_REGISTER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1532 | \return |
| 1533 | END \name |
| 1534 | .endm |
| 1535 | |
Orion Hodson | 18259d7 | 2018-04-12 11:18:23 +0100 | [diff] [blame^] | 1536 | /* |
| 1537 | * Macro for resolution and initialization of indexed DEX file |
| 1538 | * constants such as classes and strings. |
| 1539 | */ |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 1540 | .macro ONE_ARG_SAVE_EVERYTHING_DOWNCALL name, entrypoint, runtime_method_offset = RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 1541 | .extern \entrypoint |
| 1542 | ENTRY \name |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 1543 | SETUP_SAVE_EVERYTHING_FRAME \runtime_method_offset // save everything for stack crawl |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 1544 | mov x1, xSELF // pass Thread::Current |
| 1545 | bl \entrypoint // (int32_t index, Thread* self) |
| 1546 | cbz w0, 1f // If result is null, deliver the OOME. |
| 1547 | .cfi_remember_state |
| 1548 | RESTORE_SAVE_EVERYTHING_FRAME_KEEP_X0 |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1549 | REFRESH_MARKING_REGISTER |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 1550 | ret // return |
| 1551 | .cfi_restore_state |
| 1552 | .cfi_def_cfa_offset FRAME_SIZE_SAVE_EVERYTHING // workaround for clang bug: 31975598 |
| 1553 | 1: |
| 1554 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 1555 | END \name |
| 1556 | .endm |
| 1557 | |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 1558 | .macro ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT name, entrypoint |
| 1559 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL \name, \entrypoint, RUNTIME_SAVE_EVERYTHING_FOR_CLINIT_METHOD_OFFSET |
| 1560 | .endm |
| 1561 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1562 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1563 | cbz w0, 1f // result zero branch over |
| 1564 | ret // return |
| 1565 | 1: |
| 1566 | DELIVER_PENDING_EXCEPTION |
| 1567 | .endm |
| 1568 | |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1569 | /* |
Vladimir Marko | 3b37073 | 2014-10-09 18:34:28 +0100 | [diff] [blame] | 1570 | * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on |
| 1571 | * failure. |
| 1572 | */ |
| 1573 | TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1574 | |
| 1575 | /* |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1576 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 1577 | * initializer and deliver the exception on error. On success the static storage base is |
| 1578 | * returned. |
| 1579 | */ |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 1580 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT art_quick_initialize_static_storage, artInitializeStaticStorageFromCode |
| 1581 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL_FOR_CLINIT art_quick_initialize_type, artInitializeTypeFromCode |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 1582 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode |
Orion Hodson | 18259d7 | 2018-04-12 11:18:23 +0100 | [diff] [blame^] | 1583 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL art_quick_resolve_method_type, artResolveMethodTypeFromCode |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 1584 | ONE_ARG_SAVE_EVERYTHING_DOWNCALL art_quick_resolve_string, artResolveStringFromCode |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1585 | |
Roland Levillain | 809f5b1 | 2018-01-04 14:05:59 +0000 | [diff] [blame] | 1586 | // Note: Functions `art{Get,Set}<Kind>{Static,Instance}FromCompiledCode` are |
| 1587 | // defined with a macro in runtime/entrypoints/quick/quick_field_entrypoints.cc. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1588 | |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1589 | ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1590 | ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1591 | ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1592 | ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1593 | ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1594 | ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1595 | ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1596 | |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1597 | TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1598 | TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1599 | TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1600 | TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1601 | TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1602 | TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1603 | TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCompiledCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1604 | |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1605 | TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1606 | TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1607 | TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1608 | TWO_ARG_REF_DOWNCALL art_quick_set64_static, artSet64StaticFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1609 | TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1610 | |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 1611 | THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1612 | THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1613 | THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1614 | THREE_ARG_REF_DOWNCALL art_quick_set64_instance, artSet64InstanceFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1615 | THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCompiledCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1616 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1617 | // Generate the allocation entrypoints for each allocator. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1618 | GENERATE_ALLOC_ENTRYPOINTS_FOR_NON_TLAB_ALLOCATORS |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1619 | // Comment out allocators that have arm64 specific asm. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1620 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB) |
| 1621 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_region_tlab, RegionTLAB) |
| 1622 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_region_tlab, RegionTLAB) |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1623 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_region_tlab, RegionTLAB) |
Nicolas Geoffray | b048cb7 | 2017-01-23 22:50:24 +0000 | [diff] [blame] | 1624 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED8(_region_tlab, RegionTLAB) |
| 1625 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED16(_region_tlab, RegionTLAB) |
| 1626 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED32(_region_tlab, RegionTLAB) |
| 1627 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED64(_region_tlab, RegionTLAB) |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1628 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_BYTES(_region_tlab, RegionTLAB) |
| 1629 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_CHARS(_region_tlab, RegionTLAB) |
| 1630 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_STRING(_region_tlab, RegionTLAB) |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1631 | |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1632 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB) |
| 1633 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_tlab, TLAB) |
| 1634 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_tlab, TLAB) |
| 1635 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_tlab, TLAB) |
| 1636 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED8(_tlab, TLAB) |
| 1637 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED16(_tlab, TLAB) |
| 1638 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED32(_tlab, TLAB) |
| 1639 | // GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED64(_tlab, TLAB) |
| 1640 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_BYTES(_tlab, TLAB) |
| 1641 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_CHARS(_tlab, TLAB) |
| 1642 | GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_STRING(_tlab, TLAB) |
| 1643 | |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1644 | // If isInitialized=1 then the compiler assumes the object's class has already been initialized. |
| 1645 | // If isInitialized=0 the compiler can only assume it's been at least resolved. |
| 1646 | .macro ART_QUICK_ALLOC_OBJECT_ROSALLOC c_name, cxx_name, isInitialized |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1647 | ENTRY \c_name |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1648 | // Fast path rosalloc allocation. |
Nicolas Geoffray | 0d3998b | 2017-01-12 15:35:12 +0000 | [diff] [blame] | 1649 | // x0: type, xSELF(x19): Thread::Current |
| 1650 | // x1-x7: free. |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1651 | ldr x3, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET] // Check if the thread local |
| 1652 | // allocation stack has room. |
| 1653 | // ldp won't work due to large offset. |
| 1654 | ldr x4, [xSELF, #THREAD_LOCAL_ALLOC_STACK_END_OFFSET] |
| 1655 | cmp x3, x4 |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1656 | bhs .Lslow_path\c_name |
Nicolas Geoffray | 0d3998b | 2017-01-12 15:35:12 +0000 | [diff] [blame] | 1657 | ldr w3, [x0, #MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET] // Load the object size (x3) |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1658 | cmp x3, #ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE // Check if the size is for a thread |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 1659 | // local allocation. Also does the |
| 1660 | // finalizable and initialization |
| 1661 | // checks. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1662 | // When isInitialized == 0, then the class is potentially not yet initialized. |
| 1663 | // If the class is not yet initialized, the object size will be very large to force the branch |
| 1664 | // below to be taken. |
| 1665 | // |
| 1666 | // See InitializeClassVisitors in class-inl.h for more details. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1667 | bhs .Lslow_path\c_name |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1668 | // Compute the rosalloc bracket index |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 1669 | // from the size. Since the size is |
| 1670 | // already aligned we can combine the |
| 1671 | // two shifts together. |
| 1672 | add x4, xSELF, x3, lsr #(ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT - POINTER_SIZE_SHIFT) |
| 1673 | // Subtract pointer size since ther |
| 1674 | // are no runs for 0 byte allocations |
| 1675 | // and the size is already aligned. |
| 1676 | ldr x4, [x4, #(THREAD_ROSALLOC_RUNS_OFFSET - __SIZEOF_POINTER__)] |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1677 | // Load the free list head (x3). This |
| 1678 | // will be the return val. |
| 1679 | ldr x3, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)] |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1680 | cbz x3, .Lslow_path\c_name |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1681 | // "Point of no slow path". Won't go to the slow path from here on. OK to clobber x0 and x1. |
| 1682 | ldr x1, [x3, #ROSALLOC_SLOT_NEXT_OFFSET] // Load the next pointer of the head |
| 1683 | // and update the list head with the |
| 1684 | // next pointer. |
| 1685 | str x1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)] |
| 1686 | // Store the class pointer in the |
| 1687 | // header. This also overwrites the |
| 1688 | // next pointer. The offsets are |
| 1689 | // asserted to match. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1690 | |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1691 | #if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET |
| 1692 | #error "Class pointer needs to overwrite next pointer." |
| 1693 | #endif |
Nicolas Geoffray | 0d3998b | 2017-01-12 15:35:12 +0000 | [diff] [blame] | 1694 | POISON_HEAP_REF w0 |
| 1695 | str w0, [x3, #MIRROR_OBJECT_CLASS_OFFSET] |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1696 | // Push the new object onto the thread |
| 1697 | // local allocation stack and |
| 1698 | // increment the thread local |
| 1699 | // allocation stack top. |
| 1700 | ldr x1, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET] |
| 1701 | str w3, [x1], #COMPRESSED_REFERENCE_SIZE // (Increment x1 as a side effect.) |
| 1702 | str x1, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET] |
| 1703 | // Decrement the size of the free list |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1704 | |
| 1705 | // After this "STR" the object is published to the thread local allocation stack, |
| 1706 | // and it will be observable from a runtime internal (eg. Heap::VisitObjects) point of view. |
| 1707 | // It is not yet visible to the running (user) compiled code until after the return. |
| 1708 | // |
| 1709 | // To avoid the memory barrier prior to the "STR", a trick is employed, by differentiating |
| 1710 | // the state of the allocation stack slot. It can be a pointer to one of: |
| 1711 | // 0) Null entry, because the stack was bumped but the new pointer wasn't written yet. |
| 1712 | // (The stack initial state is "null" pointers). |
| 1713 | // 1) A partially valid object, with an invalid class pointer to the next free rosalloc slot. |
| 1714 | // 2) A fully valid object, with a valid class pointer pointing to a real class. |
| 1715 | // Other states are not allowed. |
| 1716 | // |
| 1717 | // An object that is invalid only temporarily, and will eventually become valid. |
| 1718 | // The internal runtime code simply checks if the object is not null or is partial and then |
| 1719 | // ignores it. |
| 1720 | // |
| 1721 | // (Note: The actual check is done by seeing if a non-null object has a class pointer pointing |
| 1722 | // to ClassClass, and that the ClassClass's class pointer is self-cyclic. A rosalloc free slot |
| 1723 | // "next" pointer is not-cyclic.) |
| 1724 | // |
| 1725 | // See also b/28790624 for a listing of CLs dealing with this race. |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1726 | ldr w1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)] |
| 1727 | sub x1, x1, #1 |
| 1728 | // TODO: consider combining this store |
| 1729 | // and the list head store above using |
| 1730 | // strd. |
| 1731 | str w1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)] |
Mathieu Chartier | 011dc2c | 2016-07-18 11:11:45 -0700 | [diff] [blame] | 1732 | |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1733 | mov x0, x3 // Set the return value and return. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1734 | .if \isInitialized == 0 |
| 1735 | // This barrier is only necessary when the allocation also requires |
| 1736 | // a class initialization check. |
| 1737 | // |
| 1738 | // If the class is already observably initialized, then new-instance allocations are protected |
| 1739 | // from publishing by the compiler which inserts its own StoreStore barrier. |
| 1740 | dmb ish |
| 1741 | // Use a "dmb ish" fence here because if there are later loads of statics (e.g. class size), |
| 1742 | // they should happen-after the implicit initialization check. |
| 1743 | // |
| 1744 | // TODO: Remove this dmb for class initialization checks (b/36692143) by introducing |
| 1745 | // a new observably-initialized class state. |
| 1746 | .endif |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1747 | ret |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1748 | .Lslow_path\c_name: |
Nicolas Geoffray | 0d3998b | 2017-01-12 15:35:12 +0000 | [diff] [blame] | 1749 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
| 1750 | mov x1, xSELF // pass Thread::Current |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1751 | bl \cxx_name |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1752 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1753 | REFRESH_MARKING_REGISTER |
Hiroshi Yamauchi | 6f6244a | 2015-10-22 12:08:12 -0700 | [diff] [blame] | 1754 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1755 | END \c_name |
| 1756 | .endm |
| 1757 | |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1758 | ART_QUICK_ALLOC_OBJECT_ROSALLOC art_quick_alloc_object_resolved_rosalloc, artAllocObjectFromCodeResolvedRosAlloc, /* isInitialized */ 0 |
| 1759 | ART_QUICK_ALLOC_OBJECT_ROSALLOC art_quick_alloc_object_initialized_rosalloc, artAllocObjectFromCodeInitializedRosAlloc, /* isInitialized */ 1 |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1760 | |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1761 | // If isInitialized=1 then the compiler assumes the object's class has already been initialized. |
| 1762 | // If isInitialized=0 the compiler can only assume it's been at least resolved. |
| 1763 | .macro ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED slowPathLabel isInitialized |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1764 | ldr x4, [xSELF, #THREAD_LOCAL_POS_OFFSET] |
| 1765 | ldr x5, [xSELF, #THREAD_LOCAL_END_OFFSET] |
| 1766 | ldr w7, [x0, #MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET] // Load the object size (x7). |
| 1767 | add x6, x4, x7 // Add object size to tlab pos. |
| 1768 | cmp x6, x5 // Check if it fits, overflow works |
| 1769 | // since the tlab pos and end are 32 |
| 1770 | // bit values. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1771 | |
| 1772 | // When isInitialized == 0, then the class is potentially not yet initialized. |
| 1773 | // If the class is not yet initialized, the object size will be very large to force the branch |
| 1774 | // below to be taken. |
| 1775 | // |
| 1776 | // See InitializeClassVisitors in class-inl.h for more details. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1777 | bhi \slowPathLabel |
| 1778 | str x6, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Store new thread_local_pos. |
| 1779 | ldr x5, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] // Increment thread_local_objects. |
| 1780 | add x5, x5, #1 |
| 1781 | str x5, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] |
| 1782 | POISON_HEAP_REF w0 |
| 1783 | str w0, [x4, #MIRROR_OBJECT_CLASS_OFFSET] // Store the class pointer. |
| 1784 | // Fence. This is "ish" not "ishst" so |
| 1785 | // that the code after this allocation |
| 1786 | // site will see the right values in |
| 1787 | // the fields of the class. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1788 | mov x0, x4 |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1789 | .if \isInitialized == 0 |
| 1790 | // This barrier is only necessary when the allocation also requires |
| 1791 | // a class initialization check. |
| 1792 | // |
| 1793 | // If the class is already observably initialized, then new-instance allocations are protected |
| 1794 | // from publishing by the compiler which inserts its own StoreStore barrier. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1795 | dmb ish |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1796 | // Use a "dmb ish" fence here because if there are later loads of statics (e.g. class size), |
| 1797 | // they should happen-after the implicit initialization check. |
| 1798 | // |
| 1799 | // TODO: Remove this dmb for class initialization checks (b/36692143) by introducing |
| 1800 | // a new observably-initialized class state. |
| 1801 | .endif |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1802 | ret |
| 1803 | .endm |
| 1804 | |
| 1805 | // The common code for art_quick_alloc_object_*region_tlab |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1806 | .macro GENERATE_ALLOC_OBJECT_RESOLVED_TLAB name, entrypoint, isInitialized |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1807 | ENTRY \name |
| 1808 | // Fast path region tlab allocation. |
| 1809 | // x0: type, xSELF(x19): Thread::Current |
| 1810 | // x1-x7: free. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1811 | ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED .Lslow_path\name, \isInitialized |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1812 | .Lslow_path\name: |
| 1813 | SETUP_SAVE_REFS_ONLY_FRAME // Save callee saves in case of GC. |
| 1814 | mov x1, xSELF // Pass Thread::Current. |
| 1815 | bl \entrypoint // (mirror::Class*, Thread*) |
| 1816 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1817 | REFRESH_MARKING_REGISTER |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1818 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1819 | END \name |
| 1820 | .endm |
| 1821 | |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1822 | GENERATE_ALLOC_OBJECT_RESOLVED_TLAB art_quick_alloc_object_resolved_region_tlab, artAllocObjectFromCodeResolvedRegionTLAB, /* isInitialized */ 0 |
| 1823 | GENERATE_ALLOC_OBJECT_RESOLVED_TLAB art_quick_alloc_object_initialized_region_tlab, artAllocObjectFromCodeInitializedRegionTLAB, /* isInitialized */ 1 |
| 1824 | GENERATE_ALLOC_OBJECT_RESOLVED_TLAB art_quick_alloc_object_resolved_tlab, artAllocObjectFromCodeResolvedTLAB, /* isInitialized */ 0 |
| 1825 | GENERATE_ALLOC_OBJECT_RESOLVED_TLAB art_quick_alloc_object_initialized_tlab, artAllocObjectFromCodeInitializedTLAB, /* isInitialized */ 1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1826 | |
Nicolas Geoffray | b048cb7 | 2017-01-23 22:50:24 +0000 | [diff] [blame] | 1827 | .macro ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED_WITH_SIZE slowPathLabel, xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1828 | and \xTemp1, \xTemp1, #OBJECT_ALIGNMENT_MASK_TOGGLED64 // Apply alignment mask |
Mathieu Chartier | 2ee98f2 | 2016-08-10 10:08:58 -0700 | [diff] [blame] | 1829 | // (addr + 7) & ~7. The mask must |
| 1830 | // be 64 bits to keep high bits in |
| 1831 | // case of overflow. |
| 1832 | // Negative sized arrays are handled here since xCount holds a zero extended 32 bit value. |
| 1833 | // Negative ints become large 64 bit unsigned ints which will always be larger than max signed |
| 1834 | // 32 bit int. Since the max shift for arrays is 3, it can not become a negative 64 bit int. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1835 | cmp \xTemp1, #MIN_LARGE_OBJECT_THRESHOLD // Possibly a large object, go slow |
| 1836 | bhs \slowPathLabel // path. |
| 1837 | |
| 1838 | ldr \xTemp0, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Check tlab for space, note that |
| 1839 | // we use (end - begin) to handle |
| 1840 | // negative size arrays. It is |
| 1841 | // assumed that a negative size will |
| 1842 | // always be greater unsigned than |
| 1843 | // region size. |
| 1844 | ldr \xTemp2, [xSELF, #THREAD_LOCAL_END_OFFSET] |
| 1845 | sub \xTemp2, \xTemp2, \xTemp0 |
| 1846 | cmp \xTemp1, \xTemp2 |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1847 | |
| 1848 | // The array class is always initialized here. Unlike new-instance, |
| 1849 | // this does not act as a double test. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1850 | bhi \slowPathLabel |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1851 | // "Point of no slow path". Won't go to the slow path from here on. OK to clobber x0 and x1. |
| 1852 | // Move old thread_local_pos to x0 |
| 1853 | // for the return value. |
| 1854 | mov x0, \xTemp0 |
| 1855 | add \xTemp0, \xTemp0, \xTemp1 |
| 1856 | str \xTemp0, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Store new thread_local_pos. |
| 1857 | ldr \xTemp0, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] // Increment thread_local_objects. |
| 1858 | add \xTemp0, \xTemp0, #1 |
| 1859 | str \xTemp0, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] |
| 1860 | POISON_HEAP_REF \wClass |
| 1861 | str \wClass, [x0, #MIRROR_OBJECT_CLASS_OFFSET] // Store the class pointer. |
| 1862 | str \wCount, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] // Store the array length. |
| 1863 | // Fence. |
Igor Murashkin | 2f470ed | 2017-05-18 15:50:59 -0700 | [diff] [blame] | 1864 | // new-array is special. The class is loaded and immediately goes to the Initialized state |
| 1865 | // before it is published. Therefore the only fence needed is for the publication of the object. |
| 1866 | // See ClassLinker::CreateArrayClass() for more details. |
| 1867 | |
| 1868 | // For publication of the new array, we don't need a 'dmb ishst' here. |
| 1869 | // The compiler generates 'dmb ishst' for all new-array insts. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1870 | ret |
| 1871 | .endm |
| 1872 | |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1873 | .macro GENERATE_ALLOC_ARRAY_TLAB name, entrypoint, size_setup |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1874 | ENTRY \name |
| 1875 | // Fast path array allocation for region tlab allocation. |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 1876 | // x0: mirror::Class* type |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1877 | // x1: int32_t component_count |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 1878 | // x2-x7: free. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1879 | mov x3, x0 |
Nicolas Geoffray | b048cb7 | 2017-01-23 22:50:24 +0000 | [diff] [blame] | 1880 | \size_setup x3, w3, x1, w1, x4, w4, x5, w5, x6, w6 |
| 1881 | ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED_WITH_SIZE .Lslow_path\name, x3, w3, x1, w1, x4, w4, x5, w5, x6, w6 |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1882 | .Lslow_path\name: |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 1883 | // x0: mirror::Class* klass |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1884 | // x1: int32_t component_count |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 1885 | // x2: Thread* self |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1886 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 1887 | mov x2, xSELF // pass Thread::Current |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1888 | bl \entrypoint |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1889 | RESTORE_SAVE_REFS_ONLY_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1890 | REFRESH_MARKING_REGISTER |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 1891 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1892 | END \name |
| 1893 | .endm |
| 1894 | |
Nicolas Geoffray | b048cb7 | 2017-01-23 22:50:24 +0000 | [diff] [blame] | 1895 | .macro COMPUTE_ARRAY_SIZE_UNKNOWN xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
| 1896 | // Array classes are never finalizable or uninitialized, no need to check. |
| 1897 | ldr \wTemp0, [\xClass, #MIRROR_CLASS_COMPONENT_TYPE_OFFSET] // Load component type |
| 1898 | UNPOISON_HEAP_REF \wTemp0 |
| 1899 | ldr \wTemp0, [\xTemp0, #MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET] |
| 1900 | lsr \xTemp0, \xTemp0, #PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT // Component size shift is in high 16 |
| 1901 | // bits. |
| 1902 | // xCount is holding a 32 bit value, |
| 1903 | // it can not overflow. |
| 1904 | lsl \xTemp1, \xCount, \xTemp0 // Calculate data size |
| 1905 | // Add array data offset and alignment. |
| 1906 | add \xTemp1, \xTemp1, #(MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1907 | #if MIRROR_LONG_ARRAY_DATA_OFFSET != MIRROR_INT_ARRAY_DATA_OFFSET + 4 |
| 1908 | #error Long array data offset must be 4 greater than int array data offset. |
| 1909 | #endif |
| 1910 | |
| 1911 | add \xTemp0, \xTemp0, #1 // Add 4 to the length only if the |
| 1912 | // component size shift is 3 |
| 1913 | // (for 64 bit alignment). |
| 1914 | and \xTemp0, \xTemp0, #4 |
| 1915 | add \xTemp1, \xTemp1, \xTemp0 |
| 1916 | .endm |
| 1917 | |
| 1918 | .macro COMPUTE_ARRAY_SIZE_8 xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
| 1919 | // Add array data offset and alignment. |
| 1920 | add \xTemp1, \xCount, #(MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1921 | .endm |
| 1922 | |
| 1923 | .macro COMPUTE_ARRAY_SIZE_16 xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
| 1924 | lsl \xTemp1, \xCount, #1 |
| 1925 | // Add array data offset and alignment. |
| 1926 | add \xTemp1, \xTemp1, #(MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1927 | .endm |
| 1928 | |
| 1929 | .macro COMPUTE_ARRAY_SIZE_32 xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
| 1930 | lsl \xTemp1, \xCount, #2 |
| 1931 | // Add array data offset and alignment. |
| 1932 | add \xTemp1, \xTemp1, #(MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
| 1933 | .endm |
| 1934 | |
| 1935 | .macro COMPUTE_ARRAY_SIZE_64 xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2 |
| 1936 | lsl \xTemp1, \xCount, #3 |
| 1937 | // Add array data offset and alignment. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1938 | add \xTemp1, \xTemp1, #(MIRROR_WIDE_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK) |
Nicolas Geoffray | b048cb7 | 2017-01-23 22:50:24 +0000 | [diff] [blame] | 1939 | .endm |
| 1940 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1941 | // TODO(ngeoffray): art_quick_alloc_array_resolved_region_tlab is not used for arm64, remove |
| 1942 | // the entrypoint once all backends have been updated to use the size variants. |
Nicolas Geoffray | d095844 | 2017-01-30 14:57:16 +0000 | [diff] [blame] | 1943 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_UNKNOWN |
| 1944 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved8_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_8 |
| 1945 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved16_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_16 |
| 1946 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved32_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_32 |
| 1947 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved64_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, COMPUTE_ARRAY_SIZE_64 |
| 1948 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_UNKNOWN |
| 1949 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved8_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_8 |
| 1950 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved16_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_16 |
| 1951 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved32_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_32 |
| 1952 | GENERATE_ALLOC_ARRAY_TLAB art_quick_alloc_array_resolved64_tlab, artAllocArrayFromCodeResolvedTLAB, COMPUTE_ARRAY_SIZE_64 |
Hiroshi Yamauchi | 10d4c08 | 2016-02-24 12:51:18 -0800 | [diff] [blame] | 1953 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1954 | /* |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 1955 | * Called by managed code when the thread has been asked to suspend. |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1956 | */ |
| 1957 | .extern artTestSuspendFromCode |
| 1958 | ENTRY art_quick_test_suspend |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 1959 | SETUP_SAVE_EVERYTHING_FRAME RUNTIME_SAVE_EVERYTHING_FOR_SUSPEND_CHECK_METHOD_OFFSET // save callee saves for stack crawl |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1960 | mov x0, xSELF |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1961 | bl artTestSuspendFromCode // (Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1962 | RESTORE_SAVE_EVERYTHING_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1963 | REFRESH_MARKING_REGISTER |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1964 | ret |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1965 | END art_quick_test_suspend |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1966 | |
Stuart Monteith | d5c78f4 | 2014-06-11 16:44:46 +0100 | [diff] [blame] | 1967 | ENTRY art_quick_implicit_suspend |
| 1968 | mov x0, xSELF |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1969 | SETUP_SAVE_REFS_ONLY_FRAME // save callee saves for stack crawl |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1970 | bl artTestSuspendFromCode // (Thread*) |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1971 | RESTORE_SAVE_REFS_ONLY_FRAME |
| 1972 | REFRESH_MARKING_REGISTER |
| 1973 | ret |
Stuart Monteith | d5c78f4 | 2014-06-11 16:44:46 +0100 | [diff] [blame] | 1974 | END art_quick_implicit_suspend |
| 1975 | |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1976 | /* |
| 1977 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
| 1978 | * x0 holds the proxy method and x1 holds the receiver; The frame size of the invoked proxy |
| 1979 | * method agrees with a ref and args callee save frame. |
| 1980 | */ |
| 1981 | .extern artQuickProxyInvokeHandler |
| 1982 | ENTRY art_quick_proxy_invoke_handler |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1983 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0 |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1984 | mov x2, xSELF // pass Thread::Current |
| 1985 | mov x3, sp // pass SP |
| 1986 | bl artQuickProxyInvokeHandler // (Method* proxy method, receiver, Thread*, SP) |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1987 | ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET] |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1988 | cbnz x2, .Lexception_in_proxy // success if no exception is pending |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1989 | RESTORE_SAVE_REFS_AND_ARGS_FRAME // Restore frame |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 1990 | REFRESH_MARKING_REGISTER |
Andreas Gampe | d1e9167 | 2014-06-02 22:50:05 -0700 | [diff] [blame] | 1991 | fmov d0, x0 // Store result in d0 in case it was float or double |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1992 | ret // return on success |
| 1993 | .Lexception_in_proxy: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1994 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1995 | DELIVER_PENDING_EXCEPTION |
| 1996 | END art_quick_proxy_invoke_handler |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1997 | |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 1998 | /* |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 1999 | * Called to resolve an imt conflict. |
| 2000 | * x0 is the conflict ArtMethod. |
| 2001 | * xIP1 is a hidden argument that holds the target interface method's dex method index. |
| 2002 | * |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2003 | * Note that this stub writes to xIP0, xIP1, x13-x15, and x0. |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 2004 | */ |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2005 | .extern artLookupResolvedMethod |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 2006 | ENTRY art_quick_imt_conflict_trampoline |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 2007 | ldr xIP0, [sp, #0] // Load referrer |
Vladimir Marko | 5122e6b | 2017-08-17 16:10:09 +0100 | [diff] [blame] | 2008 | // Load the declaring class (without read barrier) and access flags (for obsolete method check). |
| 2009 | // The obsolete flag is set with suspended threads, so we do not need an acquire operation here. |
| 2010 | #if ART_METHOD_ACCESS_FLAGS_OFFSET != ART_METHOD_DECLARING_CLASS_OFFSET + 4 |
| 2011 | #error "Expecting declaring class and access flags to be consecutive for LDP." |
| 2012 | #endif |
| 2013 | ldp wIP0, w15, [xIP0, #ART_METHOD_DECLARING_CLASS_OFFSET] |
| 2014 | // If the method is obsolete, just go through the dex cache miss slow path. |
| 2015 | tbnz x15, #ACC_OBSOLETE_METHOD_SHIFT, .Limt_conflict_trampoline_dex_cache_miss |
| 2016 | ldr wIP0, [xIP0, #MIRROR_CLASS_DEX_CACHE_OFFSET] // Load the DexCache (without read barrier). |
| 2017 | UNPOISON_HEAP_REF wIP0 |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2018 | ubfx x15, xIP1, #0, #METHOD_DEX_CACHE_HASH_BITS // Calculate DexCache method slot index. |
Vladimir Marko | 5122e6b | 2017-08-17 16:10:09 +0100 | [diff] [blame] | 2019 | ldr xIP0, [xIP0, #MIRROR_DEX_CACHE_RESOLVED_METHODS_OFFSET] // Load the resolved methods. |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2020 | add xIP0, xIP0, x15, lsl #(POINTER_SIZE_SHIFT + 1) // Load DexCache method slot address. |
| 2021 | |
| 2022 | // Relaxed atomic load x14:x15 from the dex cache slot. |
| 2023 | .Limt_conflict_trampoline_retry_load: |
| 2024 | ldxp x14, x15, [xIP0] |
| 2025 | stxp w13, x14, x15, [xIP0] |
| 2026 | cbnz w13, .Limt_conflict_trampoline_retry_load |
| 2027 | |
| 2028 | cmp x15, xIP1 // Compare method index to see if we had a DexCache method hit. |
| 2029 | bne .Limt_conflict_trampoline_dex_cache_miss |
| 2030 | .Limt_conflict_trampoline_have_interface_method: |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 2031 | ldr xIP1, [x0, #ART_METHOD_JNI_OFFSET_64] // Load ImtConflictTable |
| 2032 | ldr x0, [xIP1] // Load first entry in ImtConflictTable. |
| 2033 | .Limt_table_iterate: |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2034 | cmp x0, x14 |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 2035 | // Branch if found. Benchmarks have shown doing a branch here is better. |
| 2036 | beq .Limt_table_found |
| 2037 | // If the entry is null, the interface method is not in the ImtConflictTable. |
| 2038 | cbz x0, .Lconflict_trampoline |
| 2039 | // Iterate over the entries of the ImtConflictTable. |
| 2040 | ldr x0, [xIP1, #(2 * __SIZEOF_POINTER__)]! |
| 2041 | b .Limt_table_iterate |
| 2042 | .Limt_table_found: |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 2043 | // We successfully hit an entry in the table. Load the target method |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 2044 | // and jump to it. |
| 2045 | ldr x0, [xIP1, #__SIZEOF_POINTER__] |
| 2046 | ldr xIP0, [x0, #ART_METHOD_QUICK_CODE_OFFSET_64] |
| 2047 | br xIP0 |
| 2048 | .Lconflict_trampoline: |
| 2049 | // Call the runtime stub to populate the ImtConflictTable and jump to the |
| 2050 | // resolved method. |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2051 | mov x0, x14 // Load interface method |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 2052 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline |
Vladimir Marko | 07bfbac | 2017-07-06 14:55:02 +0100 | [diff] [blame] | 2053 | .Limt_conflict_trampoline_dex_cache_miss: |
| 2054 | // We're not creating a proper runtime method frame here, |
| 2055 | // artLookupResolvedMethod() is not allowed to walk the stack. |
| 2056 | |
| 2057 | // Save GPR args and return address, allocate space for FPR args, align stack. |
| 2058 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, (8 * 8 + 8 * 8 + 8 + 8) |
| 2059 | SAVE_TWO_REGS x2, x3, 16 |
| 2060 | SAVE_TWO_REGS x4, x5, 32 |
| 2061 | SAVE_TWO_REGS x6, x7, 48 |
| 2062 | SAVE_REG xLR, (8 * 8 + 8 * 8 + 8) |
| 2063 | |
| 2064 | // Save FPR args. |
| 2065 | stp d0, d1, [sp, #64] |
| 2066 | stp d2, d3, [sp, #80] |
| 2067 | stp d4, d5, [sp, #96] |
| 2068 | stp d6, d7, [sp, #112] |
| 2069 | |
| 2070 | mov x0, xIP1 // Pass method index. |
| 2071 | ldr x1, [sp, #(8 * 8 + 8 * 8 + 8 + 8)] // Pass referrer. |
| 2072 | bl artLookupResolvedMethod // (uint32_t method_index, ArtMethod* referrer) |
| 2073 | mov x14, x0 // Move the interface method to x14 where the loop above expects it. |
| 2074 | |
| 2075 | // Restore FPR args. |
| 2076 | ldp d0, d1, [sp, #64] |
| 2077 | ldp d2, d3, [sp, #80] |
| 2078 | ldp d4, d5, [sp, #96] |
| 2079 | ldp d6, d7, [sp, #112] |
| 2080 | |
| 2081 | // Restore GPR args and return address. |
| 2082 | RESTORE_REG xLR, (8 * 8 + 8 * 8 + 8) |
| 2083 | RESTORE_TWO_REGS x2, x3, 16 |
| 2084 | RESTORE_TWO_REGS x4, x5, 32 |
| 2085 | RESTORE_TWO_REGS x6, x7, 48 |
| 2086 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, (8 * 8 + 8 * 8 + 8 + 8) |
| 2087 | |
| 2088 | // If the method wasn't resolved, skip the lookup and go to artInvokeInterfaceTrampoline(). |
| 2089 | cbz x14, .Lconflict_trampoline |
| 2090 | b .Limt_conflict_trampoline_have_interface_method |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 2091 | END art_quick_imt_conflict_trampoline |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2092 | |
| 2093 | ENTRY art_quick_resolution_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2094 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2095 | mov x2, xSELF |
| 2096 | mov x3, sp |
| 2097 | bl artQuickResolutionTrampoline // (called, receiver, Thread*, SP) |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 2098 | cbz x0, 1f |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2099 | mov xIP0, x0 // Remember returned code pointer in xIP0. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 2100 | ldr x0, [sp, #0] // artQuickResolutionTrampoline puts called method in *SP. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2101 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2102 | REFRESH_MARKING_REGISTER |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2103 | br xIP0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2104 | 1: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2105 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2106 | DELIVER_PENDING_EXCEPTION |
| 2107 | END art_quick_resolution_trampoline |
| 2108 | |
| 2109 | /* |
| 2110 | * Generic JNI frame layout: |
| 2111 | * |
| 2112 | * #-------------------# |
| 2113 | * | | |
| 2114 | * | caller method... | |
| 2115 | * #-------------------# <--- SP on entry |
| 2116 | * | Return X30/LR | |
| 2117 | * | X29/FP | callee save |
| 2118 | * | X28 | callee save |
| 2119 | * | X27 | callee save |
| 2120 | * | X26 | callee save |
| 2121 | * | X25 | callee save |
| 2122 | * | X24 | callee save |
| 2123 | * | X23 | callee save |
| 2124 | * | X22 | callee save |
| 2125 | * | X21 | callee save |
| 2126 | * | X20 | callee save |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 2127 | * | X19 | callee save |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2128 | * | X7 | arg7 |
| 2129 | * | X6 | arg6 |
| 2130 | * | X5 | arg5 |
| 2131 | * | X4 | arg4 |
| 2132 | * | X3 | arg3 |
| 2133 | * | X2 | arg2 |
| 2134 | * | X1 | arg1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2135 | * | D7 | float arg 8 |
| 2136 | * | D6 | float arg 7 |
| 2137 | * | D5 | float arg 6 |
| 2138 | * | D4 | float arg 5 |
| 2139 | * | D3 | float arg 4 |
| 2140 | * | D2 | float arg 3 |
| 2141 | * | D1 | float arg 2 |
| 2142 | * | D0 | float arg 1 |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 2143 | * | Method* | <- X0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2144 | * #-------------------# |
| 2145 | * | local ref cookie | // 4B |
Mathieu Chartier | 421c537 | 2014-05-14 14:11:40 -0700 | [diff] [blame] | 2146 | * | handle scope size | // 4B |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2147 | * #-------------------# |
| 2148 | * | JNI Call Stack | |
| 2149 | * #-------------------# <--- SP on native call |
| 2150 | * | | |
| 2151 | * | Stack for Regs | The trampoline assembly will pop these values |
| 2152 | * | | into registers for native call |
| 2153 | * #-------------------# |
| 2154 | * | Native code ptr | |
| 2155 | * #-------------------# |
| 2156 | * | Free scratch | |
| 2157 | * #-------------------# |
| 2158 | * | Ptr to (1) | <--- SP |
| 2159 | * #-------------------# |
| 2160 | */ |
| 2161 | /* |
| 2162 | * Called to do a generic JNI down-call |
| 2163 | */ |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 2164 | ENTRY art_quick_generic_jni_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2165 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2166 | |
| 2167 | // Save SP , so we can have static CFI info. |
| 2168 | mov x28, sp |
| 2169 | .cfi_def_cfa_register x28 |
| 2170 | |
| 2171 | // This looks the same, but is different: this will be updated to point to the bottom |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 2172 | // of the frame when the handle scope is inserted. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2173 | mov xFP, sp |
| 2174 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2175 | mov xIP0, #5120 |
| 2176 | sub sp, sp, xIP0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2177 | |
| 2178 | // prepare for artQuickGenericJniTrampoline call |
| 2179 | // (Thread*, SP) |
| 2180 | // x0 x1 <= C calling convention |
| 2181 | // xSELF xFP <= where they are |
| 2182 | |
| 2183 | mov x0, xSELF // Thread* |
| 2184 | mov x1, xFP |
| 2185 | bl artQuickGenericJniTrampoline // (Thread*, sp) |
| 2186 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2187 | // The C call will have registered the complete save-frame on success. |
| 2188 | // The result of the call is: |
| 2189 | // x0: pointer to native code, 0 on error. |
| 2190 | // x1: pointer to the bottom of the used area of the alloca, can restore stack till there. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2191 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2192 | // Check for error = 0. |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2193 | cbz x0, .Lexception_in_native |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2194 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2195 | // Release part of the alloca. |
| 2196 | mov sp, x1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2197 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2198 | // Save the code pointer |
| 2199 | mov xIP0, x0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2200 | |
| 2201 | // Load parameters from frame into registers. |
| 2202 | // TODO Check with artQuickGenericJniTrampoline. |
| 2203 | // Also, check again APPCS64 - the stack arguments are interleaved. |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2204 | ldp x0, x1, [sp] |
| 2205 | ldp x2, x3, [sp, #16] |
| 2206 | ldp x4, x5, [sp, #32] |
| 2207 | ldp x6, x7, [sp, #48] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2208 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2209 | ldp d0, d1, [sp, #64] |
| 2210 | ldp d2, d3, [sp, #80] |
| 2211 | ldp d4, d5, [sp, #96] |
| 2212 | ldp d6, d7, [sp, #112] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2213 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2214 | add sp, sp, #128 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2215 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2216 | blr xIP0 // native call. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2217 | |
| 2218 | // result sign extension is handled in C code |
| 2219 | // prepare for artQuickGenericJniEndTrampoline call |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2220 | // (Thread*, result, result_f) |
| 2221 | // x0 x1 x2 <= C calling convention |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 2222 | mov x1, x0 // Result (from saved). |
| 2223 | mov x0, xSELF // Thread register. |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 2224 | fmov x2, d0 // d0 will contain floating point result, but needs to go into x2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2225 | |
| 2226 | bl artQuickGenericJniEndTrampoline |
| 2227 | |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2228 | // Pending exceptions possible. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 2229 | ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET] |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2230 | cbnz x2, .Lexception_in_native |
| 2231 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2232 | // Tear down the alloca. |
| 2233 | mov sp, x28 |
| 2234 | .cfi_def_cfa_register sp |
| 2235 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2236 | // Tear down the callee-save frame. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2237 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2238 | REFRESH_MARKING_REGISTER |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2239 | |
| 2240 | // store into fpr, for when it's a fpr return... |
| 2241 | fmov d0, x0 |
| 2242 | ret |
| 2243 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2244 | .Lexception_in_native: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2245 | // Move to x1 then sp to please assembler. |
| 2246 | ldr x1, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Vladimir Marko | 2196c65 | 2017-11-30 16:16:07 +0000 | [diff] [blame] | 2247 | add sp, x1, #-1 // Remove the GenericJNI tag. |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 2248 | .cfi_def_cfa_register sp |
| 2249 | # This will create a new save-all frame, required by the runtime. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2250 | DELIVER_PENDING_EXCEPTION |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2251 | END art_quick_generic_jni_trampoline |
| 2252 | |
| 2253 | /* |
| 2254 | * Called to bridge from the quick to interpreter ABI. On entry the arguments match those |
| 2255 | * of a quick call: |
| 2256 | * x0 = method being called/to bridge to. |
| 2257 | * x1..x7, d0..d7 = arguments to that method. |
| 2258 | */ |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 2259 | ENTRY art_quick_to_interpreter_bridge |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2260 | SETUP_SAVE_REFS_AND_ARGS_FRAME // Set up frame and save arguments. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2261 | |
| 2262 | // x0 will contain mirror::ArtMethod* method. |
| 2263 | mov x1, xSELF // How to get Thread::Current() ??? |
| 2264 | mov x2, sp |
| 2265 | |
| 2266 | // uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, |
| 2267 | // mirror::ArtMethod** sp) |
| 2268 | bl artQuickToInterpreterBridge |
| 2269 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2270 | RESTORE_SAVE_REFS_AND_ARGS_FRAME // TODO: no need to restore arguments in this case. |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2271 | REFRESH_MARKING_REGISTER |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 2272 | |
| 2273 | fmov d0, x0 |
| 2274 | |
| 2275 | RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 2276 | END art_quick_to_interpreter_bridge |
| 2277 | |
Alex Light | db01a09 | 2017-04-03 15:39:55 -0700 | [diff] [blame] | 2278 | /* |
| 2279 | * Called to attempt to execute an obsolete method. |
| 2280 | */ |
| 2281 | ONE_ARG_RUNTIME_EXCEPTION art_invoke_obsolete_method_stub, artInvokeObsoleteMethod |
| 2282 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2283 | |
| 2284 | // |
| 2285 | // Instrumentation-related stubs |
| 2286 | // |
| 2287 | .extern artInstrumentationMethodEntryFromCode |
| 2288 | ENTRY art_quick_instrumentation_entry |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2289 | SETUP_SAVE_REFS_AND_ARGS_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2290 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2291 | mov x20, x0 // Preserve method reference in a callee-save. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2292 | |
| 2293 | mov x2, xSELF |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 2294 | mov x3, sp // Pass SP |
| 2295 | bl artInstrumentationMethodEntryFromCode // (Method*, Object*, Thread*, SP) |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2296 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2297 | mov xIP0, x0 // x0 = result of call. |
| 2298 | mov x0, x20 // Reload method reference. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2299 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 2300 | RESTORE_SAVE_REFS_AND_ARGS_FRAME // Note: will restore xSELF |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2301 | REFRESH_MARKING_REGISTER |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 2302 | cbz xIP0, 1f // Deliver the pending exception if method is null. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2303 | adr xLR, art_quick_instrumentation_exit |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2304 | br xIP0 // Tail-call method with lr set to art_quick_instrumentation_exit. |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 2305 | |
| 2306 | 1: |
| 2307 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2308 | END art_quick_instrumentation_entry |
| 2309 | |
| 2310 | .extern artInstrumentationMethodExitFromCode |
| 2311 | ENTRY art_quick_instrumentation_exit |
| 2312 | mov xLR, #0 // Clobber LR for later checks. |
Mingyao Yang | 2ee1790 | 2017-08-30 11:37:08 -0700 | [diff] [blame] | 2313 | SETUP_SAVE_EVERYTHING_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2314 | |
Mingyao Yang | 2ee1790 | 2017-08-30 11:37:08 -0700 | [diff] [blame] | 2315 | add x3, sp, #8 // Pass floating-point result pointer, in kSaveEverything frame. |
| 2316 | add x2, sp, #264 // Pass integer result pointer, in kSaveEverything frame. |
| 2317 | mov x1, sp // Pass SP. |
Sebastien Hertz | 70f8d4b | 2014-06-19 11:51:41 +0200 | [diff] [blame] | 2318 | mov x0, xSELF // Pass Thread. |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 2319 | bl artInstrumentationMethodExitFromCode // (Thread*, SP, gpr_res*, fpr_res*) |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2320 | |
Mingyao Yang | 2ee1790 | 2017-08-30 11:37:08 -0700 | [diff] [blame] | 2321 | cbz x0, .Ldo_deliver_instrumentation_exception |
| 2322 | // Handle error |
| 2323 | cbnz x1, .Ldeoptimize |
| 2324 | // Normal return. |
| 2325 | str x0, [sp, #FRAME_SIZE_SAVE_EVERYTHING - 8] |
| 2326 | // Set return pc. |
| 2327 | RESTORE_SAVE_EVERYTHING_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2328 | REFRESH_MARKING_REGISTER |
Mingyao Yang | 2ee1790 | 2017-08-30 11:37:08 -0700 | [diff] [blame] | 2329 | br lr |
| 2330 | .Ldo_deliver_instrumentation_exception: |
| 2331 | DELIVER_PENDING_EXCEPTION_FRAME_READY |
| 2332 | .Ldeoptimize: |
| 2333 | str x1, [sp, #FRAME_SIZE_SAVE_EVERYTHING - 8] |
| 2334 | // Set return pc. |
| 2335 | RESTORE_SAVE_EVERYTHING_FRAME |
| 2336 | // Jump to art_quick_deoptimize. |
| 2337 | b art_quick_deoptimize |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2338 | END art_quick_instrumentation_exit |
| 2339 | |
| 2340 | /* |
| 2341 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 2342 | * will long jump to the upcall with a special exception of -1. |
| 2343 | */ |
| 2344 | .extern artDeoptimize |
| 2345 | ENTRY art_quick_deoptimize |
Mingyao Yang | 2ee1790 | 2017-08-30 11:37:08 -0700 | [diff] [blame] | 2346 | SETUP_SAVE_EVERYTHING_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2347 | mov x0, xSELF // Pass thread. |
Nicolas Geoffray | 4e92c3c | 2017-05-08 09:34:26 +0100 | [diff] [blame] | 2348 | bl artDeoptimize // (Thread*) |
Serban Constantinescu | 86797a7 | 2014-06-19 16:17:56 +0100 | [diff] [blame] | 2349 | brk 0 |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2350 | END art_quick_deoptimize |
| 2351 | |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2352 | /* |
| 2353 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
| 2354 | * will long jump to the upcall with a special exception of -1. |
| 2355 | */ |
| 2356 | .extern artDeoptimizeFromCompiledCode |
| 2357 | ENTRY art_quick_deoptimize_from_compiled_code |
Vladimir Marko | 239d6ea | 2016-09-05 10:44:04 +0100 | [diff] [blame] | 2358 | SETUP_SAVE_EVERYTHING_FRAME |
Nicolas Geoffray | 4e92c3c | 2017-05-08 09:34:26 +0100 | [diff] [blame] | 2359 | mov x1, xSELF // Pass thread. |
| 2360 | bl artDeoptimizeFromCompiledCode // (DeoptimizationKind, Thread*) |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 2361 | brk 0 |
| 2362 | END art_quick_deoptimize_from_compiled_code |
| 2363 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 2364 | |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2365 | /* |
| 2366 | * String's indexOf. |
| 2367 | * |
| 2368 | * TODO: Not very optimized. |
| 2369 | * On entry: |
| 2370 | * x0: string object (known non-null) |
| 2371 | * w1: char to match (known <= 0xFFFF) |
| 2372 | * w2: Starting offset in string data |
| 2373 | */ |
| 2374 | ENTRY art_quick_indexof |
Vladimir Marko | fdaf0f4 | 2016-10-13 19:29:53 +0100 | [diff] [blame] | 2375 | #if (STRING_COMPRESSION_FEATURE) |
| 2376 | ldr w4, [x0, #MIRROR_STRING_COUNT_OFFSET] |
| 2377 | #else |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 2378 | ldr w3, [x0, #MIRROR_STRING_COUNT_OFFSET] |
Vladimir Marko | fdaf0f4 | 2016-10-13 19:29:53 +0100 | [diff] [blame] | 2379 | #endif |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 2380 | add x0, x0, #MIRROR_STRING_VALUE_OFFSET |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 2381 | #if (STRING_COMPRESSION_FEATURE) |
| 2382 | /* w4 holds count (with flag) and w3 holds actual length */ |
Vladimir Marko | fdaf0f4 | 2016-10-13 19:29:53 +0100 | [diff] [blame] | 2383 | lsr w3, w4, #1 |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 2384 | #endif |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2385 | /* Clamp start to [0..count] */ |
| 2386 | cmp w2, #0 |
| 2387 | csel w2, wzr, w2, lt |
| 2388 | cmp w2, w3 |
| 2389 | csel w2, w3, w2, gt |
| 2390 | |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2391 | /* Save a copy to compute result */ |
| 2392 | mov x5, x0 |
| 2393 | |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 2394 | #if (STRING_COMPRESSION_FEATURE) |
Vladimir Marko | fdaf0f4 | 2016-10-13 19:29:53 +0100 | [diff] [blame] | 2395 | tbz w4, #0, .Lstring_indexof_compressed |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 2396 | #endif |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2397 | /* Build pointer to start of data to compare and pre-bias */ |
| 2398 | add x0, x0, x2, lsl #1 |
| 2399 | sub x0, x0, #2 |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2400 | /* Compute iteration count */ |
| 2401 | sub w2, w3, w2 |
| 2402 | |
| 2403 | /* |
| 2404 | * At this point we have: |
| 2405 | * x0: start of the data to test |
| 2406 | * w1: char to compare |
| 2407 | * w2: iteration count |
| 2408 | * x5: original start of string data |
| 2409 | */ |
| 2410 | |
| 2411 | subs w2, w2, #4 |
| 2412 | b.lt .Lindexof_remainder |
| 2413 | |
| 2414 | .Lindexof_loop4: |
| 2415 | ldrh w6, [x0, #2]! |
| 2416 | ldrh w7, [x0, #2]! |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2417 | ldrh wIP0, [x0, #2]! |
| 2418 | ldrh wIP1, [x0, #2]! |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2419 | cmp w6, w1 |
| 2420 | b.eq .Lmatch_0 |
| 2421 | cmp w7, w1 |
| 2422 | b.eq .Lmatch_1 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2423 | cmp wIP0, w1 |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2424 | b.eq .Lmatch_2 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 2425 | cmp wIP1, w1 |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2426 | b.eq .Lmatch_3 |
| 2427 | subs w2, w2, #4 |
| 2428 | b.ge .Lindexof_loop4 |
| 2429 | |
| 2430 | .Lindexof_remainder: |
| 2431 | adds w2, w2, #4 |
| 2432 | b.eq .Lindexof_nomatch |
| 2433 | |
| 2434 | .Lindexof_loop1: |
| 2435 | ldrh w6, [x0, #2]! |
| 2436 | cmp w6, w1 |
| 2437 | b.eq .Lmatch_3 |
| 2438 | subs w2, w2, #1 |
| 2439 | b.ne .Lindexof_loop1 |
| 2440 | |
| 2441 | .Lindexof_nomatch: |
| 2442 | mov x0, #-1 |
| 2443 | ret |
| 2444 | |
| 2445 | .Lmatch_0: |
| 2446 | sub x0, x0, #6 |
| 2447 | sub x0, x0, x5 |
| 2448 | asr x0, x0, #1 |
| 2449 | ret |
| 2450 | .Lmatch_1: |
| 2451 | sub x0, x0, #4 |
| 2452 | sub x0, x0, x5 |
| 2453 | asr x0, x0, #1 |
| 2454 | ret |
| 2455 | .Lmatch_2: |
| 2456 | sub x0, x0, #2 |
| 2457 | sub x0, x0, x5 |
| 2458 | asr x0, x0, #1 |
| 2459 | ret |
| 2460 | .Lmatch_3: |
| 2461 | sub x0, x0, x5 |
| 2462 | asr x0, x0, #1 |
| 2463 | ret |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 2464 | #if (STRING_COMPRESSION_FEATURE) |
| 2465 | /* |
| 2466 | * Comparing compressed string character-per-character with |
| 2467 | * input character |
| 2468 | */ |
| 2469 | .Lstring_indexof_compressed: |
| 2470 | add x0, x0, x2 |
| 2471 | sub x0, x0, #1 |
| 2472 | sub w2, w3, w2 |
| 2473 | .Lstring_indexof_compressed_loop: |
| 2474 | subs w2, w2, #1 |
| 2475 | b.lt .Lindexof_nomatch |
| 2476 | ldrb w6, [x0, #1]! |
| 2477 | cmp w6, w1 |
| 2478 | b.eq .Lstring_indexof_compressed_matched |
| 2479 | b .Lstring_indexof_compressed_loop |
| 2480 | .Lstring_indexof_compressed_matched: |
| 2481 | sub x0, x0, x5 |
| 2482 | ret |
| 2483 | #endif |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 2484 | END art_quick_indexof |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2485 | |
| 2486 | /* |
| 2487 | * Create a function `name` calling the ReadBarrier::Mark routine, |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2488 | * getting its argument and returning its result through W register |
| 2489 | * `wreg` (corresponding to X register `xreg`), saving and restoring |
| 2490 | * all caller-save registers. |
| 2491 | * |
| 2492 | * If `wreg` is different from `w0`, the generated function follows a |
| 2493 | * non-standard runtime calling convention: |
| 2494 | * - register `wreg` is used to pass the (sole) argument of this |
| 2495 | * function (instead of W0); |
| 2496 | * - register `wreg` is used to return the result of this function |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2497 | * (instead of W0); |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2498 | * - W0 is treated like a normal (non-argument) caller-save register; |
| 2499 | * - everything else is the same as in the standard runtime calling |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2500 | * convention (e.g. standard callee-save registers are preserved). |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2501 | */ |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2502 | .macro READ_BARRIER_MARK_REG name, wreg, xreg |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2503 | ENTRY \name |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 2504 | // Reference is null, no work to do at all. |
| 2505 | cbz \wreg, .Lret_rb_\name |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 2506 | // Use wIP0 as temp and check the mark bit of the reference. wIP0 is not used by the compiler. |
| 2507 | ldr wIP0, [\xreg, #MIRROR_OBJECT_LOCK_WORD_OFFSET] |
Mathieu Chartier | 6f198e3 | 2016-11-03 11:15:04 -0700 | [diff] [blame] | 2508 | tbz wIP0, #LOCK_WORD_MARK_BIT_SHIFT, .Lnot_marked_rb_\name |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 2509 | .Lret_rb_\name: |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 2510 | ret |
Mathieu Chartier | 6f198e3 | 2016-11-03 11:15:04 -0700 | [diff] [blame] | 2511 | .Lnot_marked_rb_\name: |
| 2512 | // Check if the top two bits are one, if this is the case it is a forwarding address. |
Vladimir Marko | b9d0111 | 2017-03-31 10:55:41 +0100 | [diff] [blame] | 2513 | tst wIP0, wIP0, lsl #1 |
| 2514 | bmi .Lret_forwarding_address\name |
Vladimir Marko | 94ce9c2 | 2016-09-30 14:50:51 +0100 | [diff] [blame] | 2515 | .Lslow_rb_\name: |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 2516 | /* |
| 2517 | * Allocate 44 stack slots * 8 = 352 bytes: |
| 2518 | * - 20 slots for core registers X0-15, X17-X19, LR |
| 2519 | * - 24 slots for floating-point registers D0-D7 and D16-D31 |
| 2520 | */ |
| 2521 | // We must not clobber IP1 since code emitted for HLoadClass and HLoadString |
| 2522 | // relies on IP1 being preserved. |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2523 | // Save all potentially live caller-save core registers. |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 2524 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 352 |
Vladimir Marko | 215076b | 2016-09-07 18:05:55 +0100 | [diff] [blame] | 2525 | SAVE_TWO_REGS x2, x3, 16 |
| 2526 | SAVE_TWO_REGS x4, x5, 32 |
| 2527 | SAVE_TWO_REGS x6, x7, 48 |
| 2528 | SAVE_TWO_REGS x8, x9, 64 |
| 2529 | SAVE_TWO_REGS x10, x11, 80 |
| 2530 | SAVE_TWO_REGS x12, x13, 96 |
| 2531 | SAVE_TWO_REGS x14, x15, 112 |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 2532 | SAVE_TWO_REGS x17, x18, 128 // Skip x16, i.e. IP0. |
| 2533 | SAVE_TWO_REGS x19, xLR, 144 // Save also return address. |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2534 | // Save all potentially live caller-save floating-point registers. |
| 2535 | stp d0, d1, [sp, #160] |
| 2536 | stp d2, d3, [sp, #176] |
| 2537 | stp d4, d5, [sp, #192] |
| 2538 | stp d6, d7, [sp, #208] |
| 2539 | stp d16, d17, [sp, #224] |
| 2540 | stp d18, d19, [sp, #240] |
| 2541 | stp d20, d21, [sp, #256] |
| 2542 | stp d22, d23, [sp, #272] |
| 2543 | stp d24, d25, [sp, #288] |
| 2544 | stp d26, d27, [sp, #304] |
| 2545 | stp d28, d29, [sp, #320] |
| 2546 | stp d30, d31, [sp, #336] |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2547 | |
| 2548 | .ifnc \wreg, w0 |
| 2549 | mov w0, \wreg // Pass arg1 - obj from `wreg` |
| 2550 | .endif |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2551 | bl artReadBarrierMark // artReadBarrierMark(obj) |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2552 | .ifnc \wreg, w0 |
| 2553 | mov \wreg, w0 // Return result into `wreg` |
| 2554 | .endif |
| 2555 | |
| 2556 | // Restore core regs, except `xreg`, as `wreg` is used to return the |
| 2557 | // result of this function (simply remove it from the stack instead). |
| 2558 | POP_REGS_NE x0, x1, 0, \xreg |
| 2559 | POP_REGS_NE x2, x3, 16, \xreg |
| 2560 | POP_REGS_NE x4, x5, 32, \xreg |
| 2561 | POP_REGS_NE x6, x7, 48, \xreg |
| 2562 | POP_REGS_NE x8, x9, 64, \xreg |
| 2563 | POP_REGS_NE x10, x11, 80, \xreg |
| 2564 | POP_REGS_NE x12, x13, 96, \xreg |
| 2565 | POP_REGS_NE x14, x15, 112, \xreg |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 2566 | POP_REGS_NE x17, x18, 128, \xreg |
| 2567 | POP_REGS_NE x19, xLR, 144, \xreg // Restore also return address. |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2568 | // Restore floating-point registers. |
| 2569 | ldp d0, d1, [sp, #160] |
| 2570 | ldp d2, d3, [sp, #176] |
| 2571 | ldp d4, d5, [sp, #192] |
| 2572 | ldp d6, d7, [sp, #208] |
| 2573 | ldp d16, d17, [sp, #224] |
| 2574 | ldp d18, d19, [sp, #240] |
| 2575 | ldp d20, d21, [sp, #256] |
| 2576 | ldp d22, d23, [sp, #272] |
| 2577 | ldp d24, d25, [sp, #288] |
| 2578 | ldp d26, d27, [sp, #304] |
| 2579 | ldp d28, d29, [sp, #320] |
| 2580 | ldp d30, d31, [sp, #336] |
Vladimir Marko | ea4c126 | 2017-02-06 19:59:33 +0000 | [diff] [blame] | 2581 | // Remove frame and return. |
| 2582 | DECREASE_FRAME 352 |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2583 | ret |
Mathieu Chartier | 6f198e3 | 2016-11-03 11:15:04 -0700 | [diff] [blame] | 2584 | .Lret_forwarding_address\name: |
Mathieu Chartier | 6f198e3 | 2016-11-03 11:15:04 -0700 | [diff] [blame] | 2585 | // Shift left by the forwarding address shift. This clears out the state bits since they are |
| 2586 | // in the top 2 bits of the lock word. |
Vladimir Marko | b9d0111 | 2017-03-31 10:55:41 +0100 | [diff] [blame] | 2587 | lsl \wreg, wIP0, #LOCK_WORD_STATE_FORWARDING_ADDRESS_SHIFT |
Mathieu Chartier | 6f198e3 | 2016-11-03 11:15:04 -0700 | [diff] [blame] | 2588 | ret |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2589 | END \name |
| 2590 | .endm |
| 2591 | |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2592 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg00, w0, x0 |
| 2593 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg01, w1, x1 |
| 2594 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg02, w2, x2 |
| 2595 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg03, w3, x3 |
| 2596 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg04, w4, x4 |
| 2597 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg05, w5, x5 |
| 2598 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg06, w6, x6 |
| 2599 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg07, w7, x7 |
| 2600 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg08, w8, x8 |
| 2601 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg09, w9, x9 |
| 2602 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg10, w10, x10 |
| 2603 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg11, w11, x11 |
| 2604 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg12, w12, x12 |
| 2605 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg13, w13, x13 |
| 2606 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg14, w14, x14 |
| 2607 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg15, w15, x15 |
Mathieu Chartier | 36c2271 | 2016-08-12 13:19:44 -0700 | [diff] [blame] | 2608 | // READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg16, w16, x16 ip0 is blocked |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2609 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg17, w17, x17 |
| 2610 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg18, w18, x18 |
| 2611 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg19, w19, x19 |
| 2612 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg20, w20, x20 |
| 2613 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg21, w21, x21 |
| 2614 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg22, w22, x22 |
| 2615 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg23, w23, x23 |
| 2616 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg24, w24, x24 |
| 2617 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg25, w25, x25 |
| 2618 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg26, w26, x26 |
| 2619 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg27, w27, x27 |
| 2620 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg28, w28, x28 |
| 2621 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg29, w29, x29 |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2622 | |
Vladimir Marko | f4f2daa | 2017-03-20 18:26:59 +0000 | [diff] [blame] | 2623 | |
| 2624 | .macro SELECT_X_OR_W_FOR_MACRO macro_to_use, x, w, xreg |
| 2625 | .if \xreg |
| 2626 | \macro_to_use \x |
| 2627 | .else |
| 2628 | \macro_to_use \w |
| 2629 | .endif |
| 2630 | .endm |
| 2631 | |
| 2632 | .macro FOR_REGISTERS macro_for_register, macro_for_reserved_register, xreg |
| 2633 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x0, w0, \xreg |
| 2634 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x1, w1, \xreg |
| 2635 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x2, w2, \xreg |
| 2636 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x3, w3, \xreg |
| 2637 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x4, w4, \xreg |
| 2638 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x5, w5, \xreg |
| 2639 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x6, w6, \xreg |
| 2640 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x7, w7, \xreg |
| 2641 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x8, w8, \xreg |
| 2642 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x9, w9, \xreg |
| 2643 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x10, w10, \xreg |
| 2644 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x11, w11, \xreg |
| 2645 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x12, w12, \xreg |
| 2646 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x13, w13, \xreg |
| 2647 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x14, w14, \xreg |
| 2648 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x15, w15, \xreg |
| 2649 | \macro_for_reserved_register // IP0 is reserved |
| 2650 | \macro_for_reserved_register // IP1 is reserved |
| 2651 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x18, w18, \xreg |
| 2652 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x19, w19, \xreg |
| 2653 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x20, w20, \xreg |
| 2654 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x21, w21, \xreg |
| 2655 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x22, w22, \xreg |
| 2656 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x23, w23, \xreg |
| 2657 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x24, w24, \xreg |
| 2658 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x25, w25, \xreg |
| 2659 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x26, w26, \xreg |
| 2660 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x27, w27, \xreg |
| 2661 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x28, w28, \xreg |
| 2662 | SELECT_X_OR_W_FOR_MACRO \macro_for_register, x29, w29, \xreg |
| 2663 | \macro_for_reserved_register // lr is reserved |
| 2664 | \macro_for_reserved_register // sp is reserved |
| 2665 | .endm |
| 2666 | |
| 2667 | .macro FOR_XREGISTERS macro_for_register, macro_for_reserved_register |
| 2668 | FOR_REGISTERS \macro_for_register, \macro_for_reserved_register, /* xreg */ 1 |
| 2669 | .endm |
| 2670 | |
| 2671 | .macro FOR_WREGISTERS macro_for_register, macro_for_reserved_register |
| 2672 | FOR_REGISTERS \macro_for_register, \macro_for_reserved_register, /* xreg */ 0 |
| 2673 | .endm |
| 2674 | |
| 2675 | .macro BRK0_BRK0 |
| 2676 | brk 0 |
| 2677 | brk 0 |
| 2678 | .endm |
| 2679 | |
| 2680 | #if BAKER_MARK_INTROSPECTION_FIELD_LDR_OFFSET != BAKER_MARK_INTROSPECTION_ARRAY_LDR_OFFSET |
| 2681 | #error "Array and field introspection code sharing requires same LDR offset." |
| 2682 | #endif |
| 2683 | .macro INTROSPECTION_ARRAY_LOAD index_reg |
| 2684 | ldr wIP0, [xIP0, \index_reg, lsl #2] |
| 2685 | b art_quick_read_barrier_mark_introspection |
| 2686 | .endm |
| 2687 | |
| 2688 | .macro MOV_WIP0_TO_WREG_AND_BL_LR reg |
| 2689 | mov \reg, wIP0 |
| 2690 | br lr // Do not use RET as we do not enter the entrypoint with "BL". |
| 2691 | .endm |
| 2692 | |
| 2693 | .macro READ_BARRIER_MARK_INTROSPECTION_SLOW_PATH ldr_offset |
| 2694 | /* |
| 2695 | * Allocate 44 stack slots * 8 = 352 bytes: |
| 2696 | * - 19 slots for core registers X0-15, X18-X19, LR |
| 2697 | * - 1 slot padding |
| 2698 | * - 24 slots for floating-point registers D0-D7 and D16-D31 |
| 2699 | */ |
| 2700 | // Save all potentially live caller-save core registers. |
| 2701 | SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 352 |
| 2702 | SAVE_TWO_REGS x2, x3, 16 |
| 2703 | SAVE_TWO_REGS x4, x5, 32 |
| 2704 | SAVE_TWO_REGS x6, x7, 48 |
| 2705 | SAVE_TWO_REGS x8, x9, 64 |
| 2706 | SAVE_TWO_REGS x10, x11, 80 |
| 2707 | SAVE_TWO_REGS x12, x13, 96 |
| 2708 | SAVE_TWO_REGS x14, x15, 112 |
| 2709 | SAVE_TWO_REGS x18, x19, 128 // Skip x16, x17, i.e. IP0, IP1. |
| 2710 | SAVE_REG xLR, 144 // Save return address, skip padding at 152. |
| 2711 | // Save all potentially live caller-save floating-point registers. |
| 2712 | stp d0, d1, [sp, #160] |
| 2713 | stp d2, d3, [sp, #176] |
| 2714 | stp d4, d5, [sp, #192] |
| 2715 | stp d6, d7, [sp, #208] |
| 2716 | stp d16, d17, [sp, #224] |
| 2717 | stp d18, d19, [sp, #240] |
| 2718 | stp d20, d21, [sp, #256] |
| 2719 | stp d22, d23, [sp, #272] |
| 2720 | stp d24, d25, [sp, #288] |
| 2721 | stp d26, d27, [sp, #304] |
| 2722 | stp d28, d29, [sp, #320] |
| 2723 | stp d30, d31, [sp, #336] |
| 2724 | |
| 2725 | mov x0, xIP0 |
| 2726 | bl artReadBarrierMark // artReadBarrierMark(obj) |
| 2727 | mov xIP0, x0 |
| 2728 | |
| 2729 | // Restore core regs, except x0 and x1 as the return register switch case |
| 2730 | // address calculation is smoother with an extra register. |
| 2731 | RESTORE_TWO_REGS x2, x3, 16 |
| 2732 | RESTORE_TWO_REGS x4, x5, 32 |
| 2733 | RESTORE_TWO_REGS x6, x7, 48 |
| 2734 | RESTORE_TWO_REGS x8, x9, 64 |
| 2735 | RESTORE_TWO_REGS x10, x11, 80 |
| 2736 | RESTORE_TWO_REGS x12, x13, 96 |
| 2737 | RESTORE_TWO_REGS x14, x15, 112 |
| 2738 | RESTORE_TWO_REGS x18, x19, 128 // Skip x16, x17, i.e. IP0, IP1. |
| 2739 | RESTORE_REG xLR, 144 // Restore return address. |
Nicolas Geoffray | 7015e76 | 2017-07-02 21:37:02 +0100 | [diff] [blame] | 2740 | // Restore caller-save floating-point registers. |
| 2741 | ldp d0, d1, [sp, #160] |
| 2742 | ldp d2, d3, [sp, #176] |
| 2743 | ldp d4, d5, [sp, #192] |
| 2744 | ldp d6, d7, [sp, #208] |
| 2745 | ldp d16, d17, [sp, #224] |
| 2746 | ldp d18, d19, [sp, #240] |
| 2747 | ldp d20, d21, [sp, #256] |
| 2748 | ldp d22, d23, [sp, #272] |
| 2749 | ldp d24, d25, [sp, #288] |
| 2750 | ldp d26, d27, [sp, #304] |
| 2751 | ldp d28, d29, [sp, #320] |
| 2752 | ldp d30, d31, [sp, #336] |
Vladimir Marko | f4f2daa | 2017-03-20 18:26:59 +0000 | [diff] [blame] | 2753 | |
| 2754 | ldr x0, [lr, #\ldr_offset] // Load the instruction. |
| 2755 | adr xIP1, .Lmark_introspection_return_switch |
| 2756 | bfi xIP1, x0, #3, #5 // Calculate switch case address. |
| 2757 | RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 352 |
| 2758 | br xIP1 |
| 2759 | .endm |
| 2760 | |
| 2761 | /* |
| 2762 | * Use introspection to load a reference from the same address as the LDR |
| 2763 | * instruction in generated code would load (unless loaded by the thunk, |
| 2764 | * see below), call ReadBarrier::Mark() with that reference if needed |
| 2765 | * and return it in the same register as the LDR instruction would load. |
| 2766 | * |
| 2767 | * The entrypoint is called through a thunk that differs across load kinds. |
| 2768 | * For field and array loads the LDR instruction in generated code follows |
| 2769 | * the branch to the thunk, i.e. the LDR is at [LR, #-4], and the thunk |
| 2770 | * knows the holder and performs the gray bit check, returning to the LDR |
| 2771 | * instruction if the object is not gray, so this entrypoint no longer |
| 2772 | * needs to know anything about the holder. For GC root loads, the LDR |
| 2773 | * instruction in generated code precedes the branch to the thunk (i.e. |
| 2774 | * the LDR is at [LR, #-8]) and the thunk does not do the gray bit check. |
| 2775 | * |
| 2776 | * For field accesses and array loads with a constant index the thunk loads |
| 2777 | * the reference into IP0 using introspection and calls the main entrypoint, |
Vladimir Marko | d1ef873 | 2017-04-18 13:55:13 +0100 | [diff] [blame] | 2778 | * art_quick_read_barrier_mark_introspection. With heap poisoning enabled, |
| 2779 | * the passed reference is poisoned. |
Vladimir Marko | f4f2daa | 2017-03-20 18:26:59 +0000 | [diff] [blame] | 2780 | * |
| 2781 | * For array accesses with non-constant index, the thunk inserts the bits |
| 2782 | * 16-21 of the LDR instruction to the entrypoint address, effectively |
| 2783 | * calculating a switch case label based on the index register (bits 16-20) |
| 2784 | * and adding an extra offset (bit 21 is set) to differentiate from the |
| 2785 | * main entrypoint, then moves the base register to IP0 and jumps to the |
| 2786 | * switch case. Therefore we need to align the main entrypoint to 512 bytes, |
| 2787 | * accounting for a 256-byte offset followed by 32 array entrypoints |
| 2788 | * starting at art_quick_read_barrier_mark_introspection_arrays, each |
| 2789 | * containing an LDR (register) and a branch to the main entrypoint. |
| 2790 | * |
| 2791 | * For GC root accesses we cannot use the main entrypoint because of the |
| 2792 | * different offset where the LDR instruction in generated code is located. |
Vladimir Marko | d1ef873 | 2017-04-18 13:55:13 +0100 | [diff] [blame] | 2793 | * (And even with heap poisoning enabled, GC roots are not poisoned.) |
Vladimir Marko | f4f2daa | 2017-03-20 18:26:59 +0000 | [diff] [blame] | 2794 | * To re-use the same entrypoint pointer in generated code, we make sure |
| 2795 | * that the gc root entrypoint (a copy of the entrypoint with a different |
| 2796 | * offset for introspection loads) is located at a known offset (768 bytes, |
| 2797 | * or BAKER_MARK_INTROSPECTION_GC_ROOT_ENTRYPOINT_OFFSET) from the main |
| 2798 | * entrypoint and the GC root thunk adjusts the entrypoint pointer, moves |
| 2799 | * the root register to IP0 and jumps to the customized entrypoint, |
| 2800 | * art_quick_read_barrier_mark_introspection_gc_roots. The thunk also |
| 2801 | * performs all the fast-path checks, so we need just the slow path. |
| 2802 | * |
| 2803 | * The code structure is |
| 2804 | * art_quick_read_barrier_mark_introspection: |
| 2805 | * Up to 256 bytes for the main entrypoint code. |
| 2806 | * Padding to 256 bytes if needed. |
| 2807 | * art_quick_read_barrier_mark_introspection_arrays: |
| 2808 | * Exactly 256 bytes for array load switch cases (32x2 instructions). |
| 2809 | * .Lmark_introspection_return_switch: |
| 2810 | * Exactly 256 bytes for return switch cases (32x2 instructions). |
| 2811 | * art_quick_read_barrier_mark_introspection_gc_roots: |
| 2812 | * GC root entrypoint code. |
| 2813 | */ |
| 2814 | .balign 512 |
| 2815 | ENTRY art_quick_read_barrier_mark_introspection |
| 2816 | // At this point, IP0 contains the reference, IP1 can be freely used. |
Vladimir Marko | d1ef873 | 2017-04-18 13:55:13 +0100 | [diff] [blame] | 2817 | // For heap poisoning, the reference is poisoned, so unpoison it first. |
| 2818 | UNPOISON_HEAP_REF wIP0 |
Vladimir Marko | f4f2daa | 2017-03-20 18:26:59 +0000 | [diff] [blame] | 2819 | // If reference is null, just return it in the right register. |
| 2820 | cbz wIP0, .Lmark_introspection_return |
| 2821 | // Use wIP1 as temp and check the mark bit of the reference. |
| 2822 | ldr wIP1, [xIP0, #MIRROR_OBJECT_LOCK_WORD_OFFSET] |
| 2823 | tbz wIP1, #LOCK_WORD_MARK_BIT_SHIFT, .Lmark_introspection_unmarked |
| 2824 | .Lmark_introspection_return: |
| 2825 | // Without an extra register for the return switch case address calculation, |
| 2826 | // we exploit the high word of the xIP0 to temporarily store the ref_reg*8, |
| 2827 | // so the return switch below must move wIP0 instead of xIP0 to the register. |
| 2828 | ldr wIP1, [lr, #BAKER_MARK_INTROSPECTION_FIELD_LDR_OFFSET] // Load the instruction. |
| 2829 | bfi xIP0, xIP1, #(32 + 3), #5 // Extract ref_reg*8 to high word in xIP0. |
| 2830 | adr xIP1, .Lmark_introspection_return_switch |
| 2831 | bfxil xIP1, xIP0, #32, #8 // Calculate return switch case address. |
| 2832 | br xIP1 |
| 2833 | .Lmark_introspection_unmarked: |
| 2834 | // Check if the top two bits are one, if this is the case it is a forwarding address. |
| 2835 | tst wIP1, wIP1, lsl #1 |
| 2836 | bmi .Lmark_introspection_forwarding_address |
| 2837 | READ_BARRIER_MARK_INTROSPECTION_SLOW_PATH BAKER_MARK_INTROSPECTION_FIELD_LDR_OFFSET |
| 2838 | |
| 2839 | .Lmark_introspection_forwarding_address: |
| 2840 | // Shift left by the forwarding address shift. This clears out the state bits since they are |
| 2841 | // in the top 2 bits of the lock word. |
| 2842 | lsl wIP0, wIP1, #LOCK_WORD_STATE_FORWARDING_ADDRESS_SHIFT |
| 2843 | b .Lmark_introspection_return |
| 2844 | |
| 2845 | // We're very close to the alloted 256B for the entrypoint code before the |
| 2846 | // array switch cases. Should we go a little bit over the limit, we can |
| 2847 | // move some code after the array switch cases and return switch cases. |
| 2848 | .balign 256 |
| 2849 | .hidden art_quick_read_barrier_mark_introspection_arrays |
| 2850 | .global art_quick_read_barrier_mark_introspection_arrays |
| 2851 | art_quick_read_barrier_mark_introspection_arrays: |
| 2852 | FOR_XREGISTERS INTROSPECTION_ARRAY_LOAD, BRK0_BRK0 |
| 2853 | .Lmark_introspection_return_switch: |
| 2854 | FOR_WREGISTERS MOV_WIP0_TO_WREG_AND_BL_LR, BRK0_BRK0 |
| 2855 | .hidden art_quick_read_barrier_mark_introspection_gc_roots |
| 2856 | .global art_quick_read_barrier_mark_introspection_gc_roots |
| 2857 | art_quick_read_barrier_mark_introspection_gc_roots: |
| 2858 | READ_BARRIER_MARK_INTROSPECTION_SLOW_PATH BAKER_MARK_INTROSPECTION_GC_ROOT_LDR_OFFSET |
| 2859 | END art_quick_read_barrier_mark_introspection |
| 2860 | |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2861 | .extern artInvokePolymorphic |
| 2862 | ENTRY art_quick_invoke_polymorphic |
| 2863 | SETUP_SAVE_REFS_AND_ARGS_FRAME // Save callee saves in case allocation triggers GC. |
| 2864 | mov x2, xSELF |
| 2865 | mov x3, sp |
| 2866 | INCREASE_FRAME 16 // Reserve space for JValue result. |
| 2867 | str xzr, [sp, #0] // Initialize result to zero. |
| 2868 | mov x0, sp // Set r0 to point to result. |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 2869 | bl artInvokePolymorphic // artInvokePolymorphic(result, receiver, thread, save_area) |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2870 | uxtb w0, w0 // Result is the return type descriptor as a char. |
| 2871 | sub w0, w0, 'A' // Convert to zero based index. |
| 2872 | cmp w0, 'Z' - 'A' |
| 2873 | bhi .Lcleanup_and_return // Clean-up if out-of-bounds. |
| 2874 | adrp x1, .Lhandler_table // Compute address of handler table. |
| 2875 | add x1, x1, :lo12:.Lhandler_table |
| 2876 | ldrb w0, [x1, w0, uxtw] // Lookup handler offset in handler table. |
| 2877 | adr x1, .Lstart_of_handlers |
| 2878 | add x0, x1, w0, sxtb #2 // Convert relative offset to absolute address. |
| 2879 | br x0 // Branch to handler. |
| 2880 | |
| 2881 | .Lstart_of_handlers: |
| 2882 | .Lstore_boolean_result: |
| 2883 | ldrb w0, [sp] |
| 2884 | b .Lcleanup_and_return |
| 2885 | .Lstore_char_result: |
| 2886 | ldrh w0, [sp] |
| 2887 | b .Lcleanup_and_return |
| 2888 | .Lstore_float_result: |
| 2889 | ldr s0, [sp] |
| 2890 | str s0, [sp, #32] |
| 2891 | b .Lcleanup_and_return |
| 2892 | .Lstore_double_result: |
| 2893 | ldr d0, [sp] |
| 2894 | str d0, [sp, #32] |
| 2895 | b .Lcleanup_and_return |
| 2896 | .Lstore_long_result: |
| 2897 | ldr x0, [sp] |
| 2898 | // Fall-through |
| 2899 | .Lcleanup_and_return: |
| 2900 | DECREASE_FRAME 16 |
| 2901 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 2902 | REFRESH_MARKING_REGISTER |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 2903 | RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 2904 | |
| 2905 | .section .rodata // Place handler table in read-only section away from text. |
| 2906 | .align 2 |
| 2907 | .macro HANDLER_TABLE_OFFSET handler_label |
| 2908 | .byte (\handler_label - .Lstart_of_handlers) / 4 |
| 2909 | .endm |
| 2910 | .Lhandler_table: |
| 2911 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // A |
| 2912 | HANDLER_TABLE_OFFSET(.Lstore_long_result) // B (byte) |
| 2913 | HANDLER_TABLE_OFFSET(.Lstore_char_result) // C (char) |
| 2914 | HANDLER_TABLE_OFFSET(.Lstore_double_result) // D (double) |
| 2915 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // E |
| 2916 | HANDLER_TABLE_OFFSET(.Lstore_float_result) // F (float) |
| 2917 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // G |
| 2918 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // H |
| 2919 | HANDLER_TABLE_OFFSET(.Lstore_long_result) // I (int) |
| 2920 | HANDLER_TABLE_OFFSET(.Lstore_long_result) // J (long) |
| 2921 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // K |
| 2922 | HANDLER_TABLE_OFFSET(.Lstore_long_result) // L (object - references are compressed and only 32-bits) |
| 2923 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // M |
| 2924 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // N |
| 2925 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // O |
| 2926 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // P |
| 2927 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // Q |
| 2928 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // R |
| 2929 | HANDLER_TABLE_OFFSET(.Lstore_long_result) // S (short) |
| 2930 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // T |
| 2931 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // U |
| 2932 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // V (void) |
| 2933 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // W |
| 2934 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // X |
| 2935 | HANDLER_TABLE_OFFSET(.Lcleanup_and_return) // Y |
| 2936 | HANDLER_TABLE_OFFSET(.Lstore_boolean_result) // Z (boolean) |
| 2937 | .text |
| 2938 | |
| 2939 | END art_quick_invoke_polymorphic |
David Srbecky | 946bb09 | 2018-03-09 17:23:01 +0000 | [diff] [blame] | 2940 | |
| 2941 | // Wrap ExecuteSwitchImpl in assembly method which specifies DEX PC for unwinding. |
| 2942 | // Argument 0: x0: The context pointer for ExecuteSwitchImpl. |
| 2943 | // Argument 1: x1: Pointer to the templated ExecuteSwitchImpl to call. |
| 2944 | // Argument 2: x2: The value of DEX PC (memory address of the methods bytecode). |
| 2945 | ENTRY ExecuteSwitchImplAsm |
| 2946 | SAVE_TWO_REGS_INCREASE_FRAME x19, xLR, 16 |
| 2947 | mov x19, x2 // x19 = DEX PC |
| 2948 | CFI_DEFINE_DEX_PC_WITH_OFFSET(0 /* x0 */, 19 /* x19 */, 0) |
| 2949 | blr x1 // Call the wrapped method. |
| 2950 | RESTORE_TWO_REGS_DECREASE_FRAME x19, xLR, 16 |
| 2951 | ret |
| 2952 | END ExecuteSwitchImplAsm |