blob: e0e1e8124e6c863d3f5afaeceab071db5fb96023 [file] [log] [blame]
Stuart Monteithb95a5342014-03-12 13:32:32 +00001/*
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
Vladimir Marko215076b2016-09-07 18:05:55 +010022.macro SAVE_REG reg, offset
23 str \reg, [sp, #(\offset)]
24 .cfi_rel_offset \reg, (\offset)
25.endm
26
27.macro RESTORE_REG reg, offset
28 ldr \reg, [sp, #(\offset)]
29 .cfi_restore \reg
30.endm
31
32.macro SAVE_TWO_REGS reg1, reg2, offset
33 stp \reg1, \reg2, [sp, #(\offset)]
34 .cfi_rel_offset \reg1, (\offset)
35 .cfi_rel_offset \reg2, (\offset) + 8
36.endm
37
38.macro RESTORE_TWO_REGS reg1, reg2, offset
39 ldp \reg1, \reg2, [sp, #(\offset)]
40 .cfi_restore \reg1
41 .cfi_restore \reg2
42.endm
43
44.macro SAVE_TWO_REGS_INCREASE_FRAME reg1, reg2, frame_adjustment
45 stp \reg1, \reg2, [sp, #-(\frame_adjustment)]!
46 .cfi_adjust_cfa_offset (\frame_adjustment)
47 .cfi_rel_offset \reg1, 0
48 .cfi_rel_offset \reg2, 8
49.endm
50
51.macro RESTORE_TWO_REGS_DECREASE_FRAME reg1, reg2, frame_adjustment
52 ldp \reg1, \reg2, [sp], #(\frame_adjustment)
53 .cfi_restore \reg1
54 .cfi_restore \reg2
55 .cfi_adjust_cfa_offset -(\frame_adjustment)
56.endm
57
Stuart Monteithb95a5342014-03-12 13:32:32 +000058 /*
59 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +010060 * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves)
Stuart Monteithb95a5342014-03-12 13:32:32 +000061 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +010062.macro SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
63 // art::Runtime** xIP0 = &art::Runtime::instance_
Zheng Xub551fdc2014-07-25 11:49:42 +080064 adrp xIP0, :got:_ZN3art7Runtime9instance_E
65 ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E]
Stuart Monteithb95a5342014-03-12 13:32:32 +000066
67 // Our registers aren't intermixed - just spill in order.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010068 ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_;
Stuart Monteithb95a5342014-03-12 13:32:32 +000069
Vladimir Markofd36f1f2016-08-03 18:49:58 +010070 // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveAllCalleeSaves];
71 ldr xIP0, [xIP0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET]
Andreas Gampe5c1e4352014-04-21 19:28:24 -070072
73 sub sp, sp, #176
74 .cfi_adjust_cfa_offset 176
75
76 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010077#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 176)
78#error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(ARM64) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -070079#endif
80
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010081 // Stack alignment filler [sp, #8].
82 // FP callee-saves.
83 stp d8, d9, [sp, #16]
84 stp d10, d11, [sp, #32]
85 stp d12, d13, [sp, #48]
86 stp d14, d15, [sp, #64]
Andreas Gampe5c1e4352014-04-21 19:28:24 -070087
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010088 // GP callee-saves
Vladimir Marko215076b2016-09-07 18:05:55 +010089 SAVE_TWO_REGS x19, x20, 80
90 SAVE_TWO_REGS x21, x22, 96
91 SAVE_TWO_REGS x23, x24, 112
92 SAVE_TWO_REGS x25, x26, 128
93 SAVE_TWO_REGS x27, x28, 144
94 SAVE_TWO_REGS x29, xLR, 160
Andreas Gampe5c1e4352014-04-21 19:28:24 -070095
Vladimir Markofd36f1f2016-08-03 18:49:58 +010096 // Store ArtMethod* Runtime::callee_save_methods_[kSaveAllCalleeSaves].
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010097 str xIP0, [sp]
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070098 // Place sp in Thread::Current()->top_quick_frame.
99 mov xIP0, sp
100 str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000101.endm
102
Zheng Xub551fdc2014-07-25 11:49:42 +0800103 /*
104 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100105 * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly).
Zheng Xub551fdc2014-07-25 11:49:42 +0800106 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100107.macro SETUP_SAVE_REFS_ONLY_FRAME
108 // art::Runtime** xIP0 = &art::Runtime::instance_
Zheng Xub551fdc2014-07-25 11:49:42 +0800109 adrp xIP0, :got:_ZN3art7Runtime9instance_E
110 ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E]
111
112 // Our registers aren't intermixed - just spill in order.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100113 ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_;
Zheng Xub551fdc2014-07-25 11:49:42 +0800114
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100115 // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveRefOnly];
116 ldr xIP0, [xIP0, RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET]
Zheng Xub551fdc2014-07-25 11:49:42 +0800117
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100118 sub sp, sp, #96
119 .cfi_adjust_cfa_offset 96
Zheng Xub551fdc2014-07-25 11:49:42 +0800120
121 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100122#if (FRAME_SIZE_SAVE_REFS_ONLY != 96)
123#error "FRAME_SIZE_SAVE_REFS_ONLY(ARM64) size not as expected."
Zheng Xub551fdc2014-07-25 11:49:42 +0800124#endif
125
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100126 // GP callee-saves.
127 // x20 paired with ArtMethod* - see below.
Vladimir Marko215076b2016-09-07 18:05:55 +0100128 SAVE_TWO_REGS x21, x22, 16
129 SAVE_TWO_REGS x23, x24, 32
130 SAVE_TWO_REGS x25, x26, 48
131 SAVE_TWO_REGS x27, x28, 64
132 SAVE_TWO_REGS x29, xLR, 80
Zheng Xub551fdc2014-07-25 11:49:42 +0800133
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100134 // Store ArtMethod* Runtime::callee_save_methods_[kSaveRefsOnly].
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100135 stp xIP0, x20, [sp]
136 .cfi_rel_offset x20, 8
Zheng Xub551fdc2014-07-25 11:49:42 +0800137
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700138 // Place sp in Thread::Current()->top_quick_frame.
139 mov xIP0, sp
140 str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
Zheng Xub551fdc2014-07-25 11:49:42 +0800141.endm
142
143// TODO: Probably no need to restore registers preserved by aapcs64.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100144.macro RESTORE_SAVE_REFS_ONLY_FRAME
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100145 // Callee-saves.
Vladimir Marko215076b2016-09-07 18:05:55 +0100146 RESTORE_REG x20, 8
147 RESTORE_TWO_REGS x21, x22, 16
148 RESTORE_TWO_REGS x23, x24, 32
149 RESTORE_TWO_REGS x25, x26, 48
150 RESTORE_TWO_REGS x27, x28, 64
151 RESTORE_TWO_REGS x29, xLR, 80
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700152
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100153 add sp, sp, #96
154 .cfi_adjust_cfa_offset -96
Stuart Monteithb95a5342014-03-12 13:32:32 +0000155.endm
156
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100157.macro POP_SAVE_REFS_ONLY_FRAME
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100158 add sp, sp, #96
159 .cfi_adjust_cfa_offset - 96
Andreas Gamped58342c2014-06-05 14:18:08 -0700160.endm
161
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100162.macro RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN
163 RESTORE_SAVE_REFS_ONLY_FRAME
Zheng Xu48241e72014-05-23 11:52:42 +0800164 ret
Stuart Monteithb95a5342014-03-12 13:32:32 +0000165.endm
166
167
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100168.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL
Zheng Xub551fdc2014-07-25 11:49:42 +0800169 sub sp, sp, #224
170 .cfi_adjust_cfa_offset 224
Stuart Monteithb95a5342014-03-12 13:32:32 +0000171
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700172 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100173#if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 224)
174#error "FRAME_SIZE_SAVE_REFS_AND_ARGS(ARM64) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700175#endif
176
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100177 // Stack alignment filler [sp, #8].
Zheng Xu69a50302015-04-14 20:04:41 +0800178 // FP args.
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100179 stp d0, d1, [sp, #16]
180 stp d2, d3, [sp, #32]
181 stp d4, d5, [sp, #48]
182 stp d6, d7, [sp, #64]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000183
Zheng Xu69a50302015-04-14 20:04:41 +0800184 // Core args.
Vladimir Marko215076b2016-09-07 18:05:55 +0100185 SAVE_TWO_REGS x1, x2, 80
186 SAVE_TWO_REGS x3, x4, 96
187 SAVE_TWO_REGS x5, x6, 112
Andreas Gampe03906cf2014-04-07 12:08:28 -0700188
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100189 // x7, Callee-saves.
Vladimir Marko215076b2016-09-07 18:05:55 +0100190 SAVE_TWO_REGS x7, x20, 128
191 SAVE_TWO_REGS x21, x22, 144
192 SAVE_TWO_REGS x23, x24, 160
193 SAVE_TWO_REGS x25, x26, 176
194 SAVE_TWO_REGS x27, x28, 192
Andreas Gampe03906cf2014-04-07 12:08:28 -0700195
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100196 // x29(callee-save) and LR.
Vladimir Marko215076b2016-09-07 18:05:55 +0100197 SAVE_TWO_REGS x29, xLR, 208
Andreas Gampe03906cf2014-04-07 12:08:28 -0700198
Stuart Monteithb95a5342014-03-12 13:32:32 +0000199.endm
200
201 /*
202 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100203 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000204 *
205 * TODO This is probably too conservative - saving FP & LR.
206 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100207.macro SETUP_SAVE_REFS_AND_ARGS_FRAME
208 // art::Runtime** xIP0 = &art::Runtime::instance_
Zheng Xub551fdc2014-07-25 11:49:42 +0800209 adrp xIP0, :got:_ZN3art7Runtime9instance_E
210 ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000211
212 // Our registers aren't intermixed - just spill in order.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100213 ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000214
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100215 // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveRefAndArgs];
216 ldr xIP0, [xIP0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000217
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100218 SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL
Stuart Monteithb95a5342014-03-12 13:32:32 +0000219
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100220 str xIP0, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kSaveRefsAndArgs].
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700221 // Place sp in Thread::Current()->top_quick_frame.
222 mov xIP0, sp
223 str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
224.endm
225
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100226.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0
227 SETUP_SAVE_REFS_AND_ARGS_FRAME_INTERNAL
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700228 str x0, [sp, #0] // Store ArtMethod* to bottom of stack.
229 // Place sp in Thread::Current()->top_quick_frame.
230 mov xIP0, sp
231 str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000232.endm
233
Zheng Xub551fdc2014-07-25 11:49:42 +0800234// TODO: Probably no need to restore registers preserved by aapcs64.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100235.macro RESTORE_SAVE_REFS_AND_ARGS_FRAME
Zheng Xu69a50302015-04-14 20:04:41 +0800236 // FP args.
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100237 ldp d0, d1, [sp, #16]
238 ldp d2, d3, [sp, #32]
239 ldp d4, d5, [sp, #48]
240 ldp d6, d7, [sp, #64]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000241
Zheng Xu69a50302015-04-14 20:04:41 +0800242 // Core args.
Vladimir Marko215076b2016-09-07 18:05:55 +0100243 RESTORE_TWO_REGS x1, x2, 80
244 RESTORE_TWO_REGS x3, x4, 96
245 RESTORE_TWO_REGS x5, x6, 112
Andreas Gampe03906cf2014-04-07 12:08:28 -0700246
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100247 // x7, Callee-saves.
Vladimir Marko215076b2016-09-07 18:05:55 +0100248 RESTORE_TWO_REGS x7, x20, 128
249 RESTORE_TWO_REGS x21, x22, 144
250 RESTORE_TWO_REGS x23, x24, 160
251 RESTORE_TWO_REGS x25, x26, 176
252 RESTORE_TWO_REGS x27, x28, 192
Andreas Gampe03906cf2014-04-07 12:08:28 -0700253
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100254 // x29(callee-save) and LR.
Vladimir Marko215076b2016-09-07 18:05:55 +0100255 RESTORE_TWO_REGS x29, xLR, 208
Stuart Monteithb95a5342014-03-12 13:32:32 +0000256
Zheng Xub551fdc2014-07-25 11:49:42 +0800257 add sp, sp, #224
258 .cfi_adjust_cfa_offset -224
Stuart Monteithb95a5342014-03-12 13:32:32 +0000259.endm
260
Vladimir Marko952dbb12016-07-28 12:01:51 +0100261 /*
262 * Macro that sets up the callee save frame to conform with
263 * Runtime::CreateCalleeSaveMethod(kSaveEverything)
264 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100265.macro SETUP_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +0100266 sub sp, sp, #512
267 .cfi_adjust_cfa_offset 512
268
269 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100270#if (FRAME_SIZE_SAVE_EVERYTHING != 512)
271#error "FRAME_SIZE_SAVE_EVERYTHING(ARM64) size not as expected."
Vladimir Marko952dbb12016-07-28 12:01:51 +0100272#endif
273
274 // Save FP registers.
Vladimir Marko40df7c12016-08-22 16:02:12 +0100275 // For better performance, store d0 and d31 separately, so that all STPs are 16-byte aligned.
Vladimir Markode5f1942016-08-10 12:30:05 +0100276 str d0, [sp, #8]
277 stp d1, d2, [sp, #16]
278 stp d3, d4, [sp, #32]
279 stp d5, d6, [sp, #48]
280 stp d7, d8, [sp, #64]
281 stp d9, d10, [sp, #80]
282 stp d11, d12, [sp, #96]
283 stp d13, d14, [sp, #112]
284 stp d15, d16, [sp, #128]
285 stp d17, d18, [sp, #144]
286 stp d19, d20, [sp, #160]
287 stp d21, d22, [sp, #176]
288 stp d23, d24, [sp, #192]
289 stp d25, d26, [sp, #208]
290 stp d27, d28, [sp, #224]
291 stp d29, d30, [sp, #240]
292 str d31, [sp, #256]
Vladimir Marko952dbb12016-07-28 12:01:51 +0100293
294 // Save core registers.
Vladimir Marko215076b2016-09-07 18:05:55 +0100295 SAVE_REG x0, 264
296 SAVE_TWO_REGS x1, x2, 272
297 SAVE_TWO_REGS x3, x4, 288
298 SAVE_TWO_REGS x5, x6, 304
299 SAVE_TWO_REGS x7, x8, 320
300 SAVE_TWO_REGS x9, x10, 336
301 SAVE_TWO_REGS x11, x12, 352
302 SAVE_TWO_REGS x13, x14, 368
303 SAVE_TWO_REGS x15, x16, 384
304 SAVE_TWO_REGS x17, x18, 400
305 SAVE_TWO_REGS x19, x20, 416
306 SAVE_TWO_REGS x21, x22, 432
307 SAVE_TWO_REGS x23, x24, 448
308 SAVE_TWO_REGS x25, x26, 464
309 SAVE_TWO_REGS x27, x28, 480
310 SAVE_TWO_REGS x29, xLR, 496
Vladimir Marko952dbb12016-07-28 12:01:51 +0100311
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100312 // art::Runtime** xIP0 = &art::Runtime::instance_
Vladimir Marko952dbb12016-07-28 12:01:51 +0100313 adrp xIP0, :got:_ZN3art7Runtime9instance_E
314 ldr xIP0, [xIP0, #:got_lo12:_ZN3art7Runtime9instance_E]
315
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100316 ldr xIP0, [xIP0] // art::Runtime* xIP0 = art::Runtime::instance_;
Vladimir Marko952dbb12016-07-28 12:01:51 +0100317
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100318 // ArtMethod* xIP0 = Runtime::instance_->callee_save_methods_[kSaveEverything];
319 ldr xIP0, [xIP0, RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET]
Vladimir Marko952dbb12016-07-28 12:01:51 +0100320
321 // Store ArtMethod* Runtime::callee_save_methods_[kSaveEverything].
322 str xIP0, [sp]
323 // Place sp in Thread::Current()->top_quick_frame.
324 mov xIP0, sp
325 str xIP0, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
326.endm
327
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100328.macro RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +0100329 // Restore FP registers.
Vladimir Marko40df7c12016-08-22 16:02:12 +0100330 // For better performance, load d0 and d31 separately, so that all LDPs are 16-byte aligned.
Vladimir Markode5f1942016-08-10 12:30:05 +0100331 ldr d0, [sp, #8]
332 ldp d1, d2, [sp, #16]
333 ldp d3, d4, [sp, #32]
334 ldp d5, d6, [sp, #48]
335 ldp d7, d8, [sp, #64]
336 ldp d9, d10, [sp, #80]
337 ldp d11, d12, [sp, #96]
338 ldp d13, d14, [sp, #112]
339 ldp d15, d16, [sp, #128]
340 ldp d17, d18, [sp, #144]
341 ldp d19, d20, [sp, #160]
342 ldp d21, d22, [sp, #176]
343 ldp d23, d24, [sp, #192]
344 ldp d25, d26, [sp, #208]
345 ldp d27, d28, [sp, #224]
346 ldp d29, d30, [sp, #240]
347 ldr d31, [sp, #256]
Vladimir Marko952dbb12016-07-28 12:01:51 +0100348
349 // Restore core registers.
Vladimir Marko215076b2016-09-07 18:05:55 +0100350 RESTORE_REG x0, 264
351 RESTORE_TWO_REGS x1, x2, 272
352 RESTORE_TWO_REGS x3, x4, 288
353 RESTORE_TWO_REGS x5, x6, 304
354 RESTORE_TWO_REGS x7, x8, 320
355 RESTORE_TWO_REGS x9, x10, 336
356 RESTORE_TWO_REGS x11, x12, 352
357 RESTORE_TWO_REGS x13, x14, 368
358 RESTORE_TWO_REGS x15, x16, 384
359 RESTORE_TWO_REGS x17, x18, 400
360 RESTORE_TWO_REGS x19, x20, 416
361 RESTORE_TWO_REGS x21, x22, 432
362 RESTORE_TWO_REGS x23, x24, 448
363 RESTORE_TWO_REGS x25, x26, 464
364 RESTORE_TWO_REGS x27, x28, 480
365 RESTORE_TWO_REGS x29, xLR, 496
Vladimir Marko952dbb12016-07-28 12:01:51 +0100366
367 add sp, sp, #512
368 .cfi_adjust_cfa_offset -512
369.endm
370
Stuart Monteithb95a5342014-03-12 13:32:32 +0000371.macro RETURN_IF_RESULT_IS_ZERO
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700372 cbnz x0, 1f // result non-zero branch over
373 ret // return
3741:
Stuart Monteithb95a5342014-03-12 13:32:32 +0000375.endm
376
377.macro RETURN_IF_RESULT_IS_NON_ZERO
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700378 cbz x0, 1f // result zero branch over
379 ret // return
3801:
Stuart Monteithb95a5342014-03-12 13:32:32 +0000381.endm
382
383 /*
384 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
385 * exception is Thread::Current()->exception_
386 */
387.macro DELIVER_PENDING_EXCEPTION
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100388 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +0000389 mov x0, xSELF
Stuart Monteithb95a5342014-03-12 13:32:32 +0000390
391 // Point of no return.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700392 b artDeliverPendingExceptionFromCode // artDeliverPendingExceptionFromCode(Thread*)
Stuart Monteithb95a5342014-03-12 13:32:32 +0000393 brk 0 // Unreached
394.endm
395
Andreas Gampe6e4e59c2014-05-05 20:11:02 -0700396.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg
397 ldr \reg, [xSELF, # THREAD_EXCEPTION_OFFSET] // Get exception field.
398 cbnz \reg, 1f
Stuart Monteithb95a5342014-03-12 13:32:32 +0000399 ret
4001:
401 DELIVER_PENDING_EXCEPTION
402.endm
403
Andreas Gampe6e4e59c2014-05-05 20:11:02 -0700404.macro RETURN_OR_DELIVER_PENDING_EXCEPTION
Zheng Xub551fdc2014-07-25 11:49:42 +0800405 RETURN_OR_DELIVER_PENDING_EXCEPTION_REG xIP0
Andreas Gampe6e4e59c2014-05-05 20:11:02 -0700406.endm
407
408// Same as above with x1. This is helpful in stubs that want to avoid clobbering another register.
409.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
410 RETURN_OR_DELIVER_PENDING_EXCEPTION_REG x1
411.endm
412
413.macro RETURN_IF_W0_IS_ZERO_OR_DELIVER
414 cbnz w0, 1f // result non-zero branch over
415 ret // return
4161:
417 DELIVER_PENDING_EXCEPTION
418.endm
419
Stuart Monteithb95a5342014-03-12 13:32:32 +0000420.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
421 .extern \cxx_name
422ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100423 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context
Zheng Xub551fdc2014-07-25 11:49:42 +0800424 mov x0, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700425 b \cxx_name // \cxx_name(Thread*)
Stuart Monteithb95a5342014-03-12 13:32:32 +0000426END \c_name
427.endm
428
429.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name
430 .extern \cxx_name
431ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100432 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context.
Zheng Xub551fdc2014-07-25 11:49:42 +0800433 mov x1, xSELF // pass Thread::Current.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700434 b \cxx_name // \cxx_name(arg, Thread*).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000435 brk 0
436END \c_name
437.endm
438
439.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
440 .extern \cxx_name
441ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100442 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context
Zheng Xub551fdc2014-07-25 11:49:42 +0800443 mov x2, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700444 b \cxx_name // \cxx_name(arg1, arg2, Thread*)
Stuart Monteithb95a5342014-03-12 13:32:32 +0000445 brk 0
446END \c_name
447.endm
448
449 /*
450 * Called by managed code, saves callee saves and then calls artThrowException
451 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception.
452 */
453ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode
454
455 /*
456 * Called by managed code to create and deliver a NullPointerException.
457 */
458NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode
459
460 /*
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100461 * Call installed by a signal handler to create and deliver a NullPointerException.
462 */
463ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_signal, artThrowNullPointerExceptionFromSignal
464
465 /*
Stuart Monteithb95a5342014-03-12 13:32:32 +0000466 * Called by managed code to create and deliver an ArithmeticException.
467 */
468NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode
469
470 /*
471 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds
472 * index, arg2 holds limit.
473 */
474TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode
475
476 /*
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100477 * Called by managed code to create and deliver a StringIndexOutOfBoundsException
478 * as if thrown from a call to String.charAt(). Arg1 holds index, arg2 holds limit.
479 */
480TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_string_bounds, artThrowStringBoundsFromCode
481
482 /*
Stuart Monteithb95a5342014-03-12 13:32:32 +0000483 * Called by managed code to create and deliver a StackOverflowError.
484 */
485NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode
486
487 /*
488 * Called by managed code to create and deliver a NoSuchMethodError.
489 */
490ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode
491
492 /*
Stuart Monteithb95a5342014-03-12 13:32:32 +0000493 * All generated callsites for interface invokes and invocation slow paths will load arguments
Andreas Gampe51f76352014-05-21 08:28:48 -0700494 * as usual - except instead of loading arg0/x0 with the target Method*, arg0/x0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100495 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
Andreas Gampe51f76352014-05-21 08:28:48 -0700496 * NOTE: "this" is first visible argument of the target, and so can be found in arg1/x1.
Stuart Monteithb95a5342014-03-12 13:32:32 +0000497 *
Andreas Gampe51f76352014-05-21 08:28:48 -0700498 * The helper will attempt to locate the target and return a 128-bit result in x0/x1 consisting
Stuart Monteithb95a5342014-03-12 13:32:32 +0000499 * of the target Method* in x0 and method->code_ in x1.
500 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700501 * If unsuccessful, the helper will return null/????. There will be a pending exception in the
Stuart Monteithb95a5342014-03-12 13:32:32 +0000502 * thread and we branch to another stub to deliver it.
503 *
504 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
505 * pointing back to the original caller.
Andreas Gampe51f76352014-05-21 08:28:48 -0700506 *
507 * Adapted from ARM32 code.
508 *
Zheng Xub551fdc2014-07-25 11:49:42 +0800509 * Clobbers xIP0.
Stuart Monteithb95a5342014-03-12 13:32:32 +0000510 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700511.macro INVOKE_TRAMPOLINE_BODY cxx_name
Stuart Monteithb95a5342014-03-12 13:32:32 +0000512 .extern \cxx_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100513 SETUP_SAVE_REFS_AND_ARGS_FRAME // save callee saves in case allocation triggers GC
Andreas Gampe51f76352014-05-21 08:28:48 -0700514 // Helper signature is always
515 // (method_idx, *this_object, *caller_method, *self, sp)
516
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100517 mov x2, xSELF // pass Thread::Current
518 mov x3, sp
519 bl \cxx_name // (method_idx, this, Thread*, SP)
Zheng Xub551fdc2014-07-25 11:49:42 +0800520 mov xIP0, x1 // save Method*->code_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100521 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Andreas Gampe51f76352014-05-21 08:28:48 -0700522 cbz x0, 1f // did we find the target? if not go to exception delivery
Zheng Xub551fdc2014-07-25 11:49:42 +0800523 br xIP0 // tail call to target
Andreas Gampe51f76352014-05-21 08:28:48 -07005241:
525 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700526.endm
527.macro INVOKE_TRAMPOLINE c_name, cxx_name
528ENTRY \c_name
529 INVOKE_TRAMPOLINE_BODY \cxx_name
Stuart Monteithb95a5342014-03-12 13:32:32 +0000530END \c_name
531.endm
532
Stuart Monteithb95a5342014-03-12 13:32:32 +0000533INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
534
535INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
536INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
537INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
538INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
539
Andreas Gampe03906cf2014-04-07 12:08:28 -0700540
541.macro INVOKE_STUB_CREATE_FRAME
542
Zheng Xu69a50302015-04-14 20:04:41 +0800543SAVE_SIZE=15*8 // x4, x5, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, SP, LR, FP saved.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700544SAVE_SIZE_AND_METHOD=SAVE_SIZE+8
Andreas Gampecf4035a2014-05-28 22:43:01 -0700545
Andreas Gampe03906cf2014-04-07 12:08:28 -0700546
Zheng Xu48241e72014-05-23 11:52:42 +0800547 mov x9, sp // Save stack pointer.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700548 .cfi_register sp,x9
549
Zheng Xu48241e72014-05-23 11:52:42 +0800550 add x10, x2, # SAVE_SIZE_AND_METHOD // calculate size of frame.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700551 sub x10, sp, x10 // Calculate SP position - saves + ArtMethod* + args
Zheng Xu48241e72014-05-23 11:52:42 +0800552 and x10, x10, # ~0xf // Enforce 16 byte stack alignment.
553 mov sp, x10 // Set new SP.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700554
Zheng Xu48241e72014-05-23 11:52:42 +0800555 sub x10, x9, #SAVE_SIZE // Calculate new FP (later). Done here as we must move SP
556 .cfi_def_cfa_register x10 // before this.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700557 .cfi_adjust_cfa_offset SAVE_SIZE
558
Nicolas Geoffray48088462014-12-12 10:29:38 +0000559 str x28, [x10, #112]
560 .cfi_rel_offset x28, 112
561
562 stp x26, x27, [x10, #96]
563 .cfi_rel_offset x26, 96
564 .cfi_rel_offset x27, 104
565
566 stp x24, x25, [x10, #80]
567 .cfi_rel_offset x24, 80
568 .cfi_rel_offset x25, 88
569
570 stp x22, x23, [x10, #64]
571 .cfi_rel_offset x22, 64
572 .cfi_rel_offset x23, 72
573
574 stp x20, x21, [x10, #48]
575 .cfi_rel_offset x20, 48
576 .cfi_rel_offset x21, 56
577
Zheng Xu69a50302015-04-14 20:04:41 +0800578 stp x9, x19, [x10, #32] // Save old stack pointer and x19.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700579 .cfi_rel_offset sp, 32
Andreas Gampecf4035a2014-05-28 22:43:01 -0700580 .cfi_rel_offset x19, 40
Andreas Gampe03906cf2014-04-07 12:08:28 -0700581
Zheng Xu48241e72014-05-23 11:52:42 +0800582 stp x4, x5, [x10, #16] // Save result and shorty addresses.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700583 .cfi_rel_offset x4, 16
584 .cfi_rel_offset x5, 24
585
Zheng Xu48241e72014-05-23 11:52:42 +0800586 stp xFP, xLR, [x10] // Store LR & FP.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700587 .cfi_rel_offset x29, 0
588 .cfi_rel_offset x30, 8
589
Zheng Xu48241e72014-05-23 11:52:42 +0800590 mov xFP, x10 // Use xFP now, as it's callee-saved.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700591 .cfi_def_cfa_register x29
Zheng Xu48241e72014-05-23 11:52:42 +0800592 mov xSELF, x3 // Move thread pointer into SELF register.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700593
594 // Copy arguments into stack frame.
595 // Use simple copy routine for now.
596 // 4 bytes per slot.
597 // X1 - source address
598 // W2 - args length
599 // X9 - destination address.
600 // W10 - temporary
Mathieu Chartiere401d142015-04-22 13:56:20 -0700601 add x9, sp, #8 // Destination address is bottom of stack + null.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700602
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700603 // Copy parameters into the stack. Use numeric label as this is a macro and Clang's assembler
604 // does not have unique-id variables.
6051:
Andreas Gampe03906cf2014-04-07 12:08:28 -0700606 cmp w2, #0
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700607 beq 2f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700608 sub w2, w2, #4 // Need 65536 bytes of range.
609 ldr w10, [x1, x2]
610 str w10, [x9, x2]
611
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700612 b 1b
Andreas Gampe03906cf2014-04-07 12:08:28 -0700613
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -07006142:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700615 // Store null into ArtMethod* at bottom of frame.
616 str xzr, [sp]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700617.endm
618
619.macro INVOKE_STUB_CALL_AND_RETURN
620
621 // load method-> METHOD_QUICK_CODE_OFFSET
Mathieu Chartiere401d142015-04-22 13:56:20 -0700622 ldr x9, [x0, #ART_METHOD_QUICK_CODE_OFFSET_64]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700623 // Branch to method.
624 blr x9
625
626 // Restore return value address and shorty address.
627 ldp x4,x5, [xFP, #16]
628 .cfi_restore x4
629 .cfi_restore x5
630
Nicolas Geoffray48088462014-12-12 10:29:38 +0000631 ldr x28, [xFP, #112]
632 .cfi_restore x28
633
634 ldp x26, x27, [xFP, #96]
635 .cfi_restore x26
636 .cfi_restore x27
637
638 ldp x24, x25, [xFP, #80]
639 .cfi_restore x24
640 .cfi_restore x25
641
642 ldp x22, x23, [xFP, #64]
643 .cfi_restore x22
644 .cfi_restore x23
645
646 ldp x20, x21, [xFP, #48]
647 .cfi_restore x20
648 .cfi_restore x21
649
Andreas Gampe03906cf2014-04-07 12:08:28 -0700650 // Store result (w0/x0/s0/d0) appropriately, depending on resultType.
651 ldrb w10, [x5]
652
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700653 // Check the return type and store the correct register into the jvalue in memory.
654 // Use numeric label as this is a macro and Clang's assembler does not have unique-id variables.
655
Andreas Gampe03906cf2014-04-07 12:08:28 -0700656 // Don't set anything for a void type.
657 cmp w10, #'V'
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700658 beq 3f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700659
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700660 // Is it a double?
Andreas Gampe03906cf2014-04-07 12:08:28 -0700661 cmp w10, #'D'
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700662 bne 1f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700663 str d0, [x4]
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700664 b 3f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700665
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -07006661: // Is it a float?
Andreas Gampe03906cf2014-04-07 12:08:28 -0700667 cmp w10, #'F'
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700668 bne 2f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700669 str s0, [x4]
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -0700670 b 3f
Andreas Gampe03906cf2014-04-07 12:08:28 -0700671
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -07006722: // Just store x0. Doesn't matter if it is 64 or 32 bits.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700673 str x0, [x4]
674
Chih-Hung Hsiehc0da7ac2015-07-27 10:10:44 -07006753: // Finish up.
Zheng Xu69a50302015-04-14 20:04:41 +0800676 ldp x2, x19, [xFP, #32] // Restore stack pointer and x19.
Andreas Gampecf4035a2014-05-28 22:43:01 -0700677 .cfi_restore x19
Andreas Gampe03906cf2014-04-07 12:08:28 -0700678 mov sp, x2
679 .cfi_restore sp
680
Andreas Gamped58342c2014-06-05 14:18:08 -0700681 ldp xFP, xLR, [xFP] // Restore old frame pointer and link register.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700682 .cfi_restore x29
683 .cfi_restore x30
684
685 ret
686
687.endm
688
689
Stuart Monteithb95a5342014-03-12 13:32:32 +0000690/*
691 * extern"C" void art_quick_invoke_stub(ArtMethod *method, x0
692 * uint32_t *args, x1
693 * uint32_t argsize, w2
694 * Thread *self, x3
695 * JValue *result, x4
696 * char *shorty); x5
697 * +----------------------+
698 * | |
699 * | C/C++ frame |
700 * | LR'' |
701 * | FP'' | <- SP'
702 * +----------------------+
703 * +----------------------+
Zheng Xu69a50302015-04-14 20:04:41 +0800704 * | x28 | <- TODO: Remove callee-saves.
705 * | : |
706 * | x19 |
Stuart Monteithb95a5342014-03-12 13:32:32 +0000707 * | SP' |
708 * | X5 |
709 * | X4 | Saved registers
710 * | LR' |
711 * | FP' | <- FP
712 * +----------------------+
713 * | uint32_t out[n-1] |
714 * | : : | Outs
715 * | uint32_t out[0] |
Mathieu Chartiere401d142015-04-22 13:56:20 -0700716 * | ArtMethod* | <- SP value=null
Stuart Monteithb95a5342014-03-12 13:32:32 +0000717 * +----------------------+
718 *
719 * Outgoing registers:
720 * x0 - Method*
721 * x1-x7 - integer parameters.
722 * d0-d7 - Floating point parameters.
723 * xSELF = self
724 * SP = & of ArtMethod*
725 * x1 = "this" pointer.
726 *
727 */
728ENTRY art_quick_invoke_stub
729 // Spill registers as per AACPS64 calling convention.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700730 INVOKE_STUB_CREATE_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +0000731
732 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters.
733 // Parse the passed shorty to determine which register to load.
734 // Load addresses for routines that load WXSD registers.
735 adr x11, .LstoreW2
736 adr x12, .LstoreX2
737 adr x13, .LstoreS0
738 adr x14, .LstoreD0
739
740 // Initialize routine offsets to 0 for integers and floats.
741 // x8 for integers, x15 for floating point.
742 mov x8, #0
743 mov x15, #0
744
745 add x10, x5, #1 // Load shorty address, plus one to skip return value.
746 ldr w1, [x9],#4 // Load "this" parameter, and increment arg pointer.
747
748 // Loop to fill registers.
749.LfillRegisters:
750 ldrb w17, [x10], #1 // Load next character in signature, and increment.
751 cbz w17, .LcallFunction // Exit at end of signature. Shorty 0 terminated.
752
753 cmp w17, #'F' // is this a float?
754 bne .LisDouble
755
756 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700757 beq .Ladvance4
Stuart Monteithb95a5342014-03-12 13:32:32 +0000758
759 add x17, x13, x15 // Calculate subroutine to jump to.
760 br x17
761
762.LisDouble:
763 cmp w17, #'D' // is this a double?
764 bne .LisLong
765
766 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700767 beq .Ladvance8
Stuart Monteithb95a5342014-03-12 13:32:32 +0000768
769 add x17, x14, x15 // Calculate subroutine to jump to.
770 br x17
771
772.LisLong:
773 cmp w17, #'J' // is this a long?
774 bne .LisOther
775
Andreas Gampe9de65ff2014-03-21 17:25:57 -0700776 cmp x8, # 6*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700777 beq .Ladvance8
Stuart Monteithb95a5342014-03-12 13:32:32 +0000778
779 add x17, x12, x8 // Calculate subroutine to jump to.
780 br x17
781
Stuart Monteithb95a5342014-03-12 13:32:32 +0000782.LisOther: // Everything else takes one vReg.
Andreas Gampe9de65ff2014-03-21 17:25:57 -0700783 cmp x8, # 6*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700784 beq .Ladvance4
785
Stuart Monteithb95a5342014-03-12 13:32:32 +0000786 add x17, x11, x8 // Calculate subroutine to jump to.
787 br x17
788
Andreas Gampe03906cf2014-04-07 12:08:28 -0700789.Ladvance4:
790 add x9, x9, #4
791 b .LfillRegisters
792
793.Ladvance8:
794 add x9, x9, #8
795 b .LfillRegisters
796
Stuart Monteithb95a5342014-03-12 13:32:32 +0000797// Macro for loading a parameter into a register.
798// counter - the register with offset into these tables
799// size - the size of the register - 4 or 8 bytes.
800// register - the name of the register to be loaded.
801.macro LOADREG counter size register return
802 ldr \register , [x9], #\size
803 add \counter, \counter, 12
804 b \return
805.endm
806
807// Store ints.
808.LstoreW2:
809 LOADREG x8 4 w2 .LfillRegisters
810 LOADREG x8 4 w3 .LfillRegisters
811 LOADREG x8 4 w4 .LfillRegisters
812 LOADREG x8 4 w5 .LfillRegisters
813 LOADREG x8 4 w6 .LfillRegisters
814 LOADREG x8 4 w7 .LfillRegisters
815
816// Store longs.
817.LstoreX2:
818 LOADREG x8 8 x2 .LfillRegisters
819 LOADREG x8 8 x3 .LfillRegisters
820 LOADREG x8 8 x4 .LfillRegisters
821 LOADREG x8 8 x5 .LfillRegisters
822 LOADREG x8 8 x6 .LfillRegisters
823 LOADREG x8 8 x7 .LfillRegisters
824
825// Store singles.
826.LstoreS0:
827 LOADREG x15 4 s0 .LfillRegisters
828 LOADREG x15 4 s1 .LfillRegisters
829 LOADREG x15 4 s2 .LfillRegisters
830 LOADREG x15 4 s3 .LfillRegisters
831 LOADREG x15 4 s4 .LfillRegisters
832 LOADREG x15 4 s5 .LfillRegisters
833 LOADREG x15 4 s6 .LfillRegisters
834 LOADREG x15 4 s7 .LfillRegisters
835
836// Store doubles.
837.LstoreD0:
838 LOADREG x15 8 d0 .LfillRegisters
839 LOADREG x15 8 d1 .LfillRegisters
840 LOADREG x15 8 d2 .LfillRegisters
841 LOADREG x15 8 d3 .LfillRegisters
842 LOADREG x15 8 d4 .LfillRegisters
843 LOADREG x15 8 d5 .LfillRegisters
844 LOADREG x15 8 d6 .LfillRegisters
845 LOADREG x15 8 d7 .LfillRegisters
846
847
848.LcallFunction:
849
Andreas Gampe03906cf2014-04-07 12:08:28 -0700850 INVOKE_STUB_CALL_AND_RETURN
Stuart Monteithb95a5342014-03-12 13:32:32 +0000851
Stuart Monteithb95a5342014-03-12 13:32:32 +0000852END art_quick_invoke_stub
853
854/* extern"C"
855 * void art_quick_invoke_static_stub(ArtMethod *method, x0
856 * uint32_t *args, x1
857 * uint32_t argsize, w2
858 * Thread *self, x3
859 * JValue *result, x4
860 * char *shorty); x5
861 */
862ENTRY art_quick_invoke_static_stub
863 // Spill registers as per AACPS64 calling convention.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700864 INVOKE_STUB_CREATE_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +0000865
866 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters.
867 // Parse the passed shorty to determine which register to load.
868 // Load addresses for routines that load WXSD registers.
869 adr x11, .LstoreW1_2
870 adr x12, .LstoreX1_2
871 adr x13, .LstoreS0_2
872 adr x14, .LstoreD0_2
873
874 // Initialize routine offsets to 0 for integers and floats.
875 // x8 for integers, x15 for floating point.
876 mov x8, #0
877 mov x15, #0
878
879 add x10, x5, #1 // Load shorty address, plus one to skip return value.
880
881 // Loop to fill registers.
882.LfillRegisters2:
883 ldrb w17, [x10], #1 // Load next character in signature, and increment.
884 cbz w17, .LcallFunction2 // Exit at end of signature. Shorty 0 terminated.
885
886 cmp w17, #'F' // is this a float?
887 bne .LisDouble2
888
889 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700890 beq .Ladvance4_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000891
892 add x17, x13, x15 // Calculate subroutine to jump to.
893 br x17
894
895.LisDouble2:
896 cmp w17, #'D' // is this a double?
897 bne .LisLong2
898
899 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700900 beq .Ladvance8_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000901
902 add x17, x14, x15 // Calculate subroutine to jump to.
903 br x17
904
905.LisLong2:
906 cmp w17, #'J' // is this a long?
907 bne .LisOther2
908
909 cmp x8, # 7*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700910 beq .Ladvance8_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000911
912 add x17, x12, x8 // Calculate subroutine to jump to.
913 br x17
914
Stuart Monteithb95a5342014-03-12 13:32:32 +0000915.LisOther2: // Everything else takes one vReg.
916 cmp x8, # 7*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700917 beq .Ladvance4_2
918
Stuart Monteithb95a5342014-03-12 13:32:32 +0000919 add x17, x11, x8 // Calculate subroutine to jump to.
920 br x17
921
Andreas Gampe03906cf2014-04-07 12:08:28 -0700922.Ladvance4_2:
923 add x9, x9, #4
924 b .LfillRegisters2
925
926.Ladvance8_2:
927 add x9, x9, #8
928 b .LfillRegisters2
929
Stuart Monteithb95a5342014-03-12 13:32:32 +0000930// Store ints.
931.LstoreW1_2:
932 LOADREG x8 4 w1 .LfillRegisters2
933 LOADREG x8 4 w2 .LfillRegisters2
934 LOADREG x8 4 w3 .LfillRegisters2
935 LOADREG x8 4 w4 .LfillRegisters2
936 LOADREG x8 4 w5 .LfillRegisters2
937 LOADREG x8 4 w6 .LfillRegisters2
938 LOADREG x8 4 w7 .LfillRegisters2
939
940// Store longs.
941.LstoreX1_2:
942 LOADREG x8 8 x1 .LfillRegisters2
943 LOADREG x8 8 x2 .LfillRegisters2
944 LOADREG x8 8 x3 .LfillRegisters2
945 LOADREG x8 8 x4 .LfillRegisters2
946 LOADREG x8 8 x5 .LfillRegisters2
947 LOADREG x8 8 x6 .LfillRegisters2
948 LOADREG x8 8 x7 .LfillRegisters2
949
950// Store singles.
951.LstoreS0_2:
952 LOADREG x15 4 s0 .LfillRegisters2
953 LOADREG x15 4 s1 .LfillRegisters2
954 LOADREG x15 4 s2 .LfillRegisters2
955 LOADREG x15 4 s3 .LfillRegisters2
956 LOADREG x15 4 s4 .LfillRegisters2
957 LOADREG x15 4 s5 .LfillRegisters2
958 LOADREG x15 4 s6 .LfillRegisters2
959 LOADREG x15 4 s7 .LfillRegisters2
960
961// Store doubles.
962.LstoreD0_2:
963 LOADREG x15 8 d0 .LfillRegisters2
964 LOADREG x15 8 d1 .LfillRegisters2
965 LOADREG x15 8 d2 .LfillRegisters2
966 LOADREG x15 8 d3 .LfillRegisters2
967 LOADREG x15 8 d4 .LfillRegisters2
968 LOADREG x15 8 d5 .LfillRegisters2
969 LOADREG x15 8 d6 .LfillRegisters2
970 LOADREG x15 8 d7 .LfillRegisters2
971
972
973.LcallFunction2:
974
Andreas Gampe03906cf2014-04-07 12:08:28 -0700975 INVOKE_STUB_CALL_AND_RETURN
Stuart Monteithb95a5342014-03-12 13:32:32 +0000976
Stuart Monteithb95a5342014-03-12 13:32:32 +0000977END art_quick_invoke_static_stub
978
Andreas Gampe03906cf2014-04-07 12:08:28 -0700979
Stuart Monteithb95a5342014-03-12 13:32:32 +0000980
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000981/* extern"C" void art_quick_osr_stub(void** stack, x0
982 * size_t stack_size_in_bytes, x1
983 * const uin8_t* native_pc, x2
984 * JValue *result, x3
985 * char *shorty, x4
986 * Thread *self) x5
987 */
988ENTRY art_quick_osr_stub
989SAVE_SIZE=15*8 // x3, x4, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, SP, LR, FP saved.
990 mov x9, sp // Save stack pointer.
991 .cfi_register sp,x9
992
993 sub x10, sp, # SAVE_SIZE
994 and x10, x10, # ~0xf // Enforce 16 byte stack alignment.
995 mov sp, x10 // Set new SP.
996
997 str x28, [sp, #112]
998 stp x26, x27, [sp, #96]
999 stp x24, x25, [sp, #80]
1000 stp x22, x23, [sp, #64]
1001 stp x20, x21, [sp, #48]
1002 stp x9, x19, [sp, #32] // Save old stack pointer and x19.
1003 stp x3, x4, [sp, #16] // Save result and shorty addresses.
1004 stp xFP, xLR, [sp] // Store LR & FP.
1005 mov xSELF, x5 // Move thread pointer into SELF register.
1006
1007 sub sp, sp, #16
1008 str xzr, [sp] // Store null for ArtMethod* slot
1009 // Branch to stub.
1010 bl .Losr_entry
1011 add sp, sp, #16
1012
1013 // Restore return value address and shorty address.
1014 ldp x3,x4, [sp, #16]
1015 ldr x28, [sp, #112]
1016 ldp x26, x27, [sp, #96]
1017 ldp x24, x25, [sp, #80]
1018 ldp x22, x23, [sp, #64]
1019 ldp x20, x21, [sp, #48]
1020
1021 // Store result (w0/x0/s0/d0) appropriately, depending on resultType.
1022 ldrb w10, [x4]
1023
1024 // Check the return type and store the correct register into the jvalue in memory.
1025
1026 // Don't set anything for a void type.
1027 cmp w10, #'V'
1028 beq .Losr_exit
1029
1030 // Is it a double?
1031 cmp w10, #'D'
1032 bne .Lno_double
1033 str d0, [x3]
1034 b .Losr_exit
1035
1036.Lno_double: // Is it a float?
1037 cmp w10, #'F'
1038 bne .Lno_float
1039 str s0, [x3]
1040 b .Losr_exit
1041
1042.Lno_float: // Just store x0. Doesn't matter if it is 64 or 32 bits.
1043 str x0, [x3]
1044
1045.Losr_exit: // Finish up.
1046 ldp x2, x19, [sp, #32] // Restore stack pointer and x19.
1047 ldp xFP, xLR, [sp] // Restore old frame pointer and link register.
1048 mov sp, x2
1049 ret
1050
1051.Losr_entry:
1052 // Update stack pointer for the callee
1053 sub sp, sp, x1
1054
1055 // Update link register slot expected by the callee.
1056 sub w1, w1, #8
1057 str lr, [sp, x1]
1058
1059 // Copy arguments into stack frame.
1060 // Use simple copy routine for now.
1061 // 4 bytes per slot.
1062 // X0 - source address
1063 // W1 - args length
1064 // SP - destination address.
1065 // W10 - temporary
1066.Losr_loop_entry:
1067 cmp w1, #0
1068 beq .Losr_loop_exit
1069 sub w1, w1, #4
1070 ldr w10, [x0, x1]
1071 str w10, [sp, x1]
1072 b .Losr_loop_entry
1073
1074.Losr_loop_exit:
1075 // Branch to the OSR entry point.
1076 br x2
1077
1078END art_quick_osr_stub
1079
Stuart Monteithb95a5342014-03-12 13:32:32 +00001080 /*
1081 * On entry x0 is uintptr_t* gprs_ and x1 is uint64_t* fprs_
1082 */
1083
1084ENTRY art_quick_do_long_jump
1085 // Load FPRs
1086 ldp d0, d1, [x1], #16
1087 ldp d2, d3, [x1], #16
1088 ldp d4, d5, [x1], #16
1089 ldp d6, d7, [x1], #16
1090 ldp d8, d9, [x1], #16
1091 ldp d10, d11, [x1], #16
1092 ldp d12, d13, [x1], #16
1093 ldp d14, d15, [x1], #16
1094 ldp d16, d17, [x1], #16
1095 ldp d18, d19, [x1], #16
1096 ldp d20, d21, [x1], #16
1097 ldp d22, d23, [x1], #16
1098 ldp d24, d25, [x1], #16
1099 ldp d26, d27, [x1], #16
1100 ldp d28, d29, [x1], #16
1101 ldp d30, d31, [x1]
1102
1103 // Load GPRs
1104 // TODO: lots of those are smashed, could optimize.
1105 add x0, x0, #30*8
Andreas Gampe639bdd12015-06-03 11:22:45 -07001106 ldp x30, x1, [x0], #-16 // LR & SP
Stuart Monteithb95a5342014-03-12 13:32:32 +00001107 ldp x28, x29, [x0], #-16
1108 ldp x26, x27, [x0], #-16
1109 ldp x24, x25, [x0], #-16
1110 ldp x22, x23, [x0], #-16
1111 ldp x20, x21, [x0], #-16
1112 ldp x18, x19, [x0], #-16
1113 ldp x16, x17, [x0], #-16
1114 ldp x14, x15, [x0], #-16
1115 ldp x12, x13, [x0], #-16
1116 ldp x10, x11, [x0], #-16
1117 ldp x8, x9, [x0], #-16
1118 ldp x6, x7, [x0], #-16
1119 ldp x4, x5, [x0], #-16
1120 ldp x2, x3, [x0], #-16
1121 mov sp, x1
1122
Andreas Gampe639bdd12015-06-03 11:22:45 -07001123 // Need to load PC, it's at the end (after the space for the unused XZR). Use x1.
1124 ldr x1, [x0, #33*8]
1125 // And the value of x0.
1126 ldr x0, [x0]
1127
1128 br x1
Stuart Monteithb95a5342014-03-12 13:32:32 +00001129END art_quick_do_long_jump
1130
Andreas Gampef4e910b2014-04-29 16:55:52 -07001131 /*
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001132 * Entry from managed code that calls artLockObjectFromCode, may block for GC. x0 holds the
1133 * possibly null object to lock.
1134 *
1135 * Derived from arm32 code.
1136 */
1137 .extern artLockObjectFromCode
1138ENTRY art_quick_lock_object
1139 cbz w0, .Lslow_lock
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001140 add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001141.Lretry_lock:
1142 ldr w2, [xSELF, #THREAD_ID_OFFSET] // TODO: Can the thread ID really change during the loop?
1143 ldxr w1, [x4]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001144 mov x3, x1
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001145 and w3, w3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001146 cbnz w3, .Lnot_unlocked // already thin locked
1147 // unlocked case - x1: original lock word that's zero except for the read barrier bits.
1148 orr x2, x1, x2 // x2 holds thread id with count of 0 with preserved read barrier bits
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001149 stxr w3, w2, [x4]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001150 cbnz w3, .Llock_stxr_fail // store failed, retry
Andreas Gampe675967d2014-05-14 16:28:34 -07001151 dmb ishld // full (LoadLoad|LoadStore) memory barrier
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001152 ret
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001153.Lnot_unlocked: // x1: original lock word
1154 lsr w3, w1, LOCK_WORD_STATE_SHIFT
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001155 cbnz w3, .Lslow_lock // if either of the top two bits are set, go slow path
1156 eor w2, w1, w2 // lock_word.ThreadId() ^ self->ThreadId()
1157 uxth w2, w2 // zero top 16 bits
1158 cbnz w2, .Lslow_lock // lock word and self thread id's match -> recursive lock
1159 // else contention, go to slow path
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001160 mov x3, x1 // copy the lock word to check count overflow.
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001161 and w3, w3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits.
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001162 add w2, w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count in lock word placing in w2 to check overflow
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001163 lsr w3, w2, #LOCK_WORD_GC_STATE_SHIFT // if the first gc state bit is set, we overflowed.
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001164 cbnz w3, .Lslow_lock // if we overflow the count go slow path
1165 add w2, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // increment count for real
1166 stxr w3, w2, [x4]
1167 cbnz w3, .Llock_stxr_fail // store failed, retry
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001168 ret
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001169.Llock_stxr_fail:
1170 b .Lretry_lock // retry
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001171.Lslow_lock:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001172 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case we block
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001173 mov x1, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001174 bl artLockObjectFromCode // (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001175 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001176 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1177END art_quick_lock_object
1178
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001179ENTRY art_quick_lock_object_no_inline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001180 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case we block
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001181 mov x1, xSELF // pass Thread::Current
1182 bl artLockObjectFromCode // (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001183 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001184 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1185END art_quick_lock_object_no_inline
1186
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001187 /*
1188 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
1189 * x0 holds the possibly null object to lock.
1190 *
1191 * Derived from arm32 code.
1192 */
1193 .extern artUnlockObjectFromCode
1194ENTRY art_quick_unlock_object
1195 cbz x0, .Lslow_unlock
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001196 add x4, x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET // exclusive load/store has no immediate anymore
1197.Lretry_unlock:
1198#ifndef USE_READ_BARRIER
1199 ldr w1, [x4]
1200#else
1201 ldxr w1, [x4] // Need to use atomic instructions for read barrier
1202#endif
1203 lsr w2, w1, LOCK_WORD_STATE_SHIFT
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001204 cbnz w2, .Lslow_unlock // if either of the top two bits are set, go slow path
1205 ldr w2, [xSELF, #THREAD_ID_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001206 mov x3, x1 // copy lock word to check thread id equality
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001207 and w3, w3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001208 eor w3, w3, w2 // lock_word.ThreadId() ^ self->ThreadId()
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001209 uxth w3, w3 // zero top 16 bits
1210 cbnz w3, .Lslow_unlock // do lock word and self thread id's match?
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001211 mov x3, x1 // copy lock word to detect transition to unlocked
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001212 and w3, w3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED // zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001213 cmp w3, #LOCK_WORD_THIN_LOCK_COUNT_ONE
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001214 bpl .Lrecursive_thin_unlock
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001215 // transition to unlocked
1216 mov x3, x1
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001217 and w3, w3, #LOCK_WORD_GC_STATE_MASK_SHIFTED // w3: zero except for the preserved read barrier bits
Andreas Gampe675967d2014-05-14 16:28:34 -07001218 dmb ish // full (LoadStore|StoreStore) memory barrier
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001219#ifndef USE_READ_BARRIER
1220 str w3, [x4]
1221#else
1222 stxr w2, w3, [x4] // Need to use atomic instructions for read barrier
1223 cbnz w2, .Lunlock_stxr_fail // store failed, retry
1224#endif
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001225 ret
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001226.Lrecursive_thin_unlock: // w1: original lock word
1227 sub w1, w1, #LOCK_WORD_THIN_LOCK_COUNT_ONE // decrement count
1228#ifndef USE_READ_BARRIER
1229 str w1, [x4]
1230#else
1231 stxr w2, w1, [x4] // Need to use atomic instructions for read barrier
1232 cbnz w2, .Lunlock_stxr_fail // store failed, retry
1233#endif
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001234 ret
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -08001235.Lunlock_stxr_fail:
1236 b .Lretry_unlock // retry
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001237.Lslow_unlock:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001238 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case exception allocation triggers GC
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001239 mov x1, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001240 bl artUnlockObjectFromCode // (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001241 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe4fc046e2014-05-06 16:56:39 -07001242 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1243END art_quick_unlock_object
Andreas Gampe525cde22014-04-22 15:44:50 -07001244
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001245ENTRY art_quick_unlock_object_no_inline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001246 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case exception allocation triggers GC
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001247 mov x1, xSELF // pass Thread::Current
1248 bl artUnlockObjectFromCode // (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001249 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001250 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1251END art_quick_unlock_object_no_inline
1252
Andreas Gampe525cde22014-04-22 15:44:50 -07001253 /*
1254 * Entry from managed code that calls artIsAssignableFromCode and on failure calls
1255 * artThrowClassCastException.
1256 */
1257 .extern artThrowClassCastException
1258ENTRY art_quick_check_cast
1259 // Store arguments and link register
Serban Constantinescu9bd88b02015-04-22 16:24:46 +01001260 // Stack needs to be 16B aligned on calls.
Vladimir Marko215076b2016-09-07 18:05:55 +01001261 SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 32
1262 SAVE_REG xLR, 24
Andreas Gampe525cde22014-04-22 15:44:50 -07001263
1264 // Call runtime code
1265 bl artIsAssignableFromCode
1266
1267 // Check for exception
1268 cbz x0, .Lthrow_class_cast_exception
1269
1270 // Restore and return
Vladimir Marko215076b2016-09-07 18:05:55 +01001271 RESTORE_REG xLR, 24
1272 RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
Andreas Gampe525cde22014-04-22 15:44:50 -07001273 ret
1274
Andreas Gampe6b90d422015-06-26 19:49:24 -07001275 .cfi_adjust_cfa_offset 32 // Reset unwind info so following code unwinds.
1276
Andreas Gampe525cde22014-04-22 15:44:50 -07001277.Lthrow_class_cast_exception:
1278 // Restore
Vladimir Marko215076b2016-09-07 18:05:55 +01001279 RESTORE_REG xLR, 24
1280 RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
Andreas Gampe525cde22014-04-22 15:44:50 -07001281
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001282 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME // save all registers as basis for long jump context
Andreas Gampe525cde22014-04-22 15:44:50 -07001283 mov x2, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001284 b artThrowClassCastException // (Class*, Class*, Thread*)
Andreas Gampe525cde22014-04-22 15:44:50 -07001285 brk 0 // We should not return here...
1286END art_quick_check_cast
1287
Man Cao1aee9002015-07-14 22:31:42 -07001288// Restore xReg's value from [sp, #offset] if xReg is not the same as xExclude.
1289.macro POP_REG_NE xReg, offset, xExclude
1290 .ifnc \xReg, \xExclude
1291 ldr \xReg, [sp, #\offset] // restore xReg
1292 .cfi_restore \xReg
1293 .endif
1294.endm
1295
Roland Levillain4359e612016-07-20 11:32:19 +01001296// Restore xReg1's value from [sp, #offset] if xReg1 is not the same as xExclude.
1297// Restore xReg2's value from [sp, #(offset + 8)] if xReg2 is not the same as xExclude.
1298.macro POP_REGS_NE xReg1, xReg2, offset, xExclude
1299 .ifc \xReg1, \xExclude
1300 ldr \xReg2, [sp, #(\offset + 8)] // restore xReg2
1301 .else
1302 .ifc \xReg2, \xExclude
1303 ldr \xReg1, [sp, #\offset] // restore xReg1
1304 .else
1305 ldp \xReg1, \xReg2, [sp, #\offset] // restore xReg1 and xReg2
1306 .endif
1307 .endif
1308 .cfi_restore \xReg1
1309 .cfi_restore \xReg2
1310.endm
1311
Man Cao1aee9002015-07-14 22:31:42 -07001312 /*
1313 * Macro to insert read barrier, only used in art_quick_aput_obj.
1314 * xDest, wDest and xObj are registers, offset is a defined literal such as
1315 * MIRROR_OBJECT_CLASS_OFFSET. Dest needs both x and w versions of the same register to handle
1316 * name mismatch between instructions. This macro uses the lower 32b of register when possible.
1317 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
1318 */
Mathieu Chartier4b5f7912016-07-21 14:59:04 -07001319.macro READ_BARRIER xDest, wDest, xObj, xTemp, wTemp, offset, number
Man Cao1aee9002015-07-14 22:31:42 -07001320#ifdef USE_READ_BARRIER
Mathieu Chartier4b5f7912016-07-21 14:59:04 -07001321#ifdef USE_BAKER_READ_BARRIER
1322 ldr \wTemp, [\xObj, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
1323 tbnz \wTemp, #LOCK_WORD_READ_BARRIER_STATE_SHIFT, .Lrb_slowpath\number
1324 // False dependency to avoid needing load/load fence.
1325 add \xObj, \xObj, \xTemp, lsr #32
1326 ldr \wDest, [\xObj, #\offset] // Heap reference = 32b. This also zero-extends to \xDest.
1327 UNPOISON_HEAP_REF \wDest
1328 b .Lrb_exit\number
1329#endif
1330.Lrb_slowpath\number:
Man Cao1aee9002015-07-14 22:31:42 -07001331 // Store registers used in art_quick_aput_obj (x0-x4, LR), stack is 16B aligned.
Vladimir Marko215076b2016-09-07 18:05:55 +01001332 SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 48
1333 SAVE_TWO_REGS x2, x3, 16
1334 SAVE_TWO_REGS x4, xLR, 32
Man Cao1aee9002015-07-14 22:31:42 -07001335
Man Cao63069212015-08-21 15:51:39 -07001336 // mov x0, \xRef // pass ref in x0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -07001337 .ifnc \xObj, x1
1338 mov x1, \xObj // pass xObj
1339 .endif
1340 mov w2, #\offset // pass offset
1341 bl artReadBarrierSlow // artReadBarrierSlow(ref, xObj, offset)
1342 // No need to unpoison return value in w0, artReadBarrierSlow() would do the unpoisoning.
1343 .ifnc \wDest, w0
1344 mov \wDest, w0 // save return value in wDest
1345 .endif
1346
1347 // Conditionally restore saved registers
1348 POP_REG_NE x0, 0, \xDest
1349 POP_REG_NE x1, 8, \xDest
1350 POP_REG_NE x2, 16, \xDest
1351 POP_REG_NE x3, 24, \xDest
1352 POP_REG_NE x4, 32, \xDest
Vladimir Marko215076b2016-09-07 18:05:55 +01001353 RESTORE_REG xLR, 40
Man Cao1aee9002015-07-14 22:31:42 -07001354 add sp, sp, #48
1355 .cfi_adjust_cfa_offset -48
Mathieu Chartier4b5f7912016-07-21 14:59:04 -07001356.Lrb_exit\number:
Man Cao1aee9002015-07-14 22:31:42 -07001357#else
1358 ldr \wDest, [\xObj, #\offset] // Heap reference = 32b. This also zero-extends to \xDest.
1359 UNPOISON_HEAP_REF \wDest
1360#endif // USE_READ_BARRIER
1361.endm
1362
Andreas Gampef4e910b2014-04-29 16:55:52 -07001363 /*
1364 * Entry from managed code for array put operations of objects where the value being stored
1365 * needs to be checked for compatibility.
1366 * x0 = array, x1 = index, x2 = value
1367 *
1368 * Currently all values should fit into w0/w1/w2, and w1 always will as indices are 32b. We
1369 * assume, though, that the upper 32b are zeroed out. At least for x1/w1 we can do better by
1370 * using index-zero-extension in load/stores.
1371 *
1372 * Temporaries: x3, x4
1373 * TODO: x4 OK? ip seems wrong here.
1374 */
1375ENTRY art_quick_aput_obj_with_null_and_bound_check
1376 tst x0, x0
1377 bne art_quick_aput_obj_with_bound_check
1378 b art_quick_throw_null_pointer_exception
1379END art_quick_aput_obj_with_null_and_bound_check
1380
1381ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001382 ldr w3, [x0, #MIRROR_ARRAY_LENGTH_OFFSET]
Andreas Gampef4e910b2014-04-29 16:55:52 -07001383 cmp w3, w1
1384 bhi art_quick_aput_obj
1385 mov x0, x1
1386 mov x1, x3
1387 b art_quick_throw_array_bounds
1388END art_quick_aput_obj_with_bound_check
1389
Man Cao1aee9002015-07-14 22:31:42 -07001390#ifdef USE_READ_BARRIER
1391 .extern artReadBarrierSlow
1392#endif
Andreas Gampef4e910b2014-04-29 16:55:52 -07001393ENTRY art_quick_aput_obj
1394 cbz x2, .Ldo_aput_null
Mathieu Chartier4b5f7912016-07-21 14:59:04 -07001395 READ_BARRIER x3, w3, x0, x3, w3, MIRROR_OBJECT_CLASS_OFFSET, 0 // Heap reference = 32b
1396 // This also zero-extends to x3
1397 READ_BARRIER x3, w3, x3, x4, w4, MIRROR_CLASS_COMPONENT_TYPE_OFFSET, 1 // Heap reference = 32b
1398 // This also zero-extends to x3
1399 READ_BARRIER x4, w4, x2, x4, w4, MIRROR_OBJECT_CLASS_OFFSET, 2 // Heap reference = 32b
1400 // This also zero-extends to x4
Andreas Gampef4e910b2014-04-29 16:55:52 -07001401 cmp w3, w4 // value's type == array's component type - trivial assignability
1402 bne .Lcheck_assignability
1403.Ldo_aput:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001404 add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Andreas Gampef4e910b2014-04-29 16:55:52 -07001405 // "Compress" = do nothing
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001406 POISON_HEAP_REF w2
Andreas Gampef4e910b2014-04-29 16:55:52 -07001407 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1408 ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET]
1409 lsr x0, x0, #7
1410 strb w3, [x3, x0]
1411 ret
1412.Ldo_aput_null:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001413 add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Andreas Gampef4e910b2014-04-29 16:55:52 -07001414 // "Compress" = do nothing
1415 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1416 ret
1417.Lcheck_assignability:
1418 // Store arguments and link register
Vladimir Marko215076b2016-09-07 18:05:55 +01001419 SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 32
1420 SAVE_TWO_REGS x2, xLR, 16
Andreas Gampef4e910b2014-04-29 16:55:52 -07001421
1422 // Call runtime code
1423 mov x0, x3 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended
1424 mov x1, x4 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended
1425 bl artIsAssignableFromCode
1426
1427 // Check for exception
1428 cbz x0, .Lthrow_array_store_exception
1429
1430 // Restore
Vladimir Marko215076b2016-09-07 18:05:55 +01001431 RESTORE_TWO_REGS x2, xLR, 16
1432 RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
Andreas Gampef4e910b2014-04-29 16:55:52 -07001433
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001434 add x3, x0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Andreas Gampef4e910b2014-04-29 16:55:52 -07001435 // "Compress" = do nothing
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001436 POISON_HEAP_REF w2
Andreas Gampef4e910b2014-04-29 16:55:52 -07001437 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1438 ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET]
1439 lsr x0, x0, #7
1440 strb w3, [x3, x0]
1441 ret
Mathieu Chartier27386392015-06-27 15:42:27 -07001442 .cfi_adjust_cfa_offset 32 // 4 restores after cbz for unwinding.
Andreas Gampef4e910b2014-04-29 16:55:52 -07001443.Lthrow_array_store_exception:
Vladimir Marko215076b2016-09-07 18:05:55 +01001444 RESTORE_TWO_REGS x2, xLR, 16
1445 RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32
Andreas Gampef4e910b2014-04-29 16:55:52 -07001446
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001447 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Andreas Gampef4e910b2014-04-29 16:55:52 -07001448 mov x1, x2 // Pass value.
1449 mov x2, xSELF // Pass Thread::Current.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001450 b artThrowArrayStoreException // (Object*, Object*, Thread*).
Andreas Gampef4e910b2014-04-29 16:55:52 -07001451 brk 0 // Unreached.
1452END art_quick_aput_obj
1453
Stuart Monteithb95a5342014-03-12 13:32:32 +00001454// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001455.macro ONE_ARG_DOWNCALL name, entrypoint, return
1456 .extern \entrypoint
1457ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001458 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001459 mov x1, xSELF // pass Thread::Current
1460 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001461 RESTORE_SAVE_REFS_ONLY_FRAME
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001462 \return
1463END \name
1464.endm
1465
1466// Macro to facilitate adding new allocation entrypoints.
Stuart Monteithb95a5342014-03-12 13:32:32 +00001467.macro TWO_ARG_DOWNCALL name, entrypoint, return
1468 .extern \entrypoint
1469ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001470 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001471 mov x2, xSELF // pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001472 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001473 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001474 \return
Stuart Monteithb95a5342014-03-12 13:32:32 +00001475END \name
1476.endm
1477
Jeff Hao848f70a2014-01-15 13:49:50 -08001478// Macro to facilitate adding new allocation entrypoints.
Stuart Monteithb95a5342014-03-12 13:32:32 +00001479.macro THREE_ARG_DOWNCALL name, entrypoint, return
1480 .extern \entrypoint
1481ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001482 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001483 mov x3, xSELF // pass Thread::Current
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001484 bl \entrypoint
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001485 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001486 \return
Stuart Monteithb95a5342014-03-12 13:32:32 +00001487END \name
1488.endm
1489
Jeff Hao848f70a2014-01-15 13:49:50 -08001490// Macro to facilitate adding new allocation entrypoints.
1491.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1492 .extern \entrypoint
1493ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001494 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Jeff Hao848f70a2014-01-15 13:49:50 -08001495 mov x4, xSELF // pass Thread::Current
1496 bl \entrypoint //
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001497 RESTORE_SAVE_REFS_ONLY_FRAME
Jeff Hao848f70a2014-01-15 13:49:50 -08001498 \return
1499 DELIVER_PENDING_EXCEPTION
1500END \name
1501.endm
1502
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001503// Macros taking opportunity of code similarities for downcalls with referrer.
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001504.macro ONE_ARG_REF_DOWNCALL name, entrypoint, return
1505 .extern \entrypoint
1506ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001507 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
1508 ldr x1, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] // Load referrer
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001509 mov x2, xSELF // pass Thread::Current
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001510 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*, SP)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001511 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001512 \return
1513END \name
1514.endm
1515
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001516.macro TWO_ARG_REF_DOWNCALL name, entrypoint, return
1517 .extern \entrypoint
1518ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001519 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
1520 ldr x2, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] // Load referrer
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001521 mov x3, xSELF // pass Thread::Current
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001522 bl \entrypoint
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001523 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001524 \return
1525END \name
1526.endm
1527
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001528.macro THREE_ARG_REF_DOWNCALL name, entrypoint, return
1529 .extern \entrypoint
1530ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001531 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
1532 ldr x3, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] // Load referrer
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001533 mov x4, xSELF // pass Thread::Current
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001534 bl \entrypoint
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001535 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001536 \return
1537END \name
1538.endm
1539
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001540.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1541 cbz w0, 1f // result zero branch over
1542 ret // return
15431:
1544 DELIVER_PENDING_EXCEPTION
1545.endm
1546
Matteo Franchindfd891a2014-04-30 12:17:17 +01001547 /*
Vladimir Marko3b370732014-10-09 18:34:28 +01001548 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
1549 * failure.
1550 */
1551TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1552
1553 /*
Matteo Franchindfd891a2014-04-30 12:17:17 +01001554 * Entry from managed code when uninitialized static storage, this stub will run the class
1555 * initializer and deliver the exception on error. On success the static storage base is
1556 * returned.
1557 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001558ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Matteo Franchindfd891a2014-04-30 12:17:17 +01001559
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001560ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1561ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Matteo Franchindfd891a2014-04-30 12:17:17 +01001562
Fred Shih37f05ef2014-07-16 18:38:08 -07001563ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1564ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1565ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1566ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001567ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1568ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1569ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1570
Fred Shih37f05ef2014-07-16 18:38:08 -07001571TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1572TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1573TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1574TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001575TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1576TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1577TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1578
Fred Shih37f05ef2014-07-16 18:38:08 -07001579TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1580TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001581TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1582TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1583
Fred Shih37f05ef2014-07-16 18:38:08 -07001584THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1585THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001586THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
Stephen Kyle0ff20d52014-10-22 15:23:46 +01001587THREE_ARG_REF_DOWNCALL art_quick_set64_instance, artSet64InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001588THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1589
1590// This is separated out as the argument order is different.
1591 .extern artSet64StaticFromCode
1592ENTRY art_quick_set64_static
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001593 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
1594 ldr x1, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] // Load referrer
Calin Juravlee460d1d2015-09-29 04:52:17 +01001595 // x2 contains the parameter
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001596 mov x3, xSELF // pass Thread::Current
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001597 bl artSet64StaticFromCode
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001598 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001599 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1600END art_quick_set64_static
1601
Matteo Franchindfd891a2014-04-30 12:17:17 +01001602 /*
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001603 * Entry from managed code to resolve a string, this stub will
1604 * check the dex cache for a matching string (the fast path), and if not found,
1605 * it will allocate a String and deliver an exception on error.
1606 * On success the String is returned. R0 holds the string index.
Matteo Franchindfd891a2014-04-30 12:17:17 +01001607 */
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001608
1609ENTRY art_quick_resolve_string
1610 ldr x1, [sp] // load referrer
1611 ldr w2, [x1, #ART_METHOD_DECLARING_CLASS_OFFSET] // load declaring class
1612 ldr x1, [x2, #DECLARING_CLASS_DEX_CACHE_STRINGS_OFFSET] // load string dex cache
Mathieu Chartiere3fbe382016-08-30 09:42:28 -07001613 ubfx x2, x0, #0, #STRING_DEX_CACHE_HASH_BITS // get masked string index into x2
Mathieu Chartier5f404332016-08-22 15:38:08 -07001614 ldr x2, [x1, x2, lsl #STRING_DEX_CACHE_ELEMENT_SIZE_SHIFT] // load dex cache pair into x2
1615 cmp x0, x2, lsr #32 // compare against upper 32 bits
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001616 bne .Lart_quick_resolve_string_slow_path
Mathieu Chartier5f404332016-08-22 15:38:08 -07001617 ubfx x0, x2, #0, #32 // extract lower 32 bits into x0
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001618#ifdef USE_READ_BARRIER
Mathieu Chartier5f404332016-08-22 15:38:08 -07001619 // Most common case: GC is not marking.
1620 ldr w3, [xSELF, #THREAD_IS_GC_MARKING_OFFSET]
1621 cbnz x3, .Lart_quick_resolve_string_marking
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001622#endif
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001623 ret
1624
Mathieu Chartier5f404332016-08-22 15:38:08 -07001625// Slow path case, the index did not match.
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001626.Lart_quick_resolve_string_slow_path:
1627 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
1628 mov x1, xSELF // pass Thread::Current
Mathieu Chartier5f404332016-08-22 15:38:08 -07001629 bl artResolveStringFromCode // (int32_t string_idx, Thread* self)
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001630 RESTORE_SAVE_REFS_ONLY_FRAME
1631 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1632
Mathieu Chartier5f404332016-08-22 15:38:08 -07001633// GC is marking case, need to check the mark bit.
1634.Lart_quick_resolve_string_marking:
1635 ldr x3, [x0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
1636 tbnz x3, #LOCK_WORD_MARK_BIT_SHIFT, .Lart_quick_resolve_string_no_rb
1637 // Save LR so that we can return, also x1 for alignment purposes.
Vladimir Marko215076b2016-09-07 18:05:55 +01001638 SAVE_TWO_REGS_INCREASE_FRAME x1, xLR, 16 // Save x1, LR.
Mathieu Chartier5f404332016-08-22 15:38:08 -07001639 bl artReadBarrierMark // Get the marked string back.
Vladimir Marko215076b2016-09-07 18:05:55 +01001640 RESTORE_TWO_REGS_DECREASE_FRAME x1, xLR, 16 // Restore registers.
Mathieu Chartier5f404332016-08-22 15:38:08 -07001641.Lart_quick_resolve_string_no_rb:
1642 ret
1643
Christina Wadsworthead8ba32016-08-08 13:08:05 -07001644END art_quick_resolve_string
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001645
Stuart Monteithb95a5342014-03-12 13:32:32 +00001646// Generate the allocation entrypoints for each allocator.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001647GENERATE_ALLOC_ENTRYPOINTS_FOR_NON_REGION_TLAB_ALLOCATORS
1648// Comment out allocators that have arm64 specific asm.
1649// GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB) implemented in asm
1650// GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB)
1651// GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_region_tlab, RegionTLAB)
1652GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_region_tlab, RegionTLAB)
1653// GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_region_tlab, RegionTLAB) implemented in asm
1654// GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_region_tlab, RegionTLAB)
1655GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_region_tlab, RegionTLAB)
1656GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_region_tlab, RegionTLAB)
1657GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_region_tlab, RegionTLAB)
1658GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_BYTES(_region_tlab, RegionTLAB)
1659GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_CHARS(_region_tlab, RegionTLAB)
1660GENERATE_ALLOC_ENTRYPOINTS_ALLOC_STRING_FROM_STRING(_region_tlab, RegionTLAB)
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001661
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001662// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1663ENTRY art_quick_alloc_object_rosalloc
1664 // Fast path rosalloc allocation.
1665 // x0: type_idx/return value, x1: ArtMethod*, xSELF(x19): Thread::Current
1666 // x2-x7: free.
1667 ldr x2, [x1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_64] // Load dex cache resolved types array
1668 // Load the class (x2)
1669 ldr w2, [x2, x0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1670 cbz x2, .Lart_quick_alloc_object_rosalloc_slow_path // Check null class
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001671 ldr x3, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET] // Check if the thread local
1672 // allocation stack has room.
1673 // ldp won't work due to large offset.
1674 ldr x4, [xSELF, #THREAD_LOCAL_ALLOC_STACK_END_OFFSET]
1675 cmp x3, x4
1676 bhs .Lart_quick_alloc_object_rosalloc_slow_path
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001677 ldr w3, [x2, #MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET] // Load the object size (x3)
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001678 cmp x3, #ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE // Check if the size is for a thread
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001679 // local allocation. Also does the
1680 // finalizable and initialization
1681 // checks.
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001682 bhs .Lart_quick_alloc_object_rosalloc_slow_path
1683 // Compute the rosalloc bracket index
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001684 // from the size. Since the size is
1685 // already aligned we can combine the
1686 // two shifts together.
1687 add x4, xSELF, x3, lsr #(ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT - POINTER_SIZE_SHIFT)
1688 // Subtract pointer size since ther
1689 // are no runs for 0 byte allocations
1690 // and the size is already aligned.
1691 ldr x4, [x4, #(THREAD_ROSALLOC_RUNS_OFFSET - __SIZEOF_POINTER__)]
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001692 // Load the free list head (x3). This
1693 // will be the return val.
1694 ldr x3, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)]
1695 cbz x3, .Lart_quick_alloc_object_rosalloc_slow_path
1696 // "Point of no slow path". Won't go to the slow path from here on. OK to clobber x0 and x1.
1697 ldr x1, [x3, #ROSALLOC_SLOT_NEXT_OFFSET] // Load the next pointer of the head
1698 // and update the list head with the
1699 // next pointer.
1700 str x1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)]
1701 // Store the class pointer in the
1702 // header. This also overwrites the
1703 // next pointer. The offsets are
1704 // asserted to match.
1705#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1706#error "Class pointer needs to overwrite next pointer."
1707#endif
1708 POISON_HEAP_REF w2
1709 str w2, [x3, #MIRROR_OBJECT_CLASS_OFFSET]
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001710 // Fence. This is "ish" not "ishst" so
1711 // that it also ensures ordering of
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001712 // the object size load with respect
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001713 // to later accesses to the class
1714 // object. Alternatively we could use
1715 // "ishst" if we use load-acquire for
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001716 // the class status load.
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001717 // Needs to be done before pushing on
1718 // allocation since Heap::VisitObjects
1719 // relies on seeing the class pointer.
1720 // b/28790624
1721 dmb ish
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001722 // Push the new object onto the thread
1723 // local allocation stack and
1724 // increment the thread local
1725 // allocation stack top.
1726 ldr x1, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET]
1727 str w3, [x1], #COMPRESSED_REFERENCE_SIZE // (Increment x1 as a side effect.)
1728 str x1, [xSELF, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET]
1729 // Decrement the size of the free list
1730 ldr w1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)]
1731 sub x1, x1, #1
1732 // TODO: consider combining this store
1733 // and the list head store above using
1734 // strd.
1735 str w1, [x4, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)]
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001736
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001737 mov x0, x3 // Set the return value and return.
1738 ret
1739.Lart_quick_alloc_object_rosalloc_slow_path:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001740 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001741 mov x2, xSELF // pass Thread::Current
1742 bl artAllocObjectFromCodeRosAlloc // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001743 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchi6f6244a2015-10-22 12:08:12 -07001744 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1745END art_quick_alloc_object_rosalloc
Stuart Monteithb95a5342014-03-12 13:32:32 +00001746
Mathieu Chartier8261d022016-08-08 09:41:04 -07001747
1748// The common fast path code for art_quick_alloc_array_region_tlab.
1749.macro ALLOC_ARRAY_TLAB_FAST_PATH slowPathLabel, xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2
1750 // Check null class
1751 cbz \wClass, \slowPathLabel
1752 ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED \slowPathLabel, \xClass, \wClass, \xCount, \wCount, \xTemp0, \wTemp0, \xTemp1, \wTemp1, \xTemp2, \wTemp2
1753.endm
1754
1755// The common fast path code for art_quick_alloc_array_region_tlab.
1756.macro ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED slowPathLabel, xClass, wClass, xCount, wCount, xTemp0, wTemp0, xTemp1, wTemp1, xTemp2, wTemp2
1757 // Array classes are never finalizable or uninitialized, no need to check.
1758 ldr \wTemp0, [\xClass, #MIRROR_CLASS_COMPONENT_TYPE_OFFSET] // Load component type
1759 UNPOISON_HEAP_REF \wTemp0
1760 ldr \wTemp0, [\xTemp0, #MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET]
1761 lsr \xTemp0, \xTemp0, #PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT // Component size shift is in high 16
1762 // bits.
1763 // xCount is holding a 32 bit value,
1764 // it can not overflow.
1765 lsl \xTemp1, \xCount, \xTemp0 // Calculate data size
1766 // Add array data offset and alignment.
1767 add \xTemp1, \xTemp1, #(MIRROR_INT_ARRAY_DATA_OFFSET + OBJECT_ALIGNMENT_MASK)
1768#if MIRROR_LONG_ARRAY_DATA_OFFSET != MIRROR_INT_ARRAY_DATA_OFFSET + 4
1769#error Long array data offset must be 4 greater than int array data offset.
1770#endif
1771
1772 add \xTemp0, \xTemp0, #1 // Add 4 to the length only if the
1773 // component size shift is 3
1774 // (for 64 bit alignment).
1775 and \xTemp0, \xTemp0, #4
1776 add \xTemp1, \xTemp1, \xTemp0
Mathieu Chartier2ee98f22016-08-10 10:08:58 -07001777 and \xTemp1, \xTemp1, #OBJECT_ALIGNMENT_MASK_TOGGLED64 // Apply alignemnt mask
1778 // (addr + 7) & ~7. The mask must
1779 // be 64 bits to keep high bits in
1780 // case of overflow.
1781 // Negative sized arrays are handled here since xCount holds a zero extended 32 bit value.
1782 // Negative ints become large 64 bit unsigned ints which will always be larger than max signed
1783 // 32 bit int. Since the max shift for arrays is 3, it can not become a negative 64 bit int.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001784 cmp \xTemp1, #MIN_LARGE_OBJECT_THRESHOLD // Possibly a large object, go slow
1785 bhs \slowPathLabel // path.
1786
1787 ldr \xTemp0, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Check tlab for space, note that
1788 // we use (end - begin) to handle
1789 // negative size arrays. It is
1790 // assumed that a negative size will
1791 // always be greater unsigned than
1792 // region size.
1793 ldr \xTemp2, [xSELF, #THREAD_LOCAL_END_OFFSET]
1794 sub \xTemp2, \xTemp2, \xTemp0
1795 cmp \xTemp1, \xTemp2
1796 bhi \slowPathLabel
Mathieu Chartier8261d022016-08-08 09:41:04 -07001797 // "Point of no slow path". Won't go to the slow path from here on. OK to clobber x0 and x1.
1798 // Move old thread_local_pos to x0
1799 // for the return value.
1800 mov x0, \xTemp0
1801 add \xTemp0, \xTemp0, \xTemp1
1802 str \xTemp0, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Store new thread_local_pos.
1803 ldr \xTemp0, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] // Increment thread_local_objects.
1804 add \xTemp0, \xTemp0, #1
1805 str \xTemp0, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET]
1806 POISON_HEAP_REF \wClass
1807 str \wClass, [x0, #MIRROR_OBJECT_CLASS_OFFSET] // Store the class pointer.
1808 str \wCount, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] // Store the array length.
1809 // Fence.
1810 dmb ishst
1811 ret
1812.endm
1813
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001814// The common fast path code for art_quick_alloc_object_tlab and art_quick_alloc_object_region_tlab.
1815//
1816// x0: type_idx/return value, x1: ArtMethod*, x2: Class*, xSELF(x19): Thread::Current
1817// x3-x7: free.
1818// Need to preserve x0 and x1 to the slow path.
1819.macro ALLOC_OBJECT_TLAB_FAST_PATH slowPathLabel
1820 cbz x2, \slowPathLabel // Check null class
Mathieu Chartier8261d022016-08-08 09:41:04 -07001821 ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED \slowPathLabel
1822.endm
1823
Mathieu Chartier93bbee02016-08-31 09:38:40 -07001824// TODO: delete ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED since it is the same as
1825// ALLOC_OBJECT_TLAB_FAST_PATH_INITIALIZED.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001826.macro ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED slowPathLabel
Mathieu Chartier8261d022016-08-08 09:41:04 -07001827 ALLOC_OBJECT_TLAB_FAST_PATH_INITIALIZED \slowPathLabel
1828.endm
1829
1830.macro ALLOC_OBJECT_TLAB_FAST_PATH_INITIALIZED slowPathLabel
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001831 ldr x4, [xSELF, #THREAD_LOCAL_POS_OFFSET]
1832 ldr x5, [xSELF, #THREAD_LOCAL_END_OFFSET]
Mathieu Chartier93bbee02016-08-31 09:38:40 -07001833 ldr w7, [x2, #MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET] // Load the object size (x7).
1834 add x6, x4, x7 // Add object size to tlab pos.
1835 cmp x6, x5 // Check if it fits, overflow works
1836 // since the tlab pos and end are 32
1837 // bit values.
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001838 bhi \slowPathLabel
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001839 // "Point of no slow path". Won't go to the slow path from here on. OK to clobber x0 and x1.
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001840 mov x0, x4
Mathieu Chartier93bbee02016-08-31 09:38:40 -07001841 str x6, [xSELF, #THREAD_LOCAL_POS_OFFSET] // Store new thread_local_pos.
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001842 ldr x5, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET] // Increment thread_local_objects.
1843 add x5, x5, #1
1844 str x5, [xSELF, #THREAD_LOCAL_OBJECTS_OFFSET]
1845 POISON_HEAP_REF w2
1846 str w2, [x0, #MIRROR_OBJECT_CLASS_OFFSET] // Store the class pointer.
1847 // Fence. This is "ish" not "ishst" so
1848 // that the code after this allocation
1849 // site will see the right values in
1850 // the fields of the class.
1851 // Alternatively we could use "ishst"
1852 // if we use load-acquire for the
Mathieu Chartier93bbee02016-08-31 09:38:40 -07001853 // object size load.)
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001854 dmb ish
1855 ret
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001856.endm
1857
1858// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB).
1859ENTRY art_quick_alloc_object_tlab
1860 // Fast path tlab allocation.
1861 // x0: type_idx/return value, x1: ArtMethod*, xSELF(x19): Thread::Current
1862 // x2-x7: free.
1863#if defined(USE_READ_BARRIER)
1864 mvn x0, xzr // Read barrier not supported here.
1865 ret // Return -1.
1866#endif
1867 ldr x2, [x1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_64] // Load dex cache resolved types array
1868 // Load the class (x2)
1869 ldr w2, [x2, x0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1870 ALLOC_OBJECT_TLAB_FAST_PATH .Lart_quick_alloc_object_tlab_slow_path
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001871.Lart_quick_alloc_object_tlab_slow_path:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001872 SETUP_SAVE_REFS_ONLY_FRAME // Save callee saves in case of GC.
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001873 mov x2, xSELF // Pass Thread::Current.
1874 bl artAllocObjectFromCodeTLAB // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001875 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001876 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1877END art_quick_alloc_object_tlab
1878
Mathieu Chartier8261d022016-08-08 09:41:04 -07001879// The common code for art_quick_alloc_object_*region_tlab
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001880.macro GENERATE_ALLOC_OBJECT_REGION_TLAB name, entrypoint, fast_path, is_resolved, read_barrier
Mathieu Chartier8261d022016-08-08 09:41:04 -07001881ENTRY \name
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001882 // Fast path region tlab allocation.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001883 // x0: type_idx/resolved class/return value, x1: ArtMethod*, xSELF(x19): Thread::Current
1884 // If is_resolved is 1 then x0 is the resolved type, otherwise it is the index.
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001885 // x2-x7: free.
1886#if !defined(USE_READ_BARRIER)
1887 mvn x0, xzr // Read barrier must be enabled here.
1888 ret // Return -1.
1889#endif
Mathieu Chartier8261d022016-08-08 09:41:04 -07001890.if \is_resolved
1891 mov x2, x0 // class is actually stored in x0 already
1892.else
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001893 ldr x2, [x1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_64] // Load dex cache resolved types array
1894 // Load the class (x2)
1895 ldr w2, [x2, x0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001896 // If the class is null, go slow path. The check is required to read the lock word.
1897 cbz w2, .Lslow_path\name
Mathieu Chartier8261d022016-08-08 09:41:04 -07001898.endif
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001899.if \read_barrier
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001900 // Most common case: GC is not marking.
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001901 ldr w3, [xSELF, #THREAD_IS_GC_MARKING_OFFSET]
Mathieu Chartier8261d022016-08-08 09:41:04 -07001902 cbnz x3, .Lmarking\name
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001903.endif
Mathieu Chartier8261d022016-08-08 09:41:04 -07001904.Ldo_allocation\name:
1905 \fast_path .Lslow_path\name
1906.Lmarking\name:
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001907.if \read_barrier
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001908 // GC is marking, check the lock word of the class for the mark bit.
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001909 // Class is not null, check mark bit in lock word.
1910 ldr w3, [x2, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
1911 // If the bit is not zero, do the allocation.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001912 tbnz w3, #LOCK_WORD_MARK_BIT_SHIFT, .Ldo_allocation\name
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001913 // The read barrier slow path. Mark
1914 // the class.
Vladimir Marko215076b2016-09-07 18:05:55 +01001915 SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 32 // Save registers (x0, x1, lr).
1916 SAVE_REG xLR, 24 // Align sp by 16 bytes.
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001917 mov x0, x2 // Pass the class as the first param.
1918 bl artReadBarrierMark
1919 mov x2, x0 // Get the (marked) class back.
Vladimir Marko215076b2016-09-07 18:05:55 +01001920 RESTORE_REG xLR, 24
1921 RESTORE_TWO_REGS_DECREASE_FRAME x0, x1, 32 // Restore registers.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001922 b .Ldo_allocation\name
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001923.endif
Mathieu Chartier8261d022016-08-08 09:41:04 -07001924.Lslow_path\name:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001925 SETUP_SAVE_REFS_ONLY_FRAME // Save callee saves in case of GC.
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001926 mov x2, xSELF // Pass Thread::Current.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001927 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*)
1928 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchicd773782016-04-07 17:18:24 -07001929 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Mathieu Chartier8261d022016-08-08 09:41:04 -07001930END \name
1931.endm
1932
Mathieu Chartierb6ec5d72016-08-30 15:06:54 -07001933// Use ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED since the null check is already done in GENERATE_ALLOC_OBJECT_TLAB.
1934GENERATE_ALLOC_OBJECT_REGION_TLAB art_quick_alloc_object_region_tlab, artAllocObjectFromCodeRegionTLAB, ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED, 0, 1
1935// No read barrier for the resolved or initialized cases since the caller is responsible for the
1936// read barrier due to the to-space invariant.
1937GENERATE_ALLOC_OBJECT_REGION_TLAB art_quick_alloc_object_resolved_region_tlab, artAllocObjectFromCodeResolvedRegionTLAB, ALLOC_OBJECT_TLAB_FAST_PATH_RESOLVED, 1, 0
1938GENERATE_ALLOC_OBJECT_REGION_TLAB art_quick_alloc_object_initialized_region_tlab, artAllocObjectFromCodeInitializedRegionTLAB, ALLOC_OBJECT_TLAB_FAST_PATH_INITIALIZED, 1, 0
1939
1940// TODO: We could use this macro for the normal tlab allocator too.
Mathieu Chartier8261d022016-08-08 09:41:04 -07001941
1942// The common code for art_quick_alloc_array_*region_tlab
1943.macro GENERATE_ALLOC_ARRAY_REGION_TLAB name, entrypoint, fast_path, is_resolved
1944ENTRY \name
1945 // Fast path array allocation for region tlab allocation.
1946 // x0: uint32_t type_idx
1947 // x1: int32_t component_count
1948 // x2: ArtMethod* method
1949 // x3-x7: free.
1950#if !defined(USE_READ_BARRIER)
1951 mvn x0, xzr // Read barrier must be enabled here.
1952 ret // Return -1.
1953#endif
1954.if \is_resolved
1955 mov x3, x0
1956 // If already resolved, class is stored in x0
1957.else
1958 ldr x3, [x2, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_64] // Load dex cache resolved types array
1959 // Load the class (x2)
1960 ldr w3, [x3, x0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1961.endif
1962 // Most common case: GC is not marking.
1963 ldr w4, [xSELF, #THREAD_IS_GC_MARKING_OFFSET]
1964 cbnz x4, .Lmarking\name
1965.Ldo_allocation\name:
1966 \fast_path .Lslow_path\name, x3, w3, x1, w1, x4, w4, x5, w5, x6, w6
1967.Lmarking\name:
1968 // GC is marking, check the lock word of the class for the mark bit.
1969 // If the class is null, go slow path. The check is required to read the lock word.
1970 cbz w3, .Lslow_path\name
1971 // Class is not null, check mark bit in lock word.
1972 ldr w4, [x3, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
1973 // If the bit is not zero, do the allocation.
1974 tbnz w4, #LOCK_WORD_MARK_BIT_SHIFT, .Ldo_allocation\name
1975 // The read barrier slow path. Mark
1976 // the class.
1977 stp x0, x1, [sp, #-32]! // Save registers (x0, x1, x2, lr).
1978 stp x2, xLR, [sp, #16]
1979 mov x0, x3 // Pass the class as the first param.
1980 bl artReadBarrierMark
1981 mov x3, x0 // Get the (marked) class back.
1982 ldp x2, xLR, [sp, #16]
1983 ldp x0, x1, [sp], #32 // Restore registers.
1984 b .Ldo_allocation\name
1985.Lslow_path\name:
1986 // x0: uint32_t type_idx / mirror::Class* klass (if resolved)
1987 // x1: int32_t component_count
1988 // x2: ArtMethod* method
1989 // x3: Thread* self
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001990 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves in case of GC
Mathieu Chartier8261d022016-08-08 09:41:04 -07001991 mov x3, xSELF // pass Thread::Current
1992 bl \entrypoint
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001993 RESTORE_SAVE_REFS_ONLY_FRAME
Mathieu Chartier8261d022016-08-08 09:41:04 -07001994 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1995END \name
1996.endm
1997
1998GENERATE_ALLOC_ARRAY_REGION_TLAB art_quick_alloc_array_region_tlab, artAllocArrayFromCodeRegionTLAB, ALLOC_ARRAY_TLAB_FAST_PATH, 0
1999// TODO: art_quick_alloc_array_resolved_region_tlab seems to not get called. Investigate compiler.
2000GENERATE_ALLOC_ARRAY_REGION_TLAB art_quick_alloc_array_resolved_region_tlab, artAllocArrayFromCodeResolvedRegionTLAB, ALLOC_ARRAY_TLAB_FAST_PATH_RESOLVED, 1
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08002001
Zheng Xu48241e72014-05-23 11:52:42 +08002002 /*
Zheng Xu69a50302015-04-14 20:04:41 +08002003 * Called by managed code when the thread has been asked to suspend.
Zheng Xu48241e72014-05-23 11:52:42 +08002004 */
2005 .extern artTestSuspendFromCode
2006ENTRY art_quick_test_suspend
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002007 SETUP_SAVE_EVERYTHING_FRAME // save callee saves for stack crawl
Zheng Xu48241e72014-05-23 11:52:42 +08002008 mov x0, xSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002009 bl artTestSuspendFromCode // (Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002010 RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +01002011 ret
Zheng Xu48241e72014-05-23 11:52:42 +08002012END art_quick_test_suspend
Stuart Monteithb95a5342014-03-12 13:32:32 +00002013
Stuart Monteithd5c78f42014-06-11 16:44:46 +01002014ENTRY art_quick_implicit_suspend
2015 mov x0, xSELF
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002016 SETUP_SAVE_REFS_ONLY_FRAME // save callee saves for stack crawl
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002017 bl artTestSuspendFromCode // (Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002018 RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN
Stuart Monteithd5c78f42014-06-11 16:44:46 +01002019END art_quick_implicit_suspend
2020
Andreas Gampee62a07e2014-03-26 14:53:21 -07002021 /*
2022 * Called by managed code that is attempting to call a method on a proxy class. On entry
2023 * x0 holds the proxy method and x1 holds the receiver; The frame size of the invoked proxy
2024 * method agrees with a ref and args callee save frame.
2025 */
2026 .extern artQuickProxyInvokeHandler
2027ENTRY art_quick_proxy_invoke_handler
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002028 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0
Andreas Gampee62a07e2014-03-26 14:53:21 -07002029 mov x2, xSELF // pass Thread::Current
2030 mov x3, sp // pass SP
2031 bl artQuickProxyInvokeHandler // (Method* proxy method, receiver, Thread*, SP)
Serban Constantinescu9bd88b02015-04-22 16:24:46 +01002032 ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET]
Andreas Gampee62a07e2014-03-26 14:53:21 -07002033 cbnz x2, .Lexception_in_proxy // success if no exception is pending
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002034 RESTORE_SAVE_REFS_AND_ARGS_FRAME // Restore frame
Andreas Gamped1e91672014-06-02 22:50:05 -07002035 fmov d0, x0 // Store result in d0 in case it was float or double
Andreas Gampee62a07e2014-03-26 14:53:21 -07002036 ret // return on success
2037.Lexception_in_proxy:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002038 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Andreas Gampee62a07e2014-03-26 14:53:21 -07002039 DELIVER_PENDING_EXCEPTION
2040END art_quick_proxy_invoke_handler
Stuart Monteithb95a5342014-03-12 13:32:32 +00002041
Andreas Gampe51f76352014-05-21 08:28:48 -07002042 /*
Nicolas Geoffray796d6302016-03-13 22:22:31 +00002043 * Called to resolve an imt conflict.
2044 * x0 is the conflict ArtMethod.
2045 * xIP1 is a hidden argument that holds the target interface method's dex method index.
2046 *
2047 * Note that this stub writes to xIP0, xIP1, and x0.
Andreas Gampe51f76352014-05-21 08:28:48 -07002048 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -07002049 .extern artInvokeInterfaceTrampoline
Andreas Gampe51f76352014-05-21 08:28:48 -07002050ENTRY art_quick_imt_conflict_trampoline
Nicolas Geoffray796d6302016-03-13 22:22:31 +00002051 ldr xIP0, [sp, #0] // Load referrer
2052 ldr xIP0, [xIP0, #ART_METHOD_DEX_CACHE_METHODS_OFFSET_64] // Load dex cache methods array
2053 ldr xIP0, [xIP0, xIP1, lsl #POINTER_SIZE_SHIFT] // Load interface method
2054 ldr xIP1, [x0, #ART_METHOD_JNI_OFFSET_64] // Load ImtConflictTable
2055 ldr x0, [xIP1] // Load first entry in ImtConflictTable.
2056.Limt_table_iterate:
2057 cmp x0, xIP0
2058 // Branch if found. Benchmarks have shown doing a branch here is better.
2059 beq .Limt_table_found
2060 // If the entry is null, the interface method is not in the ImtConflictTable.
2061 cbz x0, .Lconflict_trampoline
2062 // Iterate over the entries of the ImtConflictTable.
2063 ldr x0, [xIP1, #(2 * __SIZEOF_POINTER__)]!
2064 b .Limt_table_iterate
2065.Limt_table_found:
Goran Jakovljevic59028d92016-03-29 18:05:03 +02002066 // We successfully hit an entry in the table. Load the target method
Nicolas Geoffray796d6302016-03-13 22:22:31 +00002067 // and jump to it.
2068 ldr x0, [xIP1, #__SIZEOF_POINTER__]
2069 ldr xIP0, [x0, #ART_METHOD_QUICK_CODE_OFFSET_64]
2070 br xIP0
2071.Lconflict_trampoline:
2072 // Call the runtime stub to populate the ImtConflictTable and jump to the
2073 // resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07002074 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Andreas Gampe51f76352014-05-21 08:28:48 -07002075END art_quick_imt_conflict_trampoline
Stuart Monteithb95a5342014-03-12 13:32:32 +00002076
2077ENTRY art_quick_resolution_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002078 SETUP_SAVE_REFS_AND_ARGS_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +00002079 mov x2, xSELF
2080 mov x3, sp
2081 bl artQuickResolutionTrampoline // (called, receiver, Thread*, SP)
Matteo Franchindfd891a2014-04-30 12:17:17 +01002082 cbz x0, 1f
Zheng Xub551fdc2014-07-25 11:49:42 +08002083 mov xIP0, x0 // Remember returned code pointer in xIP0.
Mathieu Chartiere401d142015-04-22 13:56:20 -07002084 ldr x0, [sp, #0] // artQuickResolutionTrampoline puts called method in *SP.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002085 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Zheng Xub551fdc2014-07-25 11:49:42 +08002086 br xIP0
Stuart Monteithb95a5342014-03-12 13:32:32 +000020871:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002088 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +00002089 DELIVER_PENDING_EXCEPTION
2090END art_quick_resolution_trampoline
2091
2092/*
2093 * Generic JNI frame layout:
2094 *
2095 * #-------------------#
2096 * | |
2097 * | caller method... |
2098 * #-------------------# <--- SP on entry
2099 * | Return X30/LR |
2100 * | X29/FP | callee save
2101 * | X28 | callee save
2102 * | X27 | callee save
2103 * | X26 | callee save
2104 * | X25 | callee save
2105 * | X24 | callee save
2106 * | X23 | callee save
2107 * | X22 | callee save
2108 * | X21 | callee save
2109 * | X20 | callee save
Zheng Xu69a50302015-04-14 20:04:41 +08002110 * | X19 | callee save
Stuart Monteithb95a5342014-03-12 13:32:32 +00002111 * | X7 | arg7
2112 * | X6 | arg6
2113 * | X5 | arg5
2114 * | X4 | arg4
2115 * | X3 | arg3
2116 * | X2 | arg2
2117 * | X1 | arg1
Stuart Monteithb95a5342014-03-12 13:32:32 +00002118 * | D7 | float arg 8
2119 * | D6 | float arg 7
2120 * | D5 | float arg 6
2121 * | D4 | float arg 5
2122 * | D3 | float arg 4
2123 * | D2 | float arg 3
2124 * | D1 | float arg 2
2125 * | D0 | float arg 1
Andreas Gampecf4035a2014-05-28 22:43:01 -07002126 * | Method* | <- X0
Stuart Monteithb95a5342014-03-12 13:32:32 +00002127 * #-------------------#
2128 * | local ref cookie | // 4B
Mathieu Chartier421c5372014-05-14 14:11:40 -07002129 * | handle scope size | // 4B
Stuart Monteithb95a5342014-03-12 13:32:32 +00002130 * #-------------------#
2131 * | JNI Call Stack |
2132 * #-------------------# <--- SP on native call
2133 * | |
2134 * | Stack for Regs | The trampoline assembly will pop these values
2135 * | | into registers for native call
2136 * #-------------------#
2137 * | Native code ptr |
2138 * #-------------------#
2139 * | Free scratch |
2140 * #-------------------#
2141 * | Ptr to (1) | <--- SP
2142 * #-------------------#
2143 */
2144 /*
2145 * Called to do a generic JNI down-call
2146 */
Ian Rogers6f3dbba2014-10-14 17:41:57 -07002147ENTRY art_quick_generic_jni_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002148 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_X0
Stuart Monteithb95a5342014-03-12 13:32:32 +00002149
2150 // Save SP , so we can have static CFI info.
2151 mov x28, sp
2152 .cfi_def_cfa_register x28
2153
2154 // This looks the same, but is different: this will be updated to point to the bottom
Mathieu Chartiereb8167a2014-05-07 15:43:14 -07002155 // of the frame when the handle scope is inserted.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002156 mov xFP, sp
2157
Zheng Xub551fdc2014-07-25 11:49:42 +08002158 mov xIP0, #5120
2159 sub sp, sp, xIP0
Stuart Monteithb95a5342014-03-12 13:32:32 +00002160
2161 // prepare for artQuickGenericJniTrampoline call
2162 // (Thread*, SP)
2163 // x0 x1 <= C calling convention
2164 // xSELF xFP <= where they are
2165
2166 mov x0, xSELF // Thread*
2167 mov x1, xFP
2168 bl artQuickGenericJniTrampoline // (Thread*, sp)
2169
Andreas Gampec200a4a2014-06-16 18:39:09 -07002170 // The C call will have registered the complete save-frame on success.
2171 // The result of the call is:
2172 // x0: pointer to native code, 0 on error.
2173 // x1: pointer to the bottom of the used area of the alloca, can restore stack till there.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002174
Andreas Gampec200a4a2014-06-16 18:39:09 -07002175 // Check for error = 0.
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002176 cbz x0, .Lexception_in_native
Stuart Monteithb95a5342014-03-12 13:32:32 +00002177
Andreas Gampec200a4a2014-06-16 18:39:09 -07002178 // Release part of the alloca.
2179 mov sp, x1
Stuart Monteithb95a5342014-03-12 13:32:32 +00002180
Andreas Gampec200a4a2014-06-16 18:39:09 -07002181 // Save the code pointer
2182 mov xIP0, x0
Stuart Monteithb95a5342014-03-12 13:32:32 +00002183
2184 // Load parameters from frame into registers.
2185 // TODO Check with artQuickGenericJniTrampoline.
2186 // Also, check again APPCS64 - the stack arguments are interleaved.
Andreas Gampec200a4a2014-06-16 18:39:09 -07002187 ldp x0, x1, [sp]
2188 ldp x2, x3, [sp, #16]
2189 ldp x4, x5, [sp, #32]
2190 ldp x6, x7, [sp, #48]
Stuart Monteithb95a5342014-03-12 13:32:32 +00002191
Andreas Gampec200a4a2014-06-16 18:39:09 -07002192 ldp d0, d1, [sp, #64]
2193 ldp d2, d3, [sp, #80]
2194 ldp d4, d5, [sp, #96]
2195 ldp d6, d7, [sp, #112]
Stuart Monteithb95a5342014-03-12 13:32:32 +00002196
Andreas Gampec200a4a2014-06-16 18:39:09 -07002197 add sp, sp, #128
Stuart Monteithb95a5342014-03-12 13:32:32 +00002198
Zheng Xub551fdc2014-07-25 11:49:42 +08002199 blr xIP0 // native call.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002200
2201 // result sign extension is handled in C code
2202 // prepare for artQuickGenericJniEndTrampoline call
Andreas Gampec200a4a2014-06-16 18:39:09 -07002203 // (Thread*, result, result_f)
2204 // x0 x1 x2 <= C calling convention
Serban Constantinescu9bd88b02015-04-22 16:24:46 +01002205 mov x1, x0 // Result (from saved).
2206 mov x0, xSELF // Thread register.
Andreas Gampec200a4a2014-06-16 18:39:09 -07002207 fmov x2, d0 // d0 will contain floating point result, but needs to go into x2
Stuart Monteithb95a5342014-03-12 13:32:32 +00002208
2209 bl artQuickGenericJniEndTrampoline
2210
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002211 // Pending exceptions possible.
Serban Constantinescu9bd88b02015-04-22 16:24:46 +01002212 ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET]
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002213 cbnz x2, .Lexception_in_native
2214
Stuart Monteithb95a5342014-03-12 13:32:32 +00002215 // Tear down the alloca.
2216 mov sp, x28
2217 .cfi_def_cfa_register sp
2218
Stuart Monteithb95a5342014-03-12 13:32:32 +00002219 // Tear down the callee-save frame.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002220 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +00002221
2222 // store into fpr, for when it's a fpr return...
2223 fmov d0, x0
2224 ret
2225
Stuart Monteithb95a5342014-03-12 13:32:32 +00002226.Lexception_in_native:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002227 // Move to x1 then sp to please assembler.
2228 ldr x1, [xSELF, # THREAD_TOP_QUICK_FRAME_OFFSET]
2229 mov sp, x1
2230 .cfi_def_cfa_register sp
2231 # This will create a new save-all frame, required by the runtime.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002232 DELIVER_PENDING_EXCEPTION
Stuart Monteithb95a5342014-03-12 13:32:32 +00002233END art_quick_generic_jni_trampoline
2234
2235/*
2236 * Called to bridge from the quick to interpreter ABI. On entry the arguments match those
2237 * of a quick call:
2238 * x0 = method being called/to bridge to.
2239 * x1..x7, d0..d7 = arguments to that method.
2240 */
Ian Rogers6f3dbba2014-10-14 17:41:57 -07002241ENTRY art_quick_to_interpreter_bridge
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002242 SETUP_SAVE_REFS_AND_ARGS_FRAME // Set up frame and save arguments.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002243
2244 // x0 will contain mirror::ArtMethod* method.
2245 mov x1, xSELF // How to get Thread::Current() ???
2246 mov x2, sp
2247
2248 // uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self,
2249 // mirror::ArtMethod** sp)
2250 bl artQuickToInterpreterBridge
2251
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002252 RESTORE_SAVE_REFS_AND_ARGS_FRAME // TODO: no need to restore arguments in this case.
Stuart Monteithb95a5342014-03-12 13:32:32 +00002253
2254 fmov d0, x0
2255
2256 RETURN_OR_DELIVER_PENDING_EXCEPTION
2257END art_quick_to_interpreter_bridge
2258
Andreas Gamped58342c2014-06-05 14:18:08 -07002259
2260//
2261// Instrumentation-related stubs
2262//
2263 .extern artInstrumentationMethodEntryFromCode
2264ENTRY art_quick_instrumentation_entry
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002265 SETUP_SAVE_REFS_AND_ARGS_FRAME
Andreas Gamped58342c2014-06-05 14:18:08 -07002266
Zheng Xub551fdc2014-07-25 11:49:42 +08002267 mov x20, x0 // Preserve method reference in a callee-save.
Andreas Gamped58342c2014-06-05 14:18:08 -07002268
2269 mov x2, xSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002270 mov x3, xLR
2271 bl artInstrumentationMethodEntryFromCode // (Method*, Object*, Thread*, LR)
Andreas Gamped58342c2014-06-05 14:18:08 -07002272
Zheng Xub551fdc2014-07-25 11:49:42 +08002273 mov xIP0, x0 // x0 = result of call.
2274 mov x0, x20 // Reload method reference.
Andreas Gamped58342c2014-06-05 14:18:08 -07002275
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002276 RESTORE_SAVE_REFS_AND_ARGS_FRAME // Note: will restore xSELF
Andreas Gamped58342c2014-06-05 14:18:08 -07002277 adr xLR, art_quick_instrumentation_exit
Zheng Xub551fdc2014-07-25 11:49:42 +08002278 br xIP0 // Tail-call method with lr set to art_quick_instrumentation_exit.
Andreas Gamped58342c2014-06-05 14:18:08 -07002279END art_quick_instrumentation_entry
2280
2281 .extern artInstrumentationMethodExitFromCode
2282ENTRY art_quick_instrumentation_exit
2283 mov xLR, #0 // Clobber LR for later checks.
2284
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002285 SETUP_SAVE_REFS_ONLY_FRAME
Andreas Gamped58342c2014-06-05 14:18:08 -07002286
2287 // We need to save x0 and d0. We could use a callee-save from SETUP_REF_ONLY, but then
2288 // we would need to fully restore it. As there are a lot of callee-save registers, it seems
2289 // easier to have an extra small stack area.
2290
Sebastien Hertz70f8d4b2014-06-19 11:51:41 +02002291 str x0, [sp, #-16]! // Save integer result.
Andreas Gamped58342c2014-06-05 14:18:08 -07002292 .cfi_adjust_cfa_offset 16
2293 str d0, [sp, #8] // Save floating-point result.
2294
Andreas Gamped58342c2014-06-05 14:18:08 -07002295 add x1, sp, #16 // Pass SP.
2296 mov x2, x0 // Pass integer result.
2297 fmov x3, d0 // Pass floating-point result.
Sebastien Hertz70f8d4b2014-06-19 11:51:41 +02002298 mov x0, xSELF // Pass Thread.
Andreas Gamped58342c2014-06-05 14:18:08 -07002299 bl artInstrumentationMethodExitFromCode // (Thread*, SP, gpr_res, fpr_res)
2300
Zheng Xub551fdc2014-07-25 11:49:42 +08002301 mov xIP0, x0 // Return address from instrumentation call.
Andreas Gamped58342c2014-06-05 14:18:08 -07002302 mov xLR, x1 // r1 is holding link register if we're to bounce to deoptimize
2303
2304 ldr d0, [sp, #8] // Restore floating-point result.
Vladimir Marko215076b2016-09-07 18:05:55 +01002305 ldr x0, [sp], #16 // Restore integer result, and drop stack area.
Andreas Gamped58342c2014-06-05 14:18:08 -07002306 .cfi_adjust_cfa_offset 16
2307
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002308 POP_SAVE_REFS_ONLY_FRAME
Andreas Gamped58342c2014-06-05 14:18:08 -07002309
Zheng Xub551fdc2014-07-25 11:49:42 +08002310 br xIP0 // Tail-call out.
Andreas Gamped58342c2014-06-05 14:18:08 -07002311END art_quick_instrumentation_exit
2312
2313 /*
2314 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
2315 * will long jump to the upcall with a special exception of -1.
2316 */
2317 .extern artDeoptimize
2318ENTRY art_quick_deoptimize
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002319 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Andreas Gamped58342c2014-06-05 14:18:08 -07002320 mov x0, xSELF // Pass thread.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002321 bl artDeoptimize // artDeoptimize(Thread*)
Serban Constantinescu86797a72014-06-19 16:17:56 +01002322 brk 0
Andreas Gamped58342c2014-06-05 14:18:08 -07002323END art_quick_deoptimize
2324
Sebastien Hertz07474662015-08-25 15:12:33 +00002325 /*
2326 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
2327 * will long jump to the upcall with a special exception of -1.
2328 */
2329 .extern artDeoptimizeFromCompiledCode
2330ENTRY art_quick_deoptimize_from_compiled_code
Vladimir Marko239d6ea2016-09-05 10:44:04 +01002331 SETUP_SAVE_EVERYTHING_FRAME
Sebastien Hertz07474662015-08-25 15:12:33 +00002332 mov x0, xSELF // Pass thread.
2333 bl artDeoptimizeFromCompiledCode // artDeoptimizeFromCompiledCode(Thread*)
2334 brk 0
2335END art_quick_deoptimize_from_compiled_code
2336
Andreas Gamped58342c2014-06-05 14:18:08 -07002337
Serban Constantinescu169489b2014-06-11 16:43:35 +01002338 /*
2339 * String's indexOf.
2340 *
2341 * TODO: Not very optimized.
2342 * On entry:
2343 * x0: string object (known non-null)
2344 * w1: char to match (known <= 0xFFFF)
2345 * w2: Starting offset in string data
2346 */
2347ENTRY art_quick_indexof
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002348 ldr w3, [x0, #MIRROR_STRING_COUNT_OFFSET]
Jeff Hao848f70a2014-01-15 13:49:50 -08002349 add x0, x0, #MIRROR_STRING_VALUE_OFFSET
Serban Constantinescu169489b2014-06-11 16:43:35 +01002350
2351 /* Clamp start to [0..count] */
2352 cmp w2, #0
2353 csel w2, wzr, w2, lt
2354 cmp w2, w3
2355 csel w2, w3, w2, gt
2356
Serban Constantinescu169489b2014-06-11 16:43:35 +01002357 /* Save a copy to compute result */
2358 mov x5, x0
2359
2360 /* Build pointer to start of data to compare and pre-bias */
2361 add x0, x0, x2, lsl #1
2362 sub x0, x0, #2
2363
2364 /* Compute iteration count */
2365 sub w2, w3, w2
2366
2367 /*
2368 * At this point we have:
2369 * x0: start of the data to test
2370 * w1: char to compare
2371 * w2: iteration count
2372 * x5: original start of string data
2373 */
2374
2375 subs w2, w2, #4
2376 b.lt .Lindexof_remainder
2377
2378.Lindexof_loop4:
2379 ldrh w6, [x0, #2]!
2380 ldrh w7, [x0, #2]!
Zheng Xub551fdc2014-07-25 11:49:42 +08002381 ldrh wIP0, [x0, #2]!
2382 ldrh wIP1, [x0, #2]!
Serban Constantinescu169489b2014-06-11 16:43:35 +01002383 cmp w6, w1
2384 b.eq .Lmatch_0
2385 cmp w7, w1
2386 b.eq .Lmatch_1
Zheng Xub551fdc2014-07-25 11:49:42 +08002387 cmp wIP0, w1
Serban Constantinescu169489b2014-06-11 16:43:35 +01002388 b.eq .Lmatch_2
Zheng Xub551fdc2014-07-25 11:49:42 +08002389 cmp wIP1, w1
Serban Constantinescu169489b2014-06-11 16:43:35 +01002390 b.eq .Lmatch_3
2391 subs w2, w2, #4
2392 b.ge .Lindexof_loop4
2393
2394.Lindexof_remainder:
2395 adds w2, w2, #4
2396 b.eq .Lindexof_nomatch
2397
2398.Lindexof_loop1:
2399 ldrh w6, [x0, #2]!
2400 cmp w6, w1
2401 b.eq .Lmatch_3
2402 subs w2, w2, #1
2403 b.ne .Lindexof_loop1
2404
2405.Lindexof_nomatch:
2406 mov x0, #-1
2407 ret
2408
2409.Lmatch_0:
2410 sub x0, x0, #6
2411 sub x0, x0, x5
2412 asr x0, x0, #1
2413 ret
2414.Lmatch_1:
2415 sub x0, x0, #4
2416 sub x0, x0, x5
2417 asr x0, x0, #1
2418 ret
2419.Lmatch_2:
2420 sub x0, x0, #2
2421 sub x0, x0, x5
2422 asr x0, x0, #1
2423 ret
2424.Lmatch_3:
2425 sub x0, x0, x5
2426 asr x0, x0, #1
2427 ret
2428END art_quick_indexof
Roland Levillain02b75802016-07-13 11:54:35 +01002429
2430 /*
2431 * Create a function `name` calling the ReadBarrier::Mark routine,
Roland Levillain4359e612016-07-20 11:32:19 +01002432 * getting its argument and returning its result through W register
2433 * `wreg` (corresponding to X register `xreg`), saving and restoring
2434 * all caller-save registers.
2435 *
2436 * If `wreg` is different from `w0`, the generated function follows a
2437 * non-standard runtime calling convention:
2438 * - register `wreg` is used to pass the (sole) argument of this
2439 * function (instead of W0);
2440 * - register `wreg` is used to return the result of this function
Roland Levillain02b75802016-07-13 11:54:35 +01002441 * (instead of W0);
Roland Levillain02b75802016-07-13 11:54:35 +01002442 * - W0 is treated like a normal (non-argument) caller-save register;
2443 * - everything else is the same as in the standard runtime calling
Roland Levillain4359e612016-07-20 11:32:19 +01002444 * convention (e.g. standard callee-save registers are preserved).
Roland Levillain02b75802016-07-13 11:54:35 +01002445 */
Roland Levillain4359e612016-07-20 11:32:19 +01002446.macro READ_BARRIER_MARK_REG name, wreg, xreg
Roland Levillain02b75802016-07-13 11:54:35 +01002447ENTRY \name
Mathieu Chartier36a270a2016-07-28 18:08:51 -07002448 // Reference is null, no work to do at all.
2449 cbz \wreg, .Lret_rb_\name
Roland Levillain4359e612016-07-20 11:32:19 +01002450 /*
2451 * Allocate 46 stack slots * 8 = 368 bytes:
2452 * - 20 slots for core registers X0-X19
2453 * - 24 slots for floating-point registers D0-D7 and D16-D31
2454 * - 1 slot for return address register XLR
2455 * - 1 padding slot for 16-byte stack alignment
2456 */
Mathieu Chartier36a270a2016-07-28 18:08:51 -07002457 // Use wIP0 as temp and check the mark bit of the reference. wIP0 is not used by the compiler.
2458 ldr wIP0, [\xreg, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
2459 tbz wIP0, #LOCK_WORD_MARK_BIT_SHIFT, .Lslow_path_rb_\name
2460 ret
2461.Lslow_path_rb_\name:
Roland Levillain4359e612016-07-20 11:32:19 +01002462 // Save all potentially live caller-save core registers.
Vladimir Marko215076b2016-09-07 18:05:55 +01002463 SAVE_TWO_REGS_INCREASE_FRAME x0, x1, 368
2464 SAVE_TWO_REGS x2, x3, 16
2465 SAVE_TWO_REGS x4, x5, 32
2466 SAVE_TWO_REGS x6, x7, 48
2467 SAVE_TWO_REGS x8, x9, 64
2468 SAVE_TWO_REGS x10, x11, 80
2469 SAVE_TWO_REGS x12, x13, 96
2470 SAVE_TWO_REGS x14, x15, 112
2471 SAVE_TWO_REGS x16, x17, 128
2472 SAVE_TWO_REGS x18, x19, 144
Roland Levillain4359e612016-07-20 11:32:19 +01002473 // Save all potentially live caller-save floating-point registers.
2474 stp d0, d1, [sp, #160]
2475 stp d2, d3, [sp, #176]
2476 stp d4, d5, [sp, #192]
2477 stp d6, d7, [sp, #208]
2478 stp d16, d17, [sp, #224]
2479 stp d18, d19, [sp, #240]
2480 stp d20, d21, [sp, #256]
2481 stp d22, d23, [sp, #272]
2482 stp d24, d25, [sp, #288]
2483 stp d26, d27, [sp, #304]
2484 stp d28, d29, [sp, #320]
2485 stp d30, d31, [sp, #336]
2486 // Save return address.
Vladimir Marko215076b2016-09-07 18:05:55 +01002487 // (sp + #352 is a padding slot)
2488 SAVE_REG xLR, 360
Roland Levillain4359e612016-07-20 11:32:19 +01002489
2490 .ifnc \wreg, w0
2491 mov w0, \wreg // Pass arg1 - obj from `wreg`
2492 .endif
Roland Levillain02b75802016-07-13 11:54:35 +01002493 bl artReadBarrierMark // artReadBarrierMark(obj)
Roland Levillain4359e612016-07-20 11:32:19 +01002494 .ifnc \wreg, w0
2495 mov \wreg, w0 // Return result into `wreg`
2496 .endif
2497
2498 // Restore core regs, except `xreg`, as `wreg` is used to return the
2499 // result of this function (simply remove it from the stack instead).
2500 POP_REGS_NE x0, x1, 0, \xreg
2501 POP_REGS_NE x2, x3, 16, \xreg
2502 POP_REGS_NE x4, x5, 32, \xreg
2503 POP_REGS_NE x6, x7, 48, \xreg
2504 POP_REGS_NE x8, x9, 64, \xreg
2505 POP_REGS_NE x10, x11, 80, \xreg
2506 POP_REGS_NE x12, x13, 96, \xreg
2507 POP_REGS_NE x14, x15, 112, \xreg
2508 POP_REGS_NE x16, x17, 128, \xreg
2509 POP_REGS_NE x18, x19, 144, \xreg
2510 // Restore floating-point registers.
2511 ldp d0, d1, [sp, #160]
2512 ldp d2, d3, [sp, #176]
2513 ldp d4, d5, [sp, #192]
2514 ldp d6, d7, [sp, #208]
2515 ldp d16, d17, [sp, #224]
2516 ldp d18, d19, [sp, #240]
2517 ldp d20, d21, [sp, #256]
2518 ldp d22, d23, [sp, #272]
2519 ldp d24, d25, [sp, #288]
2520 ldp d26, d27, [sp, #304]
2521 ldp d28, d29, [sp, #320]
2522 ldp d30, d31, [sp, #336]
2523 // Restore return address and remove padding.
Vladimir Marko215076b2016-09-07 18:05:55 +01002524 RESTORE_REG xLR, 360
Roland Levillain4359e612016-07-20 11:32:19 +01002525 add sp, sp, #368
2526 .cfi_adjust_cfa_offset -368
Mathieu Chartier36a270a2016-07-28 18:08:51 -07002527.Lret_rb_\name:
Roland Levillain02b75802016-07-13 11:54:35 +01002528 ret
2529END \name
2530.endm
2531
Roland Levillain4359e612016-07-20 11:32:19 +01002532READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg00, w0, x0
2533READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg01, w1, x1
2534READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg02, w2, x2
2535READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg03, w3, x3
2536READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg04, w4, x4
2537READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg05, w5, x5
2538READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg06, w6, x6
2539READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg07, w7, x7
2540READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg08, w8, x8
2541READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg09, w9, x9
2542READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg10, w10, x10
2543READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg11, w11, x11
2544READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg12, w12, x12
2545READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg13, w13, x13
2546READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg14, w14, x14
2547READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg15, w15, x15
Mathieu Chartier36c22712016-08-12 13:19:44 -07002548// READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg16, w16, x16 ip0 is blocked
Roland Levillain4359e612016-07-20 11:32:19 +01002549READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg17, w17, x17
2550READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg18, w18, x18
2551READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg19, w19, x19
2552READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg20, w20, x20
2553READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg21, w21, x21
2554READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg22, w22, x22
2555READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg23, w23, x23
2556READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg24, w24, x24
2557READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg25, w25, x25
2558READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg26, w26, x26
2559READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg27, w27, x27
2560READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg28, w28, x28
2561READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg29, w29, x29