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