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" |
| 18 | |
| 19 | #include "arch/quick_alloc_entrypoints.S" |
| 20 | |
| 21 | |
| 22 | /* |
| 23 | * Macro that sets up the callee save frame to conform with |
| 24 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
| 25 | */ |
| 26 | .macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 27 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 28 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 29 | |
| 30 | // Our registers aren't intermixed - just spill in order. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 31 | ldr xIP0, [xIP0] // xIP0 = & (art::Runtime * art::Runtime.instance_) . |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 32 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 33 | // xIP0 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] . |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 34 | // Loads appropriate callee-save-method. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 35 | ldr xIP0, [xIP0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET ] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 36 | |
| 37 | sub sp, sp, #176 |
| 38 | .cfi_adjust_cfa_offset 176 |
| 39 | |
| 40 | // Ugly compile-time check, but we only have the preprocessor. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 41 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 176) |
| 42 | #error "SAVE_ALL_CALLEE_SAVE_FRAME(ARM64) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 43 | #endif |
| 44 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 45 | // Stack alignment filler [sp, #8]. |
| 46 | // FP callee-saves. |
| 47 | stp d8, d9, [sp, #16] |
| 48 | stp d10, d11, [sp, #32] |
| 49 | stp d12, d13, [sp, #48] |
| 50 | stp d14, d15, [sp, #64] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 51 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 52 | // GP callee-saves |
| 53 | stp x19, x20, [sp, #80] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 54 | .cfi_rel_offset x19, 80 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 55 | .cfi_rel_offset x20, 88 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 56 | |
| 57 | stp x21, x22, [sp, #96] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 58 | .cfi_rel_offset x21, 96 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 59 | .cfi_rel_offset x22, 104 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 60 | |
| 61 | stp x23, x24, [sp, #112] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 62 | .cfi_rel_offset x23, 112 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 63 | .cfi_rel_offset x24, 120 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 64 | |
| 65 | stp x25, x26, [sp, #128] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 66 | .cfi_rel_offset x25, 128 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 67 | .cfi_rel_offset x26, 136 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 68 | |
| 69 | stp x27, x28, [sp, #144] |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 70 | .cfi_rel_offset x27, 144 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 71 | .cfi_rel_offset x28, 152 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 72 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 73 | stp x29, xLR, [sp, #160] |
| 74 | .cfi_rel_offset x29, 160 |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 75 | .cfi_rel_offset x30, 168 |
| 76 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 77 | // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs]. |
| 78 | str xIP0, [sp] |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 79 | // Place sp in Thread::Current()->top_quick_frame. |
| 80 | mov xIP0, sp |
| 81 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 82 | .endm |
| 83 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 84 | /* |
| 85 | * Macro that sets up the callee save frame to conform with |
| 86 | * Runtime::CreateCalleeSaveMethod(kRefsOnly). |
| 87 | */ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 88 | .macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 89 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 90 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
| 91 | |
| 92 | // Our registers aren't intermixed - just spill in order. |
| 93 | ldr xIP0, [xIP0] // xIP0 = & (art::Runtime * art::Runtime.instance_) . |
| 94 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 95 | // xIP0 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefOnly] . |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 96 | // Loads appropriate callee-save-method. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 97 | ldr xIP0, [xIP0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET ] |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 98 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 99 | sub sp, sp, #96 |
| 100 | .cfi_adjust_cfa_offset 96 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 101 | |
| 102 | // Ugly compile-time check, but we only have the preprocessor. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 103 | #if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 96) |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 104 | #error "REFS_ONLY_CALLEE_SAVE_FRAME(ARM64) size not as expected." |
| 105 | #endif |
| 106 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 107 | // GP callee-saves. |
| 108 | // x20 paired with ArtMethod* - see below. |
| 109 | stp x21, x22, [sp, #16] |
| 110 | .cfi_rel_offset x21, 16 |
| 111 | .cfi_rel_offset x22, 24 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 112 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 113 | stp x23, x24, [sp, #32] |
| 114 | .cfi_rel_offset x23, 32 |
| 115 | .cfi_rel_offset x24, 40 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 116 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 117 | stp x25, x26, [sp, #48] |
| 118 | .cfi_rel_offset x25, 48 |
| 119 | .cfi_rel_offset x26, 56 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 120 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 121 | stp x27, x28, [sp, #64] |
| 122 | .cfi_rel_offset x27, 64 |
| 123 | .cfi_rel_offset x28, 72 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 124 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 125 | stp x29, xLR, [sp, #80] |
| 126 | .cfi_rel_offset x29, 80 |
| 127 | .cfi_rel_offset x30, 88 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 128 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 129 | // Store ArtMethod* Runtime::callee_save_methods_[kRefsOnly]. |
| 130 | stp xIP0, x20, [sp] |
| 131 | .cfi_rel_offset x20, 8 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 132 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 133 | // Place sp in Thread::Current()->top_quick_frame. |
| 134 | mov xIP0, sp |
| 135 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 136 | .endm |
| 137 | |
| 138 | // TODO: Probably no need to restore registers preserved by aapcs64. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 139 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 140 | // Callee-saves. |
| 141 | ldr x20, [sp, #8] |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 142 | .cfi_restore x20 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 143 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 144 | ldp x21, x22, [sp, #16] |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 145 | .cfi_restore x21 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 146 | .cfi_restore x22 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 147 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 148 | ldp x23, x24, [sp, #32] |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 149 | .cfi_restore x23 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 150 | .cfi_restore x24 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 151 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 152 | ldp x25, x26, [sp, #48] |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 153 | .cfi_restore x25 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 154 | .cfi_restore x26 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 155 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 156 | ldp x27, x28, [sp, #64] |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 157 | .cfi_restore x27 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 158 | .cfi_restore x28 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 159 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 160 | ldp x29, xLR, [sp, #80] |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 161 | .cfi_restore x29 |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 162 | .cfi_restore x30 |
| 163 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 164 | add sp, sp, #96 |
| 165 | .cfi_adjust_cfa_offset -96 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 166 | .endm |
| 167 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 168 | .macro POP_REFS_ONLY_CALLEE_SAVE_FRAME |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 169 | add sp, sp, #96 |
| 170 | .cfi_adjust_cfa_offset - 96 |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 171 | .endm |
| 172 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 173 | .macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
| 174 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 175 | ret |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 176 | .endm |
| 177 | |
| 178 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 179 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 180 | sub sp, sp, #224 |
| 181 | .cfi_adjust_cfa_offset 224 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 182 | |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 183 | // Ugly compile-time check, but we only have the preprocessor. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 184 | #if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 224) |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 185 | #error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(ARM64) size not as expected." |
| 186 | #endif |
| 187 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 188 | // Stack alignment filler [sp, #8]. |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 189 | // FP args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 190 | stp d0, d1, [sp, #16] |
| 191 | stp d2, d3, [sp, #32] |
| 192 | stp d4, d5, [sp, #48] |
| 193 | stp d6, d7, [sp, #64] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 194 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 195 | // Core args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 196 | stp x1, x2, [sp, #80] |
| 197 | .cfi_rel_offset x1, 80 |
| 198 | .cfi_rel_offset x2, 88 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 199 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 200 | stp x3, x4, [sp, #96] |
| 201 | .cfi_rel_offset x3, 96 |
| 202 | .cfi_rel_offset x4, 104 |
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 | stp x5, x6, [sp, #112] |
| 205 | .cfi_rel_offset x5, 112 |
| 206 | .cfi_rel_offset x6, 120 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 207 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 208 | // x7, Callee-saves. |
| 209 | stp x7, x20, [sp, #128] |
| 210 | .cfi_rel_offset x7, 128 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 211 | .cfi_rel_offset x20, 136 |
| 212 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 213 | stp x21, x22, [sp, #144] |
| 214 | .cfi_rel_offset x21, 144 |
| 215 | .cfi_rel_offset x22, 152 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 216 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 217 | stp x23, x24, [sp, #160] |
| 218 | .cfi_rel_offset x23, 160 |
| 219 | .cfi_rel_offset x24, 168 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 220 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 221 | stp x25, x26, [sp, #176] |
| 222 | .cfi_rel_offset x25, 176 |
| 223 | .cfi_rel_offset x26, 184 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 224 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 225 | stp x27, x28, [sp, #192] |
| 226 | .cfi_rel_offset x27, 192 |
| 227 | .cfi_rel_offset x28, 200 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 228 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 229 | // x29(callee-save) and LR. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 230 | stp x29, xLR, [sp, #208] |
| 231 | .cfi_rel_offset x29, 208 |
| 232 | .cfi_rel_offset x30, 216 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 233 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 234 | .endm |
| 235 | |
| 236 | /* |
| 237 | * Macro that sets up the callee save frame to conform with |
| 238 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). |
| 239 | * |
| 240 | * TODO This is probably too conservative - saving FP & LR. |
| 241 | */ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 242 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 243 | adrp xIP0, :got:_ZN3art7Runtime9instance_E |
| 244 | ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 245 | |
| 246 | // Our registers aren't intermixed - just spill in order. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 247 | ldr xIP0, [xIP0] // xIP0 = & (art::Runtime * art::Runtime.instance_) . |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 248 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 249 | // xIP0 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] . |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 250 | ldr xIP0, [xIP0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET ] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 251 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 252 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 253 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 254 | str xIP0, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs] |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 255 | // Place sp in Thread::Current()->top_quick_frame. |
| 256 | mov xIP0, sp |
| 257 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
| 258 | .endm |
| 259 | |
| 260 | .macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_X0 |
| 261 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL |
| 262 | str x0, [sp, #0] // Store ArtMethod* to bottom of stack. |
| 263 | // Place sp in Thread::Current()->top_quick_frame. |
| 264 | mov xIP0, sp |
| 265 | str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 266 | .endm |
| 267 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 268 | // TODO: Probably no need to restore registers preserved by aapcs64. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 269 | .macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 270 | // FP args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 271 | ldp d0, d1, [sp, #16] |
| 272 | ldp d2, d3, [sp, #32] |
| 273 | ldp d4, d5, [sp, #48] |
| 274 | ldp d6, d7, [sp, #64] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 275 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 276 | // Core args. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 277 | ldp x1, x2, [sp, #80] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 278 | .cfi_restore x1 |
| 279 | .cfi_restore x2 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 280 | |
| 281 | ldp x3, x4, [sp, #96] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 282 | .cfi_restore x3 |
| 283 | .cfi_restore x4 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 284 | |
| 285 | ldp x5, x6, [sp, #112] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 286 | .cfi_restore x5 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 287 | .cfi_restore x6 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 288 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 289 | // x7, Callee-saves. |
| 290 | ldp x7, x20, [sp, #128] |
| 291 | .cfi_restore x7 |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 292 | .cfi_restore x20 |
| 293 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 294 | ldp x21, x22, [sp, #144] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 295 | .cfi_restore x21 |
| 296 | .cfi_restore x22 |
| 297 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 298 | ldp x23, x24, [sp, #160] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 299 | .cfi_restore x23 |
| 300 | .cfi_restore x24 |
| 301 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 302 | ldp x25, x26, [sp, #176] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 303 | .cfi_restore x25 |
| 304 | .cfi_restore x26 |
| 305 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 306 | ldp x27, x28, [sp, #192] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 307 | .cfi_restore x27 |
| 308 | .cfi_restore x28 |
| 309 | |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 310 | // x29(callee-save) and LR. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 311 | ldp x29, xLR, [sp, #208] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 312 | .cfi_restore x29 |
| 313 | .cfi_restore x30 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 314 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 315 | add sp, sp, #224 |
| 316 | .cfi_adjust_cfa_offset -224 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 317 | .endm |
| 318 | |
| 319 | .macro RETURN_IF_RESULT_IS_ZERO |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 320 | cbnz x0, 1f // result non-zero branch over |
| 321 | ret // return |
| 322 | 1: |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 323 | .endm |
| 324 | |
| 325 | .macro RETURN_IF_RESULT_IS_NON_ZERO |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 326 | cbz x0, 1f // result zero branch over |
| 327 | ret // return |
| 328 | 1: |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 329 | .endm |
| 330 | |
| 331 | /* |
| 332 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 333 | * exception is Thread::Current()->exception_ |
| 334 | */ |
| 335 | .macro DELIVER_PENDING_EXCEPTION |
| 336 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 337 | mov x0, xSELF |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 338 | |
| 339 | // Point of no return. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 340 | b artDeliverPendingExceptionFromCode // artDeliverPendingExceptionFromCode(Thread*) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 341 | brk 0 // Unreached |
| 342 | .endm |
| 343 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 344 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg |
| 345 | ldr \reg, [xSELF, # THREAD_EXCEPTION_OFFSET] // Get exception field. |
| 346 | cbnz \reg, 1f |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 347 | ret |
| 348 | 1: |
| 349 | DELIVER_PENDING_EXCEPTION |
| 350 | .endm |
| 351 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 352 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 353 | RETURN_OR_DELIVER_PENDING_EXCEPTION_REG xIP0 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 354 | .endm |
| 355 | |
| 356 | // Same as above with x1. This is helpful in stubs that want to avoid clobbering another register. |
| 357 | .macro RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 358 | RETURN_OR_DELIVER_PENDING_EXCEPTION_REG x1 |
| 359 | .endm |
| 360 | |
| 361 | .macro RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 362 | cbnz w0, 1f // result non-zero branch over |
| 363 | ret // return |
| 364 | 1: |
| 365 | DELIVER_PENDING_EXCEPTION |
| 366 | .endm |
| 367 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 368 | .macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 369 | .extern \cxx_name |
| 370 | ENTRY \c_name |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 371 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 372 | mov x0, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 373 | b \cxx_name // \cxx_name(Thread*) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 374 | END \c_name |
| 375 | .endm |
| 376 | |
| 377 | .macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 378 | .extern \cxx_name |
| 379 | ENTRY \c_name |
Serban Constantinescu | 75b9113 | 2014-04-09 18:39:10 +0100 | [diff] [blame] | 380 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context. |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 381 | mov x1, xSELF // pass Thread::Current. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 382 | b \cxx_name // \cxx_name(arg, Thread*). |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 383 | brk 0 |
| 384 | END \c_name |
| 385 | .endm |
| 386 | |
| 387 | .macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 388 | .extern \cxx_name |
| 389 | ENTRY \c_name |
| 390 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 391 | mov x2, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 392 | b \cxx_name // \cxx_name(arg1, arg2, Thread*) |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 393 | brk 0 |
| 394 | END \c_name |
| 395 | .endm |
| 396 | |
| 397 | /* |
| 398 | * Called by managed code, saves callee saves and then calls artThrowException |
| 399 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 400 | */ |
| 401 | ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode |
| 402 | |
| 403 | /* |
| 404 | * Called by managed code to create and deliver a NullPointerException. |
| 405 | */ |
| 406 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode |
| 407 | |
| 408 | /* |
| 409 | * Called by managed code to create and deliver an ArithmeticException. |
| 410 | */ |
| 411 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode |
| 412 | |
| 413 | /* |
| 414 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 415 | * index, arg2 holds limit. |
| 416 | */ |
| 417 | TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode |
| 418 | |
| 419 | /* |
| 420 | * Called by managed code to create and deliver a StackOverflowError. |
| 421 | */ |
| 422 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode |
| 423 | |
| 424 | /* |
| 425 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 426 | */ |
| 427 | ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode |
| 428 | |
| 429 | /* |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 430 | * 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] | 431 | * 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] | 432 | * 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] | 433 | * 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] | 434 | * |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 435 | * 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] | 436 | * of the target Method* in x0 and method->code_ in x1. |
| 437 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 438 | * 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] | 439 | * thread and we branch to another stub to deliver it. |
| 440 | * |
| 441 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 442 | * pointing back to the original caller. |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 443 | * |
| 444 | * Adapted from ARM32 code. |
| 445 | * |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 446 | * Clobbers xIP0. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 447 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 448 | .macro INVOKE_TRAMPOLINE_BODY cxx_name |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 449 | .extern \cxx_name |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 450 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME // save callee saves in case allocation triggers GC |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 451 | // Helper signature is always |
| 452 | // (method_idx, *this_object, *caller_method, *self, sp) |
| 453 | |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 454 | mov x2, xSELF // pass Thread::Current |
| 455 | mov x3, sp |
| 456 | bl \cxx_name // (method_idx, this, Thread*, SP) |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 457 | mov xIP0, x1 // save Method*->code_ |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 458 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 459 | 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] | 460 | br xIP0 // tail call to target |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 461 | 1: |
| 462 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 463 | .endm |
| 464 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 465 | ENTRY \c_name |
| 466 | INVOKE_TRAMPOLINE_BODY \cxx_name |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 467 | END \c_name |
| 468 | .endm |
| 469 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 470 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 471 | |
| 472 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 473 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 474 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 475 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| 476 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 477 | |
| 478 | .macro INVOKE_STUB_CREATE_FRAME |
| 479 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 480 | SAVE_SIZE=15*8 // x4, x5, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, SP, LR, FP saved. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 481 | SAVE_SIZE_AND_METHOD=SAVE_SIZE+8 |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 482 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 483 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 484 | mov x9, sp // Save stack pointer. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 485 | .cfi_register sp,x9 |
| 486 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 487 | add x10, x2, # SAVE_SIZE_AND_METHOD // calculate size of frame. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 488 | sub x10, sp, x10 // Calculate SP position - saves + ArtMethod* + args |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 489 | and x10, x10, # ~0xf // Enforce 16 byte stack alignment. |
| 490 | mov sp, x10 // Set new SP. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 491 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 492 | sub x10, x9, #SAVE_SIZE // Calculate new FP (later). Done here as we must move SP |
| 493 | .cfi_def_cfa_register x10 // before this. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 494 | .cfi_adjust_cfa_offset SAVE_SIZE |
| 495 | |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 496 | str x28, [x10, #112] |
| 497 | .cfi_rel_offset x28, 112 |
| 498 | |
| 499 | stp x26, x27, [x10, #96] |
| 500 | .cfi_rel_offset x26, 96 |
| 501 | .cfi_rel_offset x27, 104 |
| 502 | |
| 503 | stp x24, x25, [x10, #80] |
| 504 | .cfi_rel_offset x24, 80 |
| 505 | .cfi_rel_offset x25, 88 |
| 506 | |
| 507 | stp x22, x23, [x10, #64] |
| 508 | .cfi_rel_offset x22, 64 |
| 509 | .cfi_rel_offset x23, 72 |
| 510 | |
| 511 | stp x20, x21, [x10, #48] |
| 512 | .cfi_rel_offset x20, 48 |
| 513 | .cfi_rel_offset x21, 56 |
| 514 | |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 515 | stp x9, x19, [x10, #32] // Save old stack pointer and x19. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 516 | .cfi_rel_offset sp, 32 |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 517 | .cfi_rel_offset x19, 40 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 518 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 519 | stp x4, x5, [x10, #16] // Save result and shorty addresses. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 520 | .cfi_rel_offset x4, 16 |
| 521 | .cfi_rel_offset x5, 24 |
| 522 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 523 | stp xFP, xLR, [x10] // Store LR & FP. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 524 | .cfi_rel_offset x29, 0 |
| 525 | .cfi_rel_offset x30, 8 |
| 526 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 527 | mov xFP, x10 // Use xFP now, as it's callee-saved. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 528 | .cfi_def_cfa_register x29 |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 529 | mov xSELF, x3 // Move thread pointer into SELF register. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 530 | |
| 531 | // Copy arguments into stack frame. |
| 532 | // Use simple copy routine for now. |
| 533 | // 4 bytes per slot. |
| 534 | // X1 - source address |
| 535 | // W2 - args length |
| 536 | // X9 - destination address. |
| 537 | // W10 - temporary |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 538 | add x9, sp, #8 // Destination address is bottom of stack + null. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 539 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 540 | // Copy parameters into the stack. Use numeric label as this is a macro and Clang's assembler |
| 541 | // does not have unique-id variables. |
| 542 | 1: |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 543 | cmp w2, #0 |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 544 | beq 2f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 545 | sub w2, w2, #4 // Need 65536 bytes of range. |
| 546 | ldr w10, [x1, x2] |
| 547 | str w10, [x9, x2] |
| 548 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 549 | b 1b |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 550 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 551 | 2: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 552 | // Store null into ArtMethod* at bottom of frame. |
| 553 | str xzr, [sp] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 554 | .endm |
| 555 | |
| 556 | .macro INVOKE_STUB_CALL_AND_RETURN |
| 557 | |
| 558 | // load method-> METHOD_QUICK_CODE_OFFSET |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 559 | ldr x9, [x0, #ART_METHOD_QUICK_CODE_OFFSET_64] |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 560 | // Branch to method. |
| 561 | blr x9 |
| 562 | |
| 563 | // Restore return value address and shorty address. |
| 564 | ldp x4,x5, [xFP, #16] |
| 565 | .cfi_restore x4 |
| 566 | .cfi_restore x5 |
| 567 | |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 568 | ldr x28, [xFP, #112] |
| 569 | .cfi_restore x28 |
| 570 | |
| 571 | ldp x26, x27, [xFP, #96] |
| 572 | .cfi_restore x26 |
| 573 | .cfi_restore x27 |
| 574 | |
| 575 | ldp x24, x25, [xFP, #80] |
| 576 | .cfi_restore x24 |
| 577 | .cfi_restore x25 |
| 578 | |
| 579 | ldp x22, x23, [xFP, #64] |
| 580 | .cfi_restore x22 |
| 581 | .cfi_restore x23 |
| 582 | |
| 583 | ldp x20, x21, [xFP, #48] |
| 584 | .cfi_restore x20 |
| 585 | .cfi_restore x21 |
| 586 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 587 | // Store result (w0/x0/s0/d0) appropriately, depending on resultType. |
| 588 | ldrb w10, [x5] |
| 589 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 590 | // Check the return type and store the correct register into the jvalue in memory. |
| 591 | // Use numeric label as this is a macro and Clang's assembler does not have unique-id variables. |
| 592 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 593 | // Don't set anything for a void type. |
| 594 | cmp w10, #'V' |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 595 | beq 3f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 596 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 597 | // Is it a double? |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 598 | cmp w10, #'D' |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 599 | bne 1f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 600 | str d0, [x4] |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 601 | b 3f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 602 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 603 | 1: // Is it a float? |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 604 | cmp w10, #'F' |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 605 | bne 2f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 606 | str s0, [x4] |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 607 | b 3f |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 608 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 609 | 2: // 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] | 610 | str x0, [x4] |
| 611 | |
Chih-Hung Hsieh | c0da7ac | 2015-07-27 10:10:44 -0700 | [diff] [blame] | 612 | 3: // Finish up. |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 613 | ldp x2, x19, [xFP, #32] // Restore stack pointer and x19. |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 614 | .cfi_restore x19 |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 615 | mov sp, x2 |
| 616 | .cfi_restore sp |
| 617 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 618 | ldp xFP, xLR, [xFP] // Restore old frame pointer and link register. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 619 | .cfi_restore x29 |
| 620 | .cfi_restore x30 |
| 621 | |
| 622 | ret |
| 623 | |
| 624 | .endm |
| 625 | |
| 626 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 627 | /* |
| 628 | * extern"C" void art_quick_invoke_stub(ArtMethod *method, x0 |
| 629 | * uint32_t *args, x1 |
| 630 | * uint32_t argsize, w2 |
| 631 | * Thread *self, x3 |
| 632 | * JValue *result, x4 |
| 633 | * char *shorty); x5 |
| 634 | * +----------------------+ |
| 635 | * | | |
| 636 | * | C/C++ frame | |
| 637 | * | LR'' | |
| 638 | * | FP'' | <- SP' |
| 639 | * +----------------------+ |
| 640 | * +----------------------+ |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 641 | * | x28 | <- TODO: Remove callee-saves. |
| 642 | * | : | |
| 643 | * | x19 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 644 | * | SP' | |
| 645 | * | X5 | |
| 646 | * | X4 | Saved registers |
| 647 | * | LR' | |
| 648 | * | FP' | <- FP |
| 649 | * +----------------------+ |
| 650 | * | uint32_t out[n-1] | |
| 651 | * | : : | Outs |
| 652 | * | uint32_t out[0] | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 653 | * | ArtMethod* | <- SP value=null |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 654 | * +----------------------+ |
| 655 | * |
| 656 | * Outgoing registers: |
| 657 | * x0 - Method* |
| 658 | * x1-x7 - integer parameters. |
| 659 | * d0-d7 - Floating point parameters. |
| 660 | * xSELF = self |
| 661 | * SP = & of ArtMethod* |
| 662 | * x1 = "this" pointer. |
| 663 | * |
| 664 | */ |
| 665 | ENTRY art_quick_invoke_stub |
| 666 | // Spill registers as per AACPS64 calling convention. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 667 | INVOKE_STUB_CREATE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 668 | |
| 669 | // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. |
| 670 | // Parse the passed shorty to determine which register to load. |
| 671 | // Load addresses for routines that load WXSD registers. |
| 672 | adr x11, .LstoreW2 |
| 673 | adr x12, .LstoreX2 |
| 674 | adr x13, .LstoreS0 |
| 675 | adr x14, .LstoreD0 |
| 676 | |
| 677 | // Initialize routine offsets to 0 for integers and floats. |
| 678 | // x8 for integers, x15 for floating point. |
| 679 | mov x8, #0 |
| 680 | mov x15, #0 |
| 681 | |
| 682 | add x10, x5, #1 // Load shorty address, plus one to skip return value. |
| 683 | ldr w1, [x9],#4 // Load "this" parameter, and increment arg pointer. |
| 684 | |
| 685 | // Loop to fill registers. |
| 686 | .LfillRegisters: |
| 687 | ldrb w17, [x10], #1 // Load next character in signature, and increment. |
| 688 | cbz w17, .LcallFunction // Exit at end of signature. Shorty 0 terminated. |
| 689 | |
| 690 | cmp w17, #'F' // is this a float? |
| 691 | bne .LisDouble |
| 692 | |
| 693 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 694 | beq .Ladvance4 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 695 | |
| 696 | add x17, x13, x15 // Calculate subroutine to jump to. |
| 697 | br x17 |
| 698 | |
| 699 | .LisDouble: |
| 700 | cmp w17, #'D' // is this a double? |
| 701 | bne .LisLong |
| 702 | |
| 703 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 704 | beq .Ladvance8 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 705 | |
| 706 | add x17, x14, x15 // Calculate subroutine to jump to. |
| 707 | br x17 |
| 708 | |
| 709 | .LisLong: |
| 710 | cmp w17, #'J' // is this a long? |
| 711 | bne .LisOther |
| 712 | |
Andreas Gampe | 9de65ff | 2014-03-21 17:25:57 -0700 | [diff] [blame] | 713 | cmp x8, # 6*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 714 | beq .Ladvance8 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 715 | |
| 716 | add x17, x12, x8 // Calculate subroutine to jump to. |
| 717 | br x17 |
| 718 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 719 | .LisOther: // Everything else takes one vReg. |
Andreas Gampe | 9de65ff | 2014-03-21 17:25:57 -0700 | [diff] [blame] | 720 | cmp x8, # 6*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 721 | beq .Ladvance4 |
| 722 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 723 | add x17, x11, x8 // Calculate subroutine to jump to. |
| 724 | br x17 |
| 725 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 726 | .Ladvance4: |
| 727 | add x9, x9, #4 |
| 728 | b .LfillRegisters |
| 729 | |
| 730 | .Ladvance8: |
| 731 | add x9, x9, #8 |
| 732 | b .LfillRegisters |
| 733 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 734 | // Macro for loading a parameter into a register. |
| 735 | // counter - the register with offset into these tables |
| 736 | // size - the size of the register - 4 or 8 bytes. |
| 737 | // register - the name of the register to be loaded. |
| 738 | .macro LOADREG counter size register return |
| 739 | ldr \register , [x9], #\size |
| 740 | add \counter, \counter, 12 |
| 741 | b \return |
| 742 | .endm |
| 743 | |
| 744 | // Store ints. |
| 745 | .LstoreW2: |
| 746 | LOADREG x8 4 w2 .LfillRegisters |
| 747 | LOADREG x8 4 w3 .LfillRegisters |
| 748 | LOADREG x8 4 w4 .LfillRegisters |
| 749 | LOADREG x8 4 w5 .LfillRegisters |
| 750 | LOADREG x8 4 w6 .LfillRegisters |
| 751 | LOADREG x8 4 w7 .LfillRegisters |
| 752 | |
| 753 | // Store longs. |
| 754 | .LstoreX2: |
| 755 | LOADREG x8 8 x2 .LfillRegisters |
| 756 | LOADREG x8 8 x3 .LfillRegisters |
| 757 | LOADREG x8 8 x4 .LfillRegisters |
| 758 | LOADREG x8 8 x5 .LfillRegisters |
| 759 | LOADREG x8 8 x6 .LfillRegisters |
| 760 | LOADREG x8 8 x7 .LfillRegisters |
| 761 | |
| 762 | // Store singles. |
| 763 | .LstoreS0: |
| 764 | LOADREG x15 4 s0 .LfillRegisters |
| 765 | LOADREG x15 4 s1 .LfillRegisters |
| 766 | LOADREG x15 4 s2 .LfillRegisters |
| 767 | LOADREG x15 4 s3 .LfillRegisters |
| 768 | LOADREG x15 4 s4 .LfillRegisters |
| 769 | LOADREG x15 4 s5 .LfillRegisters |
| 770 | LOADREG x15 4 s6 .LfillRegisters |
| 771 | LOADREG x15 4 s7 .LfillRegisters |
| 772 | |
| 773 | // Store doubles. |
| 774 | .LstoreD0: |
| 775 | LOADREG x15 8 d0 .LfillRegisters |
| 776 | LOADREG x15 8 d1 .LfillRegisters |
| 777 | LOADREG x15 8 d2 .LfillRegisters |
| 778 | LOADREG x15 8 d3 .LfillRegisters |
| 779 | LOADREG x15 8 d4 .LfillRegisters |
| 780 | LOADREG x15 8 d5 .LfillRegisters |
| 781 | LOADREG x15 8 d6 .LfillRegisters |
| 782 | LOADREG x15 8 d7 .LfillRegisters |
| 783 | |
| 784 | |
| 785 | .LcallFunction: |
| 786 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 787 | INVOKE_STUB_CALL_AND_RETURN |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 788 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 789 | END art_quick_invoke_stub |
| 790 | |
| 791 | /* extern"C" |
| 792 | * void art_quick_invoke_static_stub(ArtMethod *method, x0 |
| 793 | * uint32_t *args, x1 |
| 794 | * uint32_t argsize, w2 |
| 795 | * Thread *self, x3 |
| 796 | * JValue *result, x4 |
| 797 | * char *shorty); x5 |
| 798 | */ |
| 799 | ENTRY art_quick_invoke_static_stub |
| 800 | // Spill registers as per AACPS64 calling convention. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 801 | INVOKE_STUB_CREATE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 802 | |
| 803 | // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. |
| 804 | // Parse the passed shorty to determine which register to load. |
| 805 | // Load addresses for routines that load WXSD registers. |
| 806 | adr x11, .LstoreW1_2 |
| 807 | adr x12, .LstoreX1_2 |
| 808 | adr x13, .LstoreS0_2 |
| 809 | adr x14, .LstoreD0_2 |
| 810 | |
| 811 | // Initialize routine offsets to 0 for integers and floats. |
| 812 | // x8 for integers, x15 for floating point. |
| 813 | mov x8, #0 |
| 814 | mov x15, #0 |
| 815 | |
| 816 | add x10, x5, #1 // Load shorty address, plus one to skip return value. |
| 817 | |
| 818 | // Loop to fill registers. |
| 819 | .LfillRegisters2: |
| 820 | ldrb w17, [x10], #1 // Load next character in signature, and increment. |
| 821 | cbz w17, .LcallFunction2 // Exit at end of signature. Shorty 0 terminated. |
| 822 | |
| 823 | cmp w17, #'F' // is this a float? |
| 824 | bne .LisDouble2 |
| 825 | |
| 826 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 827 | beq .Ladvance4_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 828 | |
| 829 | add x17, x13, x15 // Calculate subroutine to jump to. |
| 830 | br x17 |
| 831 | |
| 832 | .LisDouble2: |
| 833 | cmp w17, #'D' // is this a double? |
| 834 | bne .LisLong2 |
| 835 | |
| 836 | cmp x15, # 8*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 837 | beq .Ladvance8_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 838 | |
| 839 | add x17, x14, x15 // Calculate subroutine to jump to. |
| 840 | br x17 |
| 841 | |
| 842 | .LisLong2: |
| 843 | cmp w17, #'J' // is this a long? |
| 844 | bne .LisOther2 |
| 845 | |
| 846 | cmp x8, # 7*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 847 | beq .Ladvance8_2 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 848 | |
| 849 | add x17, x12, x8 // Calculate subroutine to jump to. |
| 850 | br x17 |
| 851 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 852 | .LisOther2: // Everything else takes one vReg. |
| 853 | cmp x8, # 7*12 // Skip this load if all registers full. |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 854 | beq .Ladvance4_2 |
| 855 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 856 | add x17, x11, x8 // Calculate subroutine to jump to. |
| 857 | br x17 |
| 858 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 859 | .Ladvance4_2: |
| 860 | add x9, x9, #4 |
| 861 | b .LfillRegisters2 |
| 862 | |
| 863 | .Ladvance8_2: |
| 864 | add x9, x9, #8 |
| 865 | b .LfillRegisters2 |
| 866 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 867 | // Store ints. |
| 868 | .LstoreW1_2: |
| 869 | LOADREG x8 4 w1 .LfillRegisters2 |
| 870 | LOADREG x8 4 w2 .LfillRegisters2 |
| 871 | LOADREG x8 4 w3 .LfillRegisters2 |
| 872 | LOADREG x8 4 w4 .LfillRegisters2 |
| 873 | LOADREG x8 4 w5 .LfillRegisters2 |
| 874 | LOADREG x8 4 w6 .LfillRegisters2 |
| 875 | LOADREG x8 4 w7 .LfillRegisters2 |
| 876 | |
| 877 | // Store longs. |
| 878 | .LstoreX1_2: |
| 879 | LOADREG x8 8 x1 .LfillRegisters2 |
| 880 | LOADREG x8 8 x2 .LfillRegisters2 |
| 881 | LOADREG x8 8 x3 .LfillRegisters2 |
| 882 | LOADREG x8 8 x4 .LfillRegisters2 |
| 883 | LOADREG x8 8 x5 .LfillRegisters2 |
| 884 | LOADREG x8 8 x6 .LfillRegisters2 |
| 885 | LOADREG x8 8 x7 .LfillRegisters2 |
| 886 | |
| 887 | // Store singles. |
| 888 | .LstoreS0_2: |
| 889 | LOADREG x15 4 s0 .LfillRegisters2 |
| 890 | LOADREG x15 4 s1 .LfillRegisters2 |
| 891 | LOADREG x15 4 s2 .LfillRegisters2 |
| 892 | LOADREG x15 4 s3 .LfillRegisters2 |
| 893 | LOADREG x15 4 s4 .LfillRegisters2 |
| 894 | LOADREG x15 4 s5 .LfillRegisters2 |
| 895 | LOADREG x15 4 s6 .LfillRegisters2 |
| 896 | LOADREG x15 4 s7 .LfillRegisters2 |
| 897 | |
| 898 | // Store doubles. |
| 899 | .LstoreD0_2: |
| 900 | LOADREG x15 8 d0 .LfillRegisters2 |
| 901 | LOADREG x15 8 d1 .LfillRegisters2 |
| 902 | LOADREG x15 8 d2 .LfillRegisters2 |
| 903 | LOADREG x15 8 d3 .LfillRegisters2 |
| 904 | LOADREG x15 8 d4 .LfillRegisters2 |
| 905 | LOADREG x15 8 d5 .LfillRegisters2 |
| 906 | LOADREG x15 8 d6 .LfillRegisters2 |
| 907 | LOADREG x15 8 d7 .LfillRegisters2 |
| 908 | |
| 909 | |
| 910 | .LcallFunction2: |
| 911 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 912 | INVOKE_STUB_CALL_AND_RETURN |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 913 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 914 | END art_quick_invoke_static_stub |
| 915 | |
Andreas Gampe | 03906cf | 2014-04-07 12:08:28 -0700 | [diff] [blame] | 916 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 917 | |
| 918 | /* |
| 919 | * On entry x0 is uintptr_t* gprs_ and x1 is uint64_t* fprs_ |
| 920 | */ |
| 921 | |
| 922 | ENTRY art_quick_do_long_jump |
| 923 | // Load FPRs |
| 924 | ldp d0, d1, [x1], #16 |
| 925 | ldp d2, d3, [x1], #16 |
| 926 | ldp d4, d5, [x1], #16 |
| 927 | ldp d6, d7, [x1], #16 |
| 928 | ldp d8, d9, [x1], #16 |
| 929 | ldp d10, d11, [x1], #16 |
| 930 | ldp d12, d13, [x1], #16 |
| 931 | ldp d14, d15, [x1], #16 |
| 932 | ldp d16, d17, [x1], #16 |
| 933 | ldp d18, d19, [x1], #16 |
| 934 | ldp d20, d21, [x1], #16 |
| 935 | ldp d22, d23, [x1], #16 |
| 936 | ldp d24, d25, [x1], #16 |
| 937 | ldp d26, d27, [x1], #16 |
| 938 | ldp d28, d29, [x1], #16 |
| 939 | ldp d30, d31, [x1] |
| 940 | |
| 941 | // Load GPRs |
| 942 | // TODO: lots of those are smashed, could optimize. |
| 943 | add x0, x0, #30*8 |
| 944 | ldp x30, x1, [x0], #-16 |
| 945 | ldp x28, x29, [x0], #-16 |
| 946 | ldp x26, x27, [x0], #-16 |
| 947 | ldp x24, x25, [x0], #-16 |
| 948 | ldp x22, x23, [x0], #-16 |
| 949 | ldp x20, x21, [x0], #-16 |
| 950 | ldp x18, x19, [x0], #-16 |
| 951 | ldp x16, x17, [x0], #-16 |
| 952 | ldp x14, x15, [x0], #-16 |
| 953 | ldp x12, x13, [x0], #-16 |
| 954 | ldp x10, x11, [x0], #-16 |
| 955 | ldp x8, x9, [x0], #-16 |
| 956 | ldp x6, x7, [x0], #-16 |
| 957 | ldp x4, x5, [x0], #-16 |
| 958 | ldp x2, x3, [x0], #-16 |
| 959 | mov sp, x1 |
| 960 | |
| 961 | // TODO: Is it really OK to use LR for the target PC? |
| 962 | mov x0, #0 |
| 963 | mov x1, #0 |
| 964 | br xLR |
| 965 | END art_quick_do_long_jump |
| 966 | |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 967 | /* |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 968 | * Entry from managed code that calls artLockObjectFromCode, may block for GC. x0 holds the |
| 969 | * possibly null object to lock. |
| 970 | * |
| 971 | * Derived from arm32 code. |
| 972 | */ |
| 973 | .extern artLockObjectFromCode |
| 974 | ENTRY art_quick_lock_object |
| 975 | cbz w0, .Lslow_lock |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 976 | add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 977 | .Lretry_lock: |
| 978 | ldr w2, [xSELF, #THREAD_ID_OFFSET] // TODO: Can the thread ID really change during the loop? |
| 979 | ldxr w1, [x4] |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 980 | mov x3, x1 |
| 981 | and w3, w3, #LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED // zero the read barrier bits |
| 982 | cbnz w3, .Lnot_unlocked // already thin locked |
| 983 | // unlocked case - x1: original lock word that's zero except for the read barrier bits. |
| 984 | orr x2, x1, x2 // x2 holds thread id with count of 0 with preserved read barrier bits |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 985 | stxr w3, w2, [x4] |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 986 | cbnz w3, .Llock_stxr_fail // store failed, retry |
Andreas Gampe | 675967d | 2014-05-14 16:28:34 -0700 | [diff] [blame] | 987 | dmb ishld // full (LoadLoad|LoadStore) memory barrier |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 988 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 989 | .Lnot_unlocked: // x1: original lock word |
| 990 | lsr w3, w1, LOCK_WORD_STATE_SHIFT |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 991 | cbnz w3, .Lslow_lock // if either of the top two bits are set, go slow path |
| 992 | eor w2, w1, w2 // lock_word.ThreadId() ^ self->ThreadId() |
| 993 | uxth w2, w2 // zero top 16 bits |
| 994 | cbnz w2, .Lslow_lock // lock word and self thread id's match -> recursive lock |
| 995 | // else contention, go to slow path |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 996 | mov x3, x1 // copy the lock word to check count overflow. |
| 997 | and w3, w3, #LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED // zero the read barrier bits. |
| 998 | add w2, w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count in lock word placing in w2 to check overflow |
| 999 | lsr w3, w2, LOCK_WORD_READ_BARRIER_STATE_SHIFT // if either of the upper two bits (28-29) are set, we overflowed. |
| 1000 | cbnz w3, .Lslow_lock // if we overflow the count go slow path |
| 1001 | add w2, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count for real |
| 1002 | stxr w3, w2, [x4] |
| 1003 | cbnz w3, .Llock_stxr_fail // store failed, retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1004 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1005 | .Llock_stxr_fail: |
| 1006 | b .Lretry_lock // retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1007 | .Lslow_lock: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1008 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case we block |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1009 | mov x1, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1010 | bl artLockObjectFromCode // (Object* obj, Thread*) |
| 1011 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1012 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1013 | END art_quick_lock_object |
| 1014 | |
| 1015 | /* |
| 1016 | * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. |
| 1017 | * x0 holds the possibly null object to lock. |
| 1018 | * |
| 1019 | * Derived from arm32 code. |
| 1020 | */ |
| 1021 | .extern artUnlockObjectFromCode |
| 1022 | ENTRY art_quick_unlock_object |
| 1023 | cbz x0, .Lslow_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1024 | add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore |
| 1025 | .Lretry_unlock: |
| 1026 | #ifndef USE_READ_BARRIER |
| 1027 | ldr w1, [x4] |
| 1028 | #else |
| 1029 | ldxr w1, [x4] // Need to use atomic instructions for read barrier |
| 1030 | #endif |
| 1031 | lsr w2, w1, LOCK_WORD_STATE_SHIFT |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1032 | cbnz w2, .Lslow_unlock // if either of the top two bits are set, go slow path |
| 1033 | ldr w2, [xSELF, #THREAD_ID_OFFSET] |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1034 | mov x3, x1 // copy lock word to check thread id equality |
| 1035 | and w3, w3, #LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED // zero the read barrier bits |
| 1036 | eor w3, w3, w2 // lock_word.ThreadId() ^ self->ThreadId() |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1037 | uxth w3, w3 // zero top 16 bits |
| 1038 | cbnz w3, .Lslow_unlock // do lock word and self thread id's match? |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1039 | mov x3, x1 // copy lock word to detect transition to unlocked |
| 1040 | and w3, w3, #LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED // zero the read barrier bits |
| 1041 | cmp w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1042 | bpl .Lrecursive_thin_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1043 | // transition to unlocked |
| 1044 | mov x3, x1 |
| 1045 | and w3, w3, #LOCK_WORD_READ_BARRIER_STATE_MASK // w3: zero except for the preserved read barrier bits |
Andreas Gampe | 675967d | 2014-05-14 16:28:34 -0700 | [diff] [blame] | 1046 | dmb ish // full (LoadStore|StoreStore) memory barrier |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1047 | #ifndef USE_READ_BARRIER |
| 1048 | str w3, [x4] |
| 1049 | #else |
| 1050 | stxr w2, w3, [x4] // Need to use atomic instructions for read barrier |
| 1051 | cbnz w2, .Lunlock_stxr_fail // store failed, retry |
| 1052 | #endif |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1053 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1054 | .Lrecursive_thin_unlock: // w1: original lock word |
| 1055 | sub w1, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // decrement count |
| 1056 | #ifndef USE_READ_BARRIER |
| 1057 | str w1, [x4] |
| 1058 | #else |
| 1059 | stxr w2, w1, [x4] // Need to use atomic instructions for read barrier |
| 1060 | cbnz w2, .Lunlock_stxr_fail // store failed, retry |
| 1061 | #endif |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1062 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1063 | .Lunlock_stxr_fail: |
| 1064 | b .Lretry_unlock // retry |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1065 | .Lslow_unlock: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1066 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case exception allocation triggers GC |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1067 | mov x1, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1068 | bl artUnlockObjectFromCode // (Object* obj, Thread*) |
| 1069 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 4fc046e | 2014-05-06 16:56:39 -0700 | [diff] [blame] | 1070 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1071 | END art_quick_unlock_object |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1072 | |
| 1073 | /* |
| 1074 | * Entry from managed code that calls artIsAssignableFromCode and on failure calls |
| 1075 | * artThrowClassCastException. |
| 1076 | */ |
| 1077 | .extern artThrowClassCastException |
| 1078 | ENTRY art_quick_check_cast |
| 1079 | // Store arguments and link register |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1080 | // Stack needs to be 16B aligned on calls. |
| 1081 | stp x0, x1, [sp,#-32]! |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1082 | .cfi_adjust_cfa_offset 32 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1083 | .cfi_rel_offset x0, 0 |
| 1084 | .cfi_rel_offset x1, 8 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1085 | str xLR, [sp, #24] |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1086 | .cfi_rel_offset x30, 24 |
| 1087 | |
| 1088 | // Call runtime code |
| 1089 | bl artIsAssignableFromCode |
| 1090 | |
| 1091 | // Check for exception |
| 1092 | cbz x0, .Lthrow_class_cast_exception |
| 1093 | |
| 1094 | // Restore and return |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1095 | ldr xLR, [sp, #24] |
| 1096 | .cfi_restore x30 |
| 1097 | ldp x0, x1, [sp], #32 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1098 | .cfi_restore x0 |
| 1099 | .cfi_restore x1 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1100 | .cfi_adjust_cfa_offset -32 |
| 1101 | ret |
| 1102 | |
Andreas Gampe | 6b90d42 | 2015-06-26 19:49:24 -0700 | [diff] [blame] | 1103 | .cfi_adjust_cfa_offset 32 // Reset unwind info so following code unwinds. |
| 1104 | |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1105 | .Lthrow_class_cast_exception: |
| 1106 | // Restore |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1107 | ldr xLR, [sp, #24] |
| 1108 | .cfi_restore x30 |
| 1109 | ldp x0, x1, [sp], #32 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1110 | .cfi_restore x0 |
| 1111 | .cfi_restore x1 |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1112 | .cfi_adjust_cfa_offset -32 |
| 1113 | |
| 1114 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 1115 | mov x2, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1116 | b artThrowClassCastException // (Class*, Class*, Thread*) |
Andreas Gampe | 525cde2 | 2014-04-22 15:44:50 -0700 | [diff] [blame] | 1117 | brk 0 // We should not return here... |
| 1118 | END art_quick_check_cast |
| 1119 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1120 | // Restore xReg's value from [sp, #offset] if xReg is not the same as xExclude. |
| 1121 | .macro POP_REG_NE xReg, offset, xExclude |
| 1122 | .ifnc \xReg, \xExclude |
| 1123 | ldr \xReg, [sp, #\offset] // restore xReg |
| 1124 | .cfi_restore \xReg |
| 1125 | .endif |
| 1126 | .endm |
| 1127 | |
| 1128 | /* |
| 1129 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1130 | * xDest, wDest and xObj are registers, offset is a defined literal such as |
| 1131 | * MIRROR_OBJECT_CLASS_OFFSET. Dest needs both x and w versions of the same register to handle |
| 1132 | * name mismatch between instructions. This macro uses the lower 32b of register when possible. |
| 1133 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1134 | */ |
| 1135 | .macro READ_BARRIER xDest, wDest, xObj, offset |
| 1136 | #ifdef USE_READ_BARRIER |
| 1137 | // Store registers used in art_quick_aput_obj (x0-x4, LR), stack is 16B aligned. |
| 1138 | stp x0, x1, [sp, #-48]! |
| 1139 | .cfi_adjust_cfa_offset 48 |
| 1140 | .cfi_rel_offset x0, 0 |
| 1141 | .cfi_rel_offset x1, 8 |
| 1142 | stp x2, x3, [sp, #16] |
| 1143 | .cfi_rel_offset x2, 16 |
| 1144 | .cfi_rel_offset x3, 24 |
| 1145 | stp x4, xLR, [sp, #32] |
| 1146 | .cfi_rel_offset x4, 32 |
| 1147 | .cfi_rel_offset x30, 40 |
| 1148 | |
| 1149 | // mov x0, x0 // pass ref in x0 (no-op for now since parameter ref is unused) |
| 1150 | .ifnc \xObj, x1 |
| 1151 | mov x1, \xObj // pass xObj |
| 1152 | .endif |
| 1153 | mov w2, #\offset // pass offset |
| 1154 | bl artReadBarrierSlow // artReadBarrierSlow(ref, xObj, offset) |
| 1155 | // No need to unpoison return value in w0, artReadBarrierSlow() would do the unpoisoning. |
| 1156 | .ifnc \wDest, w0 |
| 1157 | mov \wDest, w0 // save return value in wDest |
| 1158 | .endif |
| 1159 | |
| 1160 | // Conditionally restore saved registers |
| 1161 | POP_REG_NE x0, 0, \xDest |
| 1162 | POP_REG_NE x1, 8, \xDest |
| 1163 | POP_REG_NE x2, 16, \xDest |
| 1164 | POP_REG_NE x3, 24, \xDest |
| 1165 | POP_REG_NE x4, 32, \xDest |
| 1166 | ldr xLR, [sp, #40] |
| 1167 | .cfi_restore x30 |
| 1168 | add sp, sp, #48 |
| 1169 | .cfi_adjust_cfa_offset -48 |
| 1170 | #else |
| 1171 | ldr \wDest, [\xObj, #\offset] // Heap reference = 32b. This also zero-extends to \xDest. |
| 1172 | UNPOISON_HEAP_REF \wDest |
| 1173 | #endif // USE_READ_BARRIER |
| 1174 | .endm |
| 1175 | |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1176 | /* |
| 1177 | * Entry from managed code for array put operations of objects where the value being stored |
| 1178 | * needs to be checked for compatibility. |
| 1179 | * x0 = array, x1 = index, x2 = value |
| 1180 | * |
| 1181 | * Currently all values should fit into w0/w1/w2, and w1 always will as indices are 32b. We |
| 1182 | * assume, though, that the upper 32b are zeroed out. At least for x1/w1 we can do better by |
| 1183 | * using index-zero-extension in load/stores. |
| 1184 | * |
| 1185 | * Temporaries: x3, x4 |
| 1186 | * TODO: x4 OK? ip seems wrong here. |
| 1187 | */ |
| 1188 | ENTRY art_quick_aput_obj_with_null_and_bound_check |
| 1189 | tst x0, x0 |
| 1190 | bne art_quick_aput_obj_with_bound_check |
| 1191 | b art_quick_throw_null_pointer_exception |
| 1192 | END art_quick_aput_obj_with_null_and_bound_check |
| 1193 | |
| 1194 | ENTRY art_quick_aput_obj_with_bound_check |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1195 | ldr w3, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1196 | cmp w3, w1 |
| 1197 | bhi art_quick_aput_obj |
| 1198 | mov x0, x1 |
| 1199 | mov x1, x3 |
| 1200 | b art_quick_throw_array_bounds |
| 1201 | END art_quick_aput_obj_with_bound_check |
| 1202 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1203 | #ifdef USE_READ_BARRIER |
| 1204 | .extern artReadBarrierSlow |
| 1205 | #endif |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1206 | ENTRY art_quick_aput_obj |
| 1207 | cbz x2, .Ldo_aput_null |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1208 | READ_BARRIER x3, w3, x0, MIRROR_OBJECT_CLASS_OFFSET // Heap reference = 32b |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1209 | // This also zero-extends to x3 |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1210 | READ_BARRIER x4, w4, x2, MIRROR_OBJECT_CLASS_OFFSET // Heap reference = 32b |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1211 | // This also zero-extends to x4 |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1212 | READ_BARRIER x3, w3, x3, MIRROR_CLASS_COMPONENT_TYPE_OFFSET // Heap reference = 32b |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1213 | // This also zero-extends to x3 |
| 1214 | cmp w3, w4 // value's type == array's component type - trivial assignability |
| 1215 | bne .Lcheck_assignability |
| 1216 | .Ldo_aput: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1217 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1218 | // "Compress" = do nothing |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1219 | POISON_HEAP_REF w2 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1220 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1221 | ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET] |
| 1222 | lsr x0, x0, #7 |
| 1223 | strb w3, [x3, x0] |
| 1224 | ret |
| 1225 | .Ldo_aput_null: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1226 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1227 | // "Compress" = do nothing |
| 1228 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1229 | ret |
| 1230 | .Lcheck_assignability: |
| 1231 | // Store arguments and link register |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1232 | stp x0, x1, [sp,#-32]! |
| 1233 | .cfi_adjust_cfa_offset 32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1234 | .cfi_rel_offset x0, 0 |
| 1235 | .cfi_rel_offset x1, 8 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1236 | stp x2, xLR, [sp, #16] |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1237 | .cfi_rel_offset x2, 16 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1238 | .cfi_rel_offset x30, 24 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1239 | |
| 1240 | // Call runtime code |
| 1241 | mov x0, x3 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended |
| 1242 | mov x1, x4 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended |
| 1243 | bl artIsAssignableFromCode |
| 1244 | |
| 1245 | // Check for exception |
| 1246 | cbz x0, .Lthrow_array_store_exception |
| 1247 | |
| 1248 | // Restore |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1249 | ldp x2, x30, [sp, #16] |
| 1250 | .cfi_restore x2 |
| 1251 | .cfi_restore x30 |
| 1252 | ldp x0, x1, [sp], #32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1253 | .cfi_restore x0 |
| 1254 | .cfi_restore x1 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1255 | .cfi_adjust_cfa_offset -32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1256 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1257 | add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1258 | // "Compress" = do nothing |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1259 | POISON_HEAP_REF w2 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1260 | str w2, [x3, x1, lsl #2] // Heap reference = 32b |
| 1261 | ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET] |
| 1262 | lsr x0, x0, #7 |
| 1263 | strb w3, [x3, x0] |
| 1264 | ret |
Mathieu Chartier | 2738639 | 2015-06-27 15:42:27 -0700 | [diff] [blame] | 1265 | .cfi_adjust_cfa_offset 32 // 4 restores after cbz for unwinding. |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1266 | .Lthrow_array_store_exception: |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1267 | ldp x2, x30, [sp, #16] |
| 1268 | .cfi_restore x2 |
| 1269 | .cfi_restore x30 |
| 1270 | ldp x0, x1, [sp], #32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1271 | .cfi_restore x0 |
| 1272 | .cfi_restore x1 |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1273 | .cfi_adjust_cfa_offset -32 |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1274 | |
| 1275 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1276 | mov x1, x2 // Pass value. |
| 1277 | mov x2, xSELF // Pass Thread::Current. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1278 | b artThrowArrayStoreException // (Object*, Object*, Thread*). |
Andreas Gampe | f4e910b | 2014-04-29 16:55:52 -0700 | [diff] [blame] | 1279 | brk 0 // Unreached. |
| 1280 | END art_quick_aput_obj |
| 1281 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1282 | // Macro to facilitate adding new allocation entrypoints. |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1283 | .macro ONE_ARG_DOWNCALL name, entrypoint, return |
| 1284 | .extern \entrypoint |
| 1285 | ENTRY \name |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1286 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1287 | mov x1, xSELF // pass Thread::Current |
| 1288 | bl \entrypoint // (uint32_t type_idx, Method* method, Thread*) |
| 1289 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1290 | \return |
| 1291 | END \name |
| 1292 | .endm |
| 1293 | |
| 1294 | // Macro to facilitate adding new allocation entrypoints. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1295 | .macro TWO_ARG_DOWNCALL name, entrypoint, return |
| 1296 | .extern \entrypoint |
| 1297 | ENTRY \name |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1298 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1299 | mov x2, xSELF // pass Thread::Current |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1300 | bl \entrypoint // (uint32_t type_idx, Method* method, Thread*) |
| 1301 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1302 | \return |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1303 | END \name |
| 1304 | .endm |
| 1305 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1306 | // Macro to facilitate adding new allocation entrypoints. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1307 | .macro THREE_ARG_DOWNCALL name, entrypoint, return |
| 1308 | .extern \entrypoint |
| 1309 | ENTRY \name |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1310 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1311 | mov x3, xSELF // pass Thread::Current |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1312 | bl \entrypoint |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1313 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 00c1e6d | 2014-04-25 15:47:13 -0700 | [diff] [blame] | 1314 | \return |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1315 | END \name |
| 1316 | .endm |
| 1317 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1318 | // Macro to facilitate adding new allocation entrypoints. |
| 1319 | .macro FOUR_ARG_DOWNCALL name, entrypoint, return |
| 1320 | .extern \entrypoint |
| 1321 | ENTRY \name |
| 1322 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
| 1323 | mov x4, xSELF // pass Thread::Current |
| 1324 | bl \entrypoint // |
| 1325 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
| 1326 | \return |
| 1327 | DELIVER_PENDING_EXCEPTION |
| 1328 | END \name |
| 1329 | .endm |
| 1330 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1331 | // Macros taking opportunity of code similarities for downcalls with referrer. |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1332 | .macro ONE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1333 | .extern \entrypoint |
| 1334 | ENTRY \name |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1335 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1336 | ldr x1, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1337 | mov x2, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1338 | bl \entrypoint // (uint32_t type_idx, Method* method, Thread*, SP) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1339 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1340 | \return |
| 1341 | END \name |
| 1342 | .endm |
| 1343 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1344 | .macro TWO_ARG_REF_DOWNCALL name, entrypoint, return |
| 1345 | .extern \entrypoint |
| 1346 | ENTRY \name |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1347 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1348 | ldr x2, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1349 | mov x3, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1350 | bl \entrypoint |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1351 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1352 | \return |
| 1353 | END \name |
| 1354 | .endm |
| 1355 | |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1356 | .macro THREE_ARG_REF_DOWNCALL name, entrypoint, return |
| 1357 | .extern \entrypoint |
| 1358 | ENTRY \name |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1359 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1360 | ldr x3, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1361 | mov x4, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1362 | bl \entrypoint |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1363 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1364 | \return |
| 1365 | END \name |
| 1366 | .endm |
| 1367 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 1368 | .macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1369 | cbz w0, 1f // result zero branch over |
| 1370 | ret // return |
| 1371 | 1: |
| 1372 | DELIVER_PENDING_EXCEPTION |
| 1373 | .endm |
| 1374 | |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1375 | /* |
Vladimir Marko | 3b37073 | 2014-10-09 18:34:28 +0100 | [diff] [blame] | 1376 | * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on |
| 1377 | * failure. |
| 1378 | */ |
| 1379 | TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1380 | |
| 1381 | /* |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1382 | * Entry from managed code when uninitialized static storage, this stub will run the class |
| 1383 | * initializer and deliver the exception on error. On success the static storage base is |
| 1384 | * returned. |
| 1385 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1386 | ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1387 | |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1388 | ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1389 | ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1390 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1391 | ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1392 | ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1393 | ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1394 | ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1395 | ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1396 | ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1397 | ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1398 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1399 | TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1400 | TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1401 | TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1402 | TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1403 | TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1404 | TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1405 | TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1 |
| 1406 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1407 | TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1408 | TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1409 | TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1410 | TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1411 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1412 | THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1413 | THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1414 | THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Stephen Kyle | 0ff20d5 | 2014-10-22 15:23:46 +0100 | [diff] [blame] | 1415 | THREE_ARG_REF_DOWNCALL art_quick_set64_instance, artSet64InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1416 | THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1417 | |
| 1418 | // This is separated out as the argument order is different. |
| 1419 | .extern artSet64StaticFromCode |
| 1420 | ENTRY art_quick_set64_static |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1421 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1422 | mov x3, x1 // Store value |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1423 | ldr x1, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1424 | mov x2, x3 // Put value param |
| 1425 | mov x3, xSELF // pass Thread::Current |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1426 | bl artSet64StaticFromCode |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1427 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1428 | RETURN_IF_W0_IS_ZERO_OR_DELIVER |
| 1429 | END art_quick_set64_static |
| 1430 | |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1431 | /* |
| 1432 | * Entry from managed code to resolve a string, this stub will allocate a String and deliver an |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1433 | * exception on error. On success the String is returned. w0 holds the string index. The fast |
| 1434 | * path check for hit in strings cache has already been performed. |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1435 | */ |
Vladimir Marko | 5ea536a | 2015-04-20 20:11:30 +0100 | [diff] [blame] | 1436 | ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Andreas Gampe | 6e4e59c | 2014-05-05 20:11:02 -0700 | [diff] [blame] | 1437 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1438 | // Generate the allocation entrypoints for each allocator. |
| 1439 | GENERATE_ALL_ALLOC_ENTRYPOINTS |
| 1440 | |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1441 | /* |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 1442 | * Called by managed code when the thread has been asked to suspend. |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1443 | */ |
| 1444 | .extern artTestSuspendFromCode |
| 1445 | ENTRY art_quick_test_suspend |
| 1446 | ldrh w0, [xSELF, #THREAD_FLAGS_OFFSET] // get xSELF->state_and_flags.as_struct.flags |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1447 | cbnz w0, .Lneed_suspend // check flags == 0 |
| 1448 | ret // return if flags == 0 |
| 1449 | .Lneed_suspend: |
| 1450 | mov x0, xSELF |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1451 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves for stack crawl |
| 1452 | bl artTestSuspendFromCode // (Thread*) |
| 1453 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
Zheng Xu | 48241e7 | 2014-05-23 11:52:42 +0800 | [diff] [blame] | 1454 | END art_quick_test_suspend |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1455 | |
Stuart Monteith | d5c78f4 | 2014-06-11 16:44:46 +0100 | [diff] [blame] | 1456 | ENTRY art_quick_implicit_suspend |
| 1457 | mov x0, xSELF |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1458 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME // save callee saves for stack crawl |
| 1459 | bl artTestSuspendFromCode // (Thread*) |
| 1460 | RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN |
Stuart Monteith | d5c78f4 | 2014-06-11 16:44:46 +0100 | [diff] [blame] | 1461 | END art_quick_implicit_suspend |
| 1462 | |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1463 | /* |
| 1464 | * Called by managed code that is attempting to call a method on a proxy class. On entry |
| 1465 | * x0 holds the proxy method and x1 holds the receiver; The frame size of the invoked proxy |
| 1466 | * method agrees with a ref and args callee save frame. |
| 1467 | */ |
| 1468 | .extern artQuickProxyInvokeHandler |
| 1469 | ENTRY art_quick_proxy_invoke_handler |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1470 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_X0 |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1471 | mov x2, xSELF // pass Thread::Current |
| 1472 | mov x3, sp // pass SP |
| 1473 | bl artQuickProxyInvokeHandler // (Method* proxy method, receiver, Thread*, SP) |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1474 | ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET] |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1475 | cbnz x2, .Lexception_in_proxy // success if no exception is pending |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1476 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME // Restore frame |
Andreas Gampe | d1e9167 | 2014-06-02 22:50:05 -0700 | [diff] [blame] | 1477 | 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] | 1478 | ret // return on success |
| 1479 | .Lexception_in_proxy: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1480 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Andreas Gampe | e62a07e | 2014-03-26 14:53:21 -0700 | [diff] [blame] | 1481 | DELIVER_PENDING_EXCEPTION |
| 1482 | END art_quick_proxy_invoke_handler |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1483 | |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 1484 | /* |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1485 | * Called to resolve an imt conflict. xIP1 is a hidden argument that holds the target method's |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 1486 | * dex method index. |
| 1487 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 1488 | .extern artInvokeInterfaceTrampoline |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 1489 | ENTRY art_quick_imt_conflict_trampoline |
Nicolas Geoffray | 8ea18d0 | 2015-05-26 16:29:08 +0100 | [diff] [blame] | 1490 | mov x0, xIP1 |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 1491 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline |
Andreas Gampe | 51f7635 | 2014-05-21 08:28:48 -0700 | [diff] [blame] | 1492 | END art_quick_imt_conflict_trampoline |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1493 | |
| 1494 | ENTRY art_quick_resolution_trampoline |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1495 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1496 | mov x2, xSELF |
| 1497 | mov x3, sp |
| 1498 | bl artQuickResolutionTrampoline // (called, receiver, Thread*, SP) |
Matteo Franchin | dfd891a | 2014-04-30 12:17:17 +0100 | [diff] [blame] | 1499 | cbz x0, 1f |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1500 | mov xIP0, x0 // Remember returned code pointer in xIP0. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1501 | ldr x0, [sp, #0] // artQuickResolutionTrampoline puts called method in *SP. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1502 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1503 | br xIP0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1504 | 1: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1505 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1506 | DELIVER_PENDING_EXCEPTION |
| 1507 | END art_quick_resolution_trampoline |
| 1508 | |
| 1509 | /* |
| 1510 | * Generic JNI frame layout: |
| 1511 | * |
| 1512 | * #-------------------# |
| 1513 | * | | |
| 1514 | * | caller method... | |
| 1515 | * #-------------------# <--- SP on entry |
| 1516 | * | Return X30/LR | |
| 1517 | * | X29/FP | callee save |
| 1518 | * | X28 | callee save |
| 1519 | * | X27 | callee save |
| 1520 | * | X26 | callee save |
| 1521 | * | X25 | callee save |
| 1522 | * | X24 | callee save |
| 1523 | * | X23 | callee save |
| 1524 | * | X22 | callee save |
| 1525 | * | X21 | callee save |
| 1526 | * | X20 | callee save |
Zheng Xu | 69a5030 | 2015-04-14 20:04:41 +0800 | [diff] [blame] | 1527 | * | X19 | callee save |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1528 | * | X7 | arg7 |
| 1529 | * | X6 | arg6 |
| 1530 | * | X5 | arg5 |
| 1531 | * | X4 | arg4 |
| 1532 | * | X3 | arg3 |
| 1533 | * | X2 | arg2 |
| 1534 | * | X1 | arg1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1535 | * | D7 | float arg 8 |
| 1536 | * | D6 | float arg 7 |
| 1537 | * | D5 | float arg 6 |
| 1538 | * | D4 | float arg 5 |
| 1539 | * | D3 | float arg 4 |
| 1540 | * | D2 | float arg 3 |
| 1541 | * | D1 | float arg 2 |
| 1542 | * | D0 | float arg 1 |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1543 | * | Method* | <- X0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1544 | * #-------------------# |
| 1545 | * | local ref cookie | // 4B |
Mathieu Chartier | 421c537 | 2014-05-14 14:11:40 -0700 | [diff] [blame] | 1546 | * | handle scope size | // 4B |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1547 | * #-------------------# |
| 1548 | * | JNI Call Stack | |
| 1549 | * #-------------------# <--- SP on native call |
| 1550 | * | | |
| 1551 | * | Stack for Regs | The trampoline assembly will pop these values |
| 1552 | * | | into registers for native call |
| 1553 | * #-------------------# |
| 1554 | * | Native code ptr | |
| 1555 | * #-------------------# |
| 1556 | * | Free scratch | |
| 1557 | * #-------------------# |
| 1558 | * | Ptr to (1) | <--- SP |
| 1559 | * #-------------------# |
| 1560 | */ |
| 1561 | /* |
| 1562 | * Called to do a generic JNI down-call |
| 1563 | */ |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 1564 | ENTRY art_quick_generic_jni_trampoline |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1565 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_X0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1566 | |
| 1567 | // Save SP , so we can have static CFI info. |
| 1568 | mov x28, sp |
| 1569 | .cfi_def_cfa_register x28 |
| 1570 | |
| 1571 | // 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] | 1572 | // of the frame when the handle scope is inserted. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1573 | mov xFP, sp |
| 1574 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1575 | mov xIP0, #5120 |
| 1576 | sub sp, sp, xIP0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1577 | |
| 1578 | // prepare for artQuickGenericJniTrampoline call |
| 1579 | // (Thread*, SP) |
| 1580 | // x0 x1 <= C calling convention |
| 1581 | // xSELF xFP <= where they are |
| 1582 | |
| 1583 | mov x0, xSELF // Thread* |
| 1584 | mov x1, xFP |
| 1585 | bl artQuickGenericJniTrampoline // (Thread*, sp) |
| 1586 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1587 | // The C call will have registered the complete save-frame on success. |
| 1588 | // The result of the call is: |
| 1589 | // x0: pointer to native code, 0 on error. |
| 1590 | // 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] | 1591 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1592 | // Check for error = 0. |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1593 | cbz x0, .Lexception_in_native |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1594 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1595 | // Release part of the alloca. |
| 1596 | mov sp, x1 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1597 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1598 | // Save the code pointer |
| 1599 | mov xIP0, x0 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1600 | |
| 1601 | // Load parameters from frame into registers. |
| 1602 | // TODO Check with artQuickGenericJniTrampoline. |
| 1603 | // Also, check again APPCS64 - the stack arguments are interleaved. |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1604 | ldp x0, x1, [sp] |
| 1605 | ldp x2, x3, [sp, #16] |
| 1606 | ldp x4, x5, [sp, #32] |
| 1607 | ldp x6, x7, [sp, #48] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1608 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1609 | ldp d0, d1, [sp, #64] |
| 1610 | ldp d2, d3, [sp, #80] |
| 1611 | ldp d4, d5, [sp, #96] |
| 1612 | ldp d6, d7, [sp, #112] |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1613 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1614 | add sp, sp, #128 |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1615 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1616 | blr xIP0 // native call. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1617 | |
| 1618 | // result sign extension is handled in C code |
| 1619 | // prepare for artQuickGenericJniEndTrampoline call |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1620 | // (Thread*, result, result_f) |
| 1621 | // x0 x1 x2 <= C calling convention |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1622 | mov x1, x0 // Result (from saved). |
| 1623 | mov x0, xSELF // Thread register. |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1624 | 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] | 1625 | |
| 1626 | bl artQuickGenericJniEndTrampoline |
| 1627 | |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1628 | // Pending exceptions possible. |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 1629 | ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET] |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1630 | cbnz x2, .Lexception_in_native |
| 1631 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1632 | // Tear down the alloca. |
| 1633 | mov sp, x28 |
| 1634 | .cfi_def_cfa_register sp |
| 1635 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1636 | // Tear down the callee-save frame. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1637 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1638 | |
| 1639 | // store into fpr, for when it's a fpr return... |
| 1640 | fmov d0, x0 |
| 1641 | ret |
| 1642 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1643 | .Lexception_in_native: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1644 | // Move to x1 then sp to please assembler. |
| 1645 | ldr x1, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET] |
| 1646 | mov sp, x1 |
| 1647 | .cfi_def_cfa_register sp |
| 1648 | # This will create a new save-all frame, required by the runtime. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1649 | DELIVER_PENDING_EXCEPTION |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1650 | END art_quick_generic_jni_trampoline |
| 1651 | |
| 1652 | /* |
| 1653 | * Called to bridge from the quick to interpreter ABI. On entry the arguments match those |
| 1654 | * of a quick call: |
| 1655 | * x0 = method being called/to bridge to. |
| 1656 | * x1..x7, d0..d7 = arguments to that method. |
| 1657 | */ |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 1658 | ENTRY art_quick_to_interpreter_bridge |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1659 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME // Set up frame and save arguments. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1660 | |
| 1661 | // x0 will contain mirror::ArtMethod* method. |
| 1662 | mov x1, xSELF // How to get Thread::Current() ??? |
| 1663 | mov x2, sp |
| 1664 | |
| 1665 | // uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, |
| 1666 | // mirror::ArtMethod** sp) |
| 1667 | bl artQuickToInterpreterBridge |
| 1668 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1669 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME // TODO: no need to restore arguments in this case. |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1670 | |
| 1671 | fmov d0, x0 |
| 1672 | |
| 1673 | RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1674 | END art_quick_to_interpreter_bridge |
| 1675 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1676 | |
| 1677 | // |
| 1678 | // Instrumentation-related stubs |
| 1679 | // |
| 1680 | .extern artInstrumentationMethodEntryFromCode |
| 1681 | ENTRY art_quick_instrumentation_entry |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1682 | SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1683 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1684 | mov x20, x0 // Preserve method reference in a callee-save. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1685 | |
| 1686 | mov x2, xSELF |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1687 | mov x3, xLR |
| 1688 | bl artInstrumentationMethodEntryFromCode // (Method*, Object*, Thread*, LR) |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1689 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1690 | mov xIP0, x0 // x0 = result of call. |
| 1691 | mov x0, x20 // Reload method reference. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1692 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1693 | RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME // Note: will restore xSELF |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1694 | adr xLR, art_quick_instrumentation_exit |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1695 | br xIP0 // Tail-call method with lr set to art_quick_instrumentation_exit. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1696 | END art_quick_instrumentation_entry |
| 1697 | |
| 1698 | .extern artInstrumentationMethodExitFromCode |
| 1699 | ENTRY art_quick_instrumentation_exit |
| 1700 | mov xLR, #0 // Clobber LR for later checks. |
| 1701 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1702 | SETUP_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1703 | |
| 1704 | // We need to save x0 and d0. We could use a callee-save from SETUP_REF_ONLY, but then |
| 1705 | // we would need to fully restore it. As there are a lot of callee-save registers, it seems |
| 1706 | // easier to have an extra small stack area. |
| 1707 | |
Sebastien Hertz | 70f8d4b | 2014-06-19 11:51:41 +0200 | [diff] [blame] | 1708 | str x0, [sp, #-16]! // Save integer result. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1709 | .cfi_adjust_cfa_offset 16 |
| 1710 | str d0, [sp, #8] // Save floating-point result. |
| 1711 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1712 | add x1, sp, #16 // Pass SP. |
| 1713 | mov x2, x0 // Pass integer result. |
| 1714 | fmov x3, d0 // Pass floating-point result. |
Sebastien Hertz | 70f8d4b | 2014-06-19 11:51:41 +0200 | [diff] [blame] | 1715 | mov x0, xSELF // Pass Thread. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1716 | bl artInstrumentationMethodExitFromCode // (Thread*, SP, gpr_res, fpr_res) |
| 1717 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1718 | mov xIP0, x0 // Return address from instrumentation call. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1719 | mov xLR, x1 // r1 is holding link register if we're to bounce to deoptimize |
| 1720 | |
| 1721 | ldr d0, [sp, #8] // Restore floating-point result. |
| 1722 | ldr x0, [sp], 16 // Restore integer result, and drop stack area. |
| 1723 | .cfi_adjust_cfa_offset 16 |
| 1724 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1725 | POP_REFS_ONLY_CALLEE_SAVE_FRAME |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1726 | |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1727 | br xIP0 // Tail-call out. |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1728 | END art_quick_instrumentation_exit |
| 1729 | |
| 1730 | /* |
| 1731 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 1732 | * will long jump to the upcall with a special exception of -1. |
| 1733 | */ |
| 1734 | .extern artDeoptimize |
| 1735 | ENTRY art_quick_deoptimize |
| 1736 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1737 | mov x0, xSELF // Pass thread. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1738 | bl artDeoptimize // artDeoptimize(Thread*) |
Serban Constantinescu | 86797a7 | 2014-06-19 16:17:56 +0100 | [diff] [blame] | 1739 | brk 0 |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1740 | END art_quick_deoptimize |
| 1741 | |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame^] | 1742 | /* |
| 1743 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
| 1744 | * will long jump to the upcall with a special exception of -1. |
| 1745 | */ |
| 1746 | .extern artDeoptimizeFromCompiledCode |
| 1747 | ENTRY art_quick_deoptimize_from_compiled_code |
| 1748 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 1749 | mov x0, xSELF // Pass thread. |
| 1750 | bl artDeoptimizeFromCompiledCode // artDeoptimizeFromCompiledCode(Thread*) |
| 1751 | brk 0 |
| 1752 | END art_quick_deoptimize_from_compiled_code |
| 1753 | |
Andreas Gampe | d58342c | 2014-06-05 14:18:08 -0700 | [diff] [blame] | 1754 | |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1755 | /* |
| 1756 | * String's indexOf. |
| 1757 | * |
| 1758 | * TODO: Not very optimized. |
| 1759 | * On entry: |
| 1760 | * x0: string object (known non-null) |
| 1761 | * w1: char to match (known <= 0xFFFF) |
| 1762 | * w2: Starting offset in string data |
| 1763 | */ |
| 1764 | ENTRY art_quick_indexof |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1765 | ldr w3, [x0, #MIRROR_STRING_COUNT_OFFSET] |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1766 | add x0, x0, #MIRROR_STRING_VALUE_OFFSET |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1767 | |
| 1768 | /* Clamp start to [0..count] */ |
| 1769 | cmp w2, #0 |
| 1770 | csel w2, wzr, w2, lt |
| 1771 | cmp w2, w3 |
| 1772 | csel w2, w3, w2, gt |
| 1773 | |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1774 | /* Save a copy to compute result */ |
| 1775 | mov x5, x0 |
| 1776 | |
| 1777 | /* Build pointer to start of data to compare and pre-bias */ |
| 1778 | add x0, x0, x2, lsl #1 |
| 1779 | sub x0, x0, #2 |
| 1780 | |
| 1781 | /* Compute iteration count */ |
| 1782 | sub w2, w3, w2 |
| 1783 | |
| 1784 | /* |
| 1785 | * At this point we have: |
| 1786 | * x0: start of the data to test |
| 1787 | * w1: char to compare |
| 1788 | * w2: iteration count |
| 1789 | * x5: original start of string data |
| 1790 | */ |
| 1791 | |
| 1792 | subs w2, w2, #4 |
| 1793 | b.lt .Lindexof_remainder |
| 1794 | |
| 1795 | .Lindexof_loop4: |
| 1796 | ldrh w6, [x0, #2]! |
| 1797 | ldrh w7, [x0, #2]! |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1798 | ldrh wIP0, [x0, #2]! |
| 1799 | ldrh wIP1, [x0, #2]! |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1800 | cmp w6, w1 |
| 1801 | b.eq .Lmatch_0 |
| 1802 | cmp w7, w1 |
| 1803 | b.eq .Lmatch_1 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1804 | cmp wIP0, w1 |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1805 | b.eq .Lmatch_2 |
Zheng Xu | b551fdc | 2014-07-25 11:49:42 +0800 | [diff] [blame] | 1806 | cmp wIP1, w1 |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1807 | b.eq .Lmatch_3 |
| 1808 | subs w2, w2, #4 |
| 1809 | b.ge .Lindexof_loop4 |
| 1810 | |
| 1811 | .Lindexof_remainder: |
| 1812 | adds w2, w2, #4 |
| 1813 | b.eq .Lindexof_nomatch |
| 1814 | |
| 1815 | .Lindexof_loop1: |
| 1816 | ldrh w6, [x0, #2]! |
| 1817 | cmp w6, w1 |
| 1818 | b.eq .Lmatch_3 |
| 1819 | subs w2, w2, #1 |
| 1820 | b.ne .Lindexof_loop1 |
| 1821 | |
| 1822 | .Lindexof_nomatch: |
| 1823 | mov x0, #-1 |
| 1824 | ret |
| 1825 | |
| 1826 | .Lmatch_0: |
| 1827 | sub x0, x0, #6 |
| 1828 | sub x0, x0, x5 |
| 1829 | asr x0, x0, #1 |
| 1830 | ret |
| 1831 | .Lmatch_1: |
| 1832 | sub x0, x0, #4 |
| 1833 | sub x0, x0, x5 |
| 1834 | asr x0, x0, #1 |
| 1835 | ret |
| 1836 | .Lmatch_2: |
| 1837 | sub x0, x0, #2 |
| 1838 | sub x0, x0, x5 |
| 1839 | asr x0, x0, #1 |
| 1840 | ret |
| 1841 | .Lmatch_3: |
| 1842 | sub x0, x0, x5 |
| 1843 | asr x0, x0, #1 |
| 1844 | ret |
| 1845 | END art_quick_indexof |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1846 | |
| 1847 | /* |
| 1848 | * String's compareTo. |
| 1849 | * |
| 1850 | * TODO: Not very optimized. |
| 1851 | * |
| 1852 | * On entry: |
| 1853 | * x0: this object pointer |
| 1854 | * x1: comp object pointer |
| 1855 | * |
| 1856 | */ |
Serban Constantinescu | 86797a7 | 2014-06-19 16:17:56 +0100 | [diff] [blame] | 1857 | .extern __memcmp16 |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1858 | ENTRY art_quick_string_compareto |
| 1859 | mov x2, x0 // x0 is return, use x2 for first input. |
| 1860 | sub x0, x2, x1 // Same string object? |
| 1861 | cbnz x0,1f |
| 1862 | ret |
| 1863 | 1: // Different string objects. |
| 1864 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1865 | ldr w4, [x2, #MIRROR_STRING_COUNT_OFFSET] |
| 1866 | ldr w3, [x1, #MIRROR_STRING_COUNT_OFFSET] |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1867 | add x2, x2, #MIRROR_STRING_VALUE_OFFSET |
| 1868 | add x1, x1, #MIRROR_STRING_VALUE_OFFSET |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1869 | |
| 1870 | /* |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1871 | * Now: Data* Count |
| 1872 | * first arg x2 w4 |
| 1873 | * second arg x1 w3 |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1874 | */ |
| 1875 | |
| 1876 | // x0 := str1.length(w4) - str2.length(w3). ldr zero-extended w3/w4 into x3/x4. |
| 1877 | subs x0, x4, x3 |
| 1878 | // Min(count1, count2) into w3. |
| 1879 | csel x3, x3, x4, ge |
| 1880 | |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 1881 | // TODO: Tune this value. |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1882 | // Check for long string, do memcmp16 for them. |
| 1883 | cmp w3, #28 // Constant from arm32. |
| 1884 | bgt .Ldo_memcmp16 |
| 1885 | |
| 1886 | /* |
| 1887 | * Now: |
| 1888 | * x2: *first string data |
| 1889 | * x1: *second string data |
| 1890 | * w3: iteration count |
| 1891 | * x0: return value if comparison equal |
| 1892 | * x4, x5, x6, x7: free |
| 1893 | */ |
| 1894 | |
| 1895 | // Do a simple unrolled loop. |
| 1896 | .Lloop: |
| 1897 | // At least two more elements? |
| 1898 | subs w3, w3, #2 |
| 1899 | b.lt .Lremainder_or_done |
| 1900 | |
| 1901 | ldrh w4, [x2], #2 |
| 1902 | ldrh w5, [x1], #2 |
| 1903 | |
| 1904 | ldrh w6, [x2], #2 |
| 1905 | ldrh w7, [x1], #2 |
| 1906 | |
| 1907 | subs w4, w4, w5 |
| 1908 | b.ne .Lw4_result |
| 1909 | |
| 1910 | subs w6, w6, w7 |
| 1911 | b.ne .Lw6_result |
| 1912 | |
| 1913 | b .Lloop |
| 1914 | |
| 1915 | .Lremainder_or_done: |
| 1916 | adds w3, w3, #1 |
| 1917 | b.eq .Lremainder |
| 1918 | ret |
| 1919 | |
| 1920 | .Lremainder: |
| 1921 | ldrh w4, [x2], #2 |
| 1922 | ldrh w5, [x1], #2 |
| 1923 | subs w4, w4, w5 |
| 1924 | b.ne .Lw4_result |
| 1925 | ret |
| 1926 | |
| 1927 | // Result is in w4 |
| 1928 | .Lw4_result: |
| 1929 | sxtw x0, w4 |
| 1930 | ret |
| 1931 | |
| 1932 | // Result is in w6 |
| 1933 | .Lw6_result: |
| 1934 | sxtw x0, w6 |
| 1935 | ret |
| 1936 | |
| 1937 | .Ldo_memcmp16: |
Zheng Xu | 62ddb32 | 2014-08-12 17:19:12 +0800 | [diff] [blame] | 1938 | mov x14, x0 // Save x0 and LR. __memcmp16 does not use these temps. |
| 1939 | mov x15, xLR // TODO: Codify and check that? |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1940 | |
| 1941 | mov x0, x2 |
| 1942 | uxtw x2, w3 |
Serban Constantinescu | 86797a7 | 2014-06-19 16:17:56 +0100 | [diff] [blame] | 1943 | bl __memcmp16 |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1944 | |
Zheng Xu | 62ddb32 | 2014-08-12 17:19:12 +0800 | [diff] [blame] | 1945 | mov xLR, x15 // Restore LR. |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1946 | |
Serban Constantinescu | 86797a7 | 2014-06-19 16:17:56 +0100 | [diff] [blame] | 1947 | cmp x0, #0 // Check the memcmp difference. |
Zheng Xu | 62ddb32 | 2014-08-12 17:19:12 +0800 | [diff] [blame] | 1948 | csel x0, x0, x14, ne // x0 := x0 != 0 ? x14(prev x0=length diff) : x1. |
Andreas Gampe | 266340d | 2014-05-02 07:55:24 -0700 | [diff] [blame] | 1949 | ret |
| 1950 | END art_quick_string_compareto |