blob: 6427838c86358e6874cc6f65bd8938207e10e0f7 [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
22 /*
23 * Macro that sets up the callee save frame to conform with
24 * Runtime::CreateCalleeSaveMethod(kSaveAll)
25 */
26.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
27 adrp x9, :got:_ZN3art7Runtime9instance_E
28 ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E]
29
30 // Our registers aren't intermixed - just spill in order.
31 ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) .
32
33 // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] .
34 ldr x9, [x9, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET ]
35
36 sub sp, sp, #368
37 .cfi_adjust_cfa_offset 368
38
Andreas Gampe5c1e4352014-04-21 19:28:24 -070039 // Ugly compile-time check, but we only have the preprocessor.
40#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 368)
41#error "SAVE_ALL_CALLEE_SAVE_FRAME(ARM64) size not as expected."
42#endif
43
Stuart Monteithb95a5342014-03-12 13:32:32 +000044 // FP args
45 stp d1, d2, [sp, #8]
46 stp d2, d3, [sp, #24]
47 stp d4, d5, [sp, #40]
48 stp d6, d7, [sp, #56]
49
50 // FP callee-saves
51 stp d8, d9, [sp, #72]
52 stp d10, d11, [sp, #88]
53 stp d12, d13, [sp, #104]
54 stp d14, d15, [sp, #120]
55
56 stp d16, d17, [sp, #136]
57 stp d18, d19, [sp, #152]
58 stp d20, d21, [sp, #168]
59 stp d22, d23, [sp, #184]
60 stp d24, d25, [sp, #200]
61 stp d26, d27, [sp, #216]
62 stp d28, d29, [sp, #232]
63 stp d30, d31, [sp, #248]
64
65
66 // Callee saved.
67 stp xSELF, x19, [sp, #264]
Andreas Gampe03906cf2014-04-07 12:08:28 -070068 .cfi_rel_offset x18, 264
69 .cfi_rel_offset x19, 272
Stuart Monteithb95a5342014-03-12 13:32:32 +000070
Andreas Gampe03906cf2014-04-07 12:08:28 -070071 stp x20, x21, [sp, #280]
72 .cfi_rel_offset x20, 280
73 .cfi_rel_offset x21, 288
74
75 stp x22, x23, [sp, #296]
76 .cfi_rel_offset x22, 296
77 .cfi_rel_offset x23, 304
78
79 stp x24, x25, [sp, #312]
80 .cfi_rel_offset x24, 312
81 .cfi_rel_offset x25, 320
82
83 stp x26, x27, [sp, #328]
84 .cfi_rel_offset x26, 328
85 .cfi_rel_offset x27, 336
86
87 stp x28, xFP, [sp, #344] // Save FP.
88 .cfi_rel_offset x28, 344
89 .cfi_rel_offset x29, 352
90
91 str xLR, [sp, #360]
92 .cfi_rel_offset x30, 360
Stuart Monteithb95a5342014-03-12 13:32:32 +000093
94 // Loads appropriate callee-save-method
95 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs]
96
97.endm
98
99 /*
100 * Macro that sets up the callee save frame to conform with
101 * Runtime::CreateCalleeSaveMethod(kRefsOnly).
102 */
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700103// WIP.
Stuart Monteithb95a5342014-03-12 13:32:32 +0000104.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700105 adrp x9, :got:_ZN3art7Runtime9instance_E
106 ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E]
107
108 // Our registers aren't intermixed - just spill in order.
109 ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) .
110
111 // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] .
112 ldr x9, [x9, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET ]
113
114 sub sp, sp, #176
115 .cfi_adjust_cfa_offset 176
116
117 // Ugly compile-time check, but we only have the preprocessor.
118#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 176)
119#error "REFS_ONLY_CALLEE_SAVE_FRAME(ARM64) size not as expected."
120#endif
121
122 // FP callee-saves
123 stp d8, d9, [sp, #8]
124 stp d10, d11, [sp, #24]
125 stp d12, d13, [sp, #40]
126 stp d14, d15, [sp, #56]
127
128 // Callee saved.
129 stp xSELF, x19, [sp, #72]
130 .cfi_rel_offset x18, 72
131 .cfi_rel_offset x19, 80
132
133 stp x20, x21, [sp, #88]
134 .cfi_rel_offset x20, 88
135 .cfi_rel_offset x21, 96
136
137 stp x22, x23, [sp, #104]
138 .cfi_rel_offset x22, 104
139 .cfi_rel_offset x23, 112
140
141 stp x24, x25, [sp, #120]
142 .cfi_rel_offset x24, 120
143 .cfi_rel_offset x25, 128
144
145 stp x26, x27, [sp, #136]
146 .cfi_rel_offset x26, 136
147 .cfi_rel_offset x27, 144
148
149 stp x28, xFP, [sp, #152] // Save FP.
150 .cfi_rel_offset x28, 152
151 .cfi_rel_offset x29, 160
152
153 str xLR, [sp, #168]
154 .cfi_rel_offset x30, 168
155
156 // Loads appropriate callee-save-method
157 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs]
Stuart Monteithb95a5342014-03-12 13:32:32 +0000158.endm
159
160.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700161 // FP callee saves
162 ldp d8, d9, [sp, #8]
163 ldp d10, d11, [sp, #24]
164 ldp d12, d13, [sp, #40]
165 ldp d14, d15, [sp, #56]
166
167 // Callee saved.
168 ldp xSELF, x19, [sp, #72]
169 .cfi_restore x18
170 .cfi_restore x19
171
172 ldp x20, x21, [sp, #88]
173 .cfi_restore x20
174 .cfi_restore x21
175
176 ldp x22, x23, [sp, #104]
177 .cfi_restore x22
178 .cfi_restore x23
179
180 ldp x24, x25, [sp, #120]
181 .cfi_restore x24
182 .cfi_restore x25
183
184 ldp x26, x27, [sp, #136]
185 .cfi_restore x26
186 .cfi_restore x27
187
188 ldp x28, xFP, [sp, #152] // Save FP.
189 .cfi_restore x28
190 .cfi_restore x29
191
192 ldr xLR, [sp, #168]
193 .cfi_restore x30
194
195 add sp, sp, #176
196 .cfi_adjust_cfa_offset -176
Stuart Monteithb95a5342014-03-12 13:32:32 +0000197.endm
198
199.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
200 brk 0
201.endm
202
203
204.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
205 sub sp, sp, #304
206 .cfi_adjust_cfa_offset 304
207
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700208 // Ugly compile-time check, but we only have the preprocessor.
209#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 304)
210#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(ARM64) size not as expected."
211#endif
212
Stuart Monteithb95a5342014-03-12 13:32:32 +0000213 stp d0, d1, [sp, #16]
214 stp d2, d3, [sp, #32]
215 stp d4, d5, [sp, #48]
216 stp d6, d7, [sp, #64]
217 stp d8, d9, [sp, #80]
218 stp d10, d11, [sp, #96]
219 stp d12, d13, [sp, #112]
220 stp d14, d15, [sp, #128]
221
222 stp x1, x2, [sp, #144]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700223 .cfi_rel_offset x1, 144
224 .cfi_rel_offset x2, 152
Stuart Monteithb95a5342014-03-12 13:32:32 +0000225
Andreas Gampe03906cf2014-04-07 12:08:28 -0700226 stp x3, x4, [sp, #160]
227 .cfi_rel_offset x3, 160
228 .cfi_rel_offset x4, 168
229
230 stp x5, x6, [sp, #176]
231 .cfi_rel_offset x5, 176
232 .cfi_rel_offset x6, 184
233
234 stp x7, xSELF, [sp, #192]
235 .cfi_rel_offset x7, 192
236 .cfi_rel_offset x18, 200
237
238 stp x19, x20, [sp, #208]
239 .cfi_rel_offset x19, 208
240 .cfi_rel_offset x20, 216
241
242 stp x21, x22, [sp, #224]
243 .cfi_rel_offset x21, 224
244 .cfi_rel_offset x22, 232
245
246 stp x23, x24, [sp, #240]
247 .cfi_rel_offset x23, 240
248 .cfi_rel_offset x24, 248
249
250 stp x25, x26, [sp, #256]
251 .cfi_rel_offset x25, 256
252 .cfi_rel_offset x26, 264
253
254 stp x27, x28, [sp, #272]
255 .cfi_rel_offset x27, 272
256 .cfi_rel_offset x28, 280
257
258 stp xFP, xLR, [sp, #288]
259 .cfi_rel_offset x29, 288
260 .cfi_rel_offset x30, 296
Stuart Monteithb95a5342014-03-12 13:32:32 +0000261.endm
262
263 /*
264 * Macro that sets up the callee save frame to conform with
265 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
266 *
267 * TODO This is probably too conservative - saving FP & LR.
268 */
269.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
270 adrp x9, :got:_ZN3art7Runtime9instance_E
271 ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E]
272
273 // Our registers aren't intermixed - just spill in order.
274 ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) .
275
276 // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] .
277 ldr x9, [x9, RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET ]
278
279 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
280
281 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs]
282.endm
283
284.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
285
286 ldp d0, d1, [sp, #16]
287 ldp d2, d3, [sp, #32]
288 ldp d4, d5, [sp, #48]
289 ldp d6, d7, [sp, #64]
290 ldp d8, d9, [sp, #80]
291 ldp d10, d11, [sp, #96]
292 ldp d12, d13, [sp, #112]
293 ldp d14, d15, [sp, #128]
294
295 // args.
296 ldp x1, x2, [sp, #144]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700297 .cfi_restore x1
298 .cfi_restore x2
299
Stuart Monteithb95a5342014-03-12 13:32:32 +0000300 ldp x3, x4, [sp, #160]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700301 .cfi_restore x3
302 .cfi_restore x4
303
Stuart Monteithb95a5342014-03-12 13:32:32 +0000304 ldp x5, x6, [sp, #176]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700305 .cfi_restore x5
306 .cfi_restore x6
307
Stuart Monteithb95a5342014-03-12 13:32:32 +0000308 ldp x7, xSELF, [sp, #192]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700309 .cfi_restore x7
310 .cfi_restore x18
311
Stuart Monteithb95a5342014-03-12 13:32:32 +0000312 ldp x19, x20, [sp, #208]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700313 .cfi_restore x19
314 .cfi_restore x20
315
Stuart Monteithb95a5342014-03-12 13:32:32 +0000316 ldp x21, x22, [sp, #224]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700317 .cfi_restore x21
318 .cfi_restore x22
319
Stuart Monteithb95a5342014-03-12 13:32:32 +0000320 ldp x23, x24, [sp, #240]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700321 .cfi_restore x23
322 .cfi_restore x24
323
Stuart Monteithb95a5342014-03-12 13:32:32 +0000324 ldp x25, x26, [sp, #256]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700325 .cfi_restore x25
326 .cfi_restore x26
327
Stuart Monteithb95a5342014-03-12 13:32:32 +0000328 ldp x27, x28, [sp, #272]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700329 .cfi_restore x27
330 .cfi_restore x28
331
Stuart Monteithb95a5342014-03-12 13:32:32 +0000332 ldp xFP, xLR, [sp, #288]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700333 .cfi_restore x29
334 .cfi_restore x30
Stuart Monteithb95a5342014-03-12 13:32:32 +0000335
336 add sp, sp, #304
337 .cfi_adjust_cfa_offset -304
338.endm
339
Andreas Gampee62a07e2014-03-26 14:53:21 -0700340.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME_NO_D0
341
342 ldr d1, [sp, #24]
343 ldp d2, d3, [sp, #32]
344 ldp d4, d5, [sp, #48]
345 ldp d6, d7, [sp, #64]
346 ldp d8, d9, [sp, #80]
347 ldp d10, d11, [sp, #96]
348 ldp d12, d13, [sp, #112]
349 ldp d14, d15, [sp, #128]
350
351 // args.
352 ldp x1, x2, [sp, #144]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700353 .cfi_restore x1
354 .cfi_restore x2
355
Andreas Gampee62a07e2014-03-26 14:53:21 -0700356 ldp x3, x4, [sp, #160]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700357 .cfi_restore x3
358 .cfi_restore x4
359
Andreas Gampee62a07e2014-03-26 14:53:21 -0700360 ldp x5, x6, [sp, #176]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700361 .cfi_restore x5
362 .cfi_restore x6
363
Andreas Gampee62a07e2014-03-26 14:53:21 -0700364 ldp x7, xSELF, [sp, #192]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700365 .cfi_restore x7
366 .cfi_restore x18
367
Andreas Gampee62a07e2014-03-26 14:53:21 -0700368 ldp x19, x20, [sp, #208]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700369 .cfi_restore x19
370 .cfi_restore x20
371
Andreas Gampee62a07e2014-03-26 14:53:21 -0700372 ldp x21, x22, [sp, #224]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700373 .cfi_restore x21
374 .cfi_restore x22
375
Andreas Gampee62a07e2014-03-26 14:53:21 -0700376 ldp x23, x24, [sp, #240]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700377 .cfi_restore x23
378 .cfi_restore x24
379
Andreas Gampee62a07e2014-03-26 14:53:21 -0700380 ldp x25, x26, [sp, #256]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700381 .cfi_restore x25
382 .cfi_restore x26
383
Andreas Gampee62a07e2014-03-26 14:53:21 -0700384 ldp x27, x28, [sp, #272]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700385 .cfi_restore x27
386 .cfi_restore x28
387
Andreas Gampee62a07e2014-03-26 14:53:21 -0700388 ldp xFP, xLR, [sp, #288]
Andreas Gampe03906cf2014-04-07 12:08:28 -0700389 .cfi_restore x29
390 .cfi_restore x30
Andreas Gampee62a07e2014-03-26 14:53:21 -0700391
392 add sp, sp, #304
393 .cfi_adjust_cfa_offset -304
394.endm
395
Stuart Monteithb95a5342014-03-12 13:32:32 +0000396.macro RETURN_IF_RESULT_IS_ZERO
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700397 cbnz x0, 1f // result non-zero branch over
398 ret // return
3991:
Stuart Monteithb95a5342014-03-12 13:32:32 +0000400.endm
401
402.macro RETURN_IF_RESULT_IS_NON_ZERO
Andreas Gampe00c1e6d2014-04-25 15:47:13 -0700403 cbz x0, 1f // result zero branch over
404 ret // return
4051:
Stuart Monteithb95a5342014-03-12 13:32:32 +0000406.endm
407
408 /*
409 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
410 * exception is Thread::Current()->exception_
411 */
412.macro DELIVER_PENDING_EXCEPTION
413 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
414 mov x0, xSELF
415 mov x1, sp
416
417 // Point of no return.
418 b artDeliverPendingExceptionFromCode // artDeliverPendingExceptionFromCode(Thread*, SP)
419 brk 0 // Unreached
420.endm
421
Andreas Gampe6e4e59c2014-05-05 20:11:02 -0700422.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg
423 ldr \reg, [xSELF, # THREAD_EXCEPTION_OFFSET] // Get exception field.
424 cbnz \reg, 1f
Stuart Monteithb95a5342014-03-12 13:32:32 +0000425 ret
4261:
427 DELIVER_PENDING_EXCEPTION
428.endm
429
Andreas Gampe6e4e59c2014-05-05 20:11:02 -0700430.macro RETURN_OR_DELIVER_PENDING_EXCEPTION
431 RETURN_OR_DELIVER_PENDING_EXCEPTION_REG x9
432.endm
433
434// Same as above with x1. This is helpful in stubs that want to avoid clobbering another register.
435.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
436 RETURN_OR_DELIVER_PENDING_EXCEPTION_REG x1
437.endm
438
439.macro RETURN_IF_W0_IS_ZERO_OR_DELIVER
440 cbnz w0, 1f // result non-zero branch over
441 ret // return
4421:
443 DELIVER_PENDING_EXCEPTION
444.endm
445
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700446// FIXME: Temporary fix for TR(XSELF).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000447.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
448 .extern \cxx_name
449ENTRY \c_name
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700450 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
451 mov x0, x19 // pass Thread::Current
452 mov x1, sp // pass SP
453 b \cxx_name // \cxx_name(Thread*, SP)
Stuart Monteithb95a5342014-03-12 13:32:32 +0000454END \c_name
455.endm
456
Serban Constantinescu75b91132014-04-09 18:39:10 +0100457// FIXME: Temporary fix for TR(XSELF).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000458.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name
459 .extern \cxx_name
460ENTRY \c_name
Serban Constantinescu75b91132014-04-09 18:39:10 +0100461 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context.
462 mov x1, x19 // pass Thread::Current.
463 mov x2, sp // pass SP.
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700464 b \cxx_name // \cxx_name(arg, Thread*, SP).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000465 brk 0
466END \c_name
467.endm
468
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700469// FIXME: Temporary fix for TR(XSELF).
Stuart Monteithb95a5342014-03-12 13:32:32 +0000470.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
471 .extern \cxx_name
472ENTRY \c_name
473 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700474 mov x2, x19 // pass Thread::Current
475 mov x3, sp // pass SP
476 b \cxx_name // \cxx_name(arg1, arg2, Thread*, SP)
Stuart Monteithb95a5342014-03-12 13:32:32 +0000477 brk 0
478END \c_name
479.endm
480
481 /*
482 * Called by managed code, saves callee saves and then calls artThrowException
483 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception.
484 */
485ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode
486
487 /*
488 * Called by managed code to create and deliver a NullPointerException.
489 */
490NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode
491
492 /*
493 * Called by managed code to create and deliver an ArithmeticException.
494 */
495NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode
496
497 /*
498 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds
499 * index, arg2 holds limit.
500 */
501TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode
502
503 /*
504 * Called by managed code to create and deliver a StackOverflowError.
505 */
506NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode
507
508 /*
509 * Called by managed code to create and deliver a NoSuchMethodError.
510 */
511ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode
512
513 /*
514 * TODO arm64 specifics need to be fleshed out.
515 * All generated callsites for interface invokes and invocation slow paths will load arguments
516 * as usual - except instead of loading x0 with the target Method*, x0 will contain
517 * the method_idx. This wrapper will save x1-x3, load the caller's Method*, align the
518 * stack and call the appropriate C helper.
519 * NOTE: "this" is first visible argument of the target, and so can be found in x1.
520 *
521 * The helper will attempt to locate the target and return a result in x0 consisting
522 * of the target Method* in x0 and method->code_ in x1.
523 *
524 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
525 * thread and we branch to another stub to deliver it.
526 *
527 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
528 * pointing back to the original caller.
529 */
530.macro INVOKE_TRAMPOLINE c_name, cxx_name
531 .extern \cxx_name
532ENTRY \c_name
533 brk 0
534END \c_name
535.endm
536
537INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
538INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
539
540INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
541INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
542INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
543INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
544
Andreas Gampe03906cf2014-04-07 12:08:28 -0700545
546.macro INVOKE_STUB_CREATE_FRAME
547
548SAVE_SIZE=5*8 // x4, x5, SP, LR & FP saved.
549SAVE_SIZE_AND_METHOD=SAVE_SIZE+8
550
551 mov x9, sp // Save stack pointer.
552 .cfi_register sp,x9
553
554 add x10, x2, # SAVE_SIZE_AND_METHOD // calculate size of frame.
555 sub x10, sp, x10 // Calculate SP position - saves + ArtMethod* + args
556 and x10, x10, # ~0xf // Enforce 16 byte stack alignment.
557 mov sp, x10 // Set new SP.
558
559 sub x10, x9, #SAVE_SIZE // Calculate new FP (later). Done here as we must move SP
560 .cfi_def_cfa_register x10 // before this.
561 .cfi_adjust_cfa_offset SAVE_SIZE
562
563 str x9, [x10, #32] // Save old stack pointer.
564 .cfi_rel_offset sp, 32
565
566 stp x4, x5, [x10, #16] // Save result and shorty addresses.
567 .cfi_rel_offset x4, 16
568 .cfi_rel_offset x5, 24
569
570 stp xFP, xLR, [x10] // Store LR & FP.
571 .cfi_rel_offset x29, 0
572 .cfi_rel_offset x30, 8
573
574 mov xFP, x10 // Use xFP now, as it's callee-saved.
575 .cfi_def_cfa_register x29
576 mov xSELF, x3 // Move thread pointer into SELF register.
577
578 // Copy arguments into stack frame.
579 // Use simple copy routine for now.
580 // 4 bytes per slot.
581 // X1 - source address
582 // W2 - args length
583 // X9 - destination address.
584 // W10 - temporary
585 add x9, sp, #8 // Destination address is bottom of stack + NULL.
586
587 // Use \@ to differentiate between macro invocations.
588.LcopyParams\@:
589 cmp w2, #0
590 beq .LendCopyParams\@
591 sub w2, w2, #4 // Need 65536 bytes of range.
592 ldr w10, [x1, x2]
593 str w10, [x9, x2]
594
595 b .LcopyParams\@
596
597.LendCopyParams\@:
598
599 // Store NULL into Method* at bottom of frame.
600 str xzr, [sp]
601
602.endm
603
604.macro INVOKE_STUB_CALL_AND_RETURN
605
606 // load method-> METHOD_QUICK_CODE_OFFSET
607 ldr x9, [x0 , #METHOD_QUICK_CODE_OFFSET]
608 // Branch to method.
609 blr x9
610
611 // Restore return value address and shorty address.
612 ldp x4,x5, [xFP, #16]
613 .cfi_restore x4
614 .cfi_restore x5
615
616 // Store result (w0/x0/s0/d0) appropriately, depending on resultType.
617 ldrb w10, [x5]
618
619 // Don't set anything for a void type.
620 cmp w10, #'V'
621 beq .Lexit_art_quick_invoke_stub\@
622
623 cmp w10, #'D'
624 bne .Lreturn_is_float\@
625 str d0, [x4]
626 b .Lexit_art_quick_invoke_stub\@
627
628.Lreturn_is_float\@:
629 cmp w10, #'F'
630 bne .Lreturn_is_int\@
631 str s0, [x4]
632 b .Lexit_art_quick_invoke_stub\@
633
634 // Just store x0. Doesn't matter if it is 64 or 32 bits.
635.Lreturn_is_int\@:
636 str x0, [x4]
637
638.Lexit_art_quick_invoke_stub\@:
639 ldr x2, [x29, #32] // Restore stack pointer.
640 mov sp, x2
641 .cfi_restore sp
642
643 ldp x29, x30, [x29] // Restore old frame pointer and link register.
644 .cfi_restore x29
645 .cfi_restore x30
646
647 ret
648
649.endm
650
651
Stuart Monteithb95a5342014-03-12 13:32:32 +0000652/*
653 * extern"C" void art_quick_invoke_stub(ArtMethod *method, x0
654 * uint32_t *args, x1
655 * uint32_t argsize, w2
656 * Thread *self, x3
657 * JValue *result, x4
658 * char *shorty); x5
659 * +----------------------+
660 * | |
661 * | C/C++ frame |
662 * | LR'' |
663 * | FP'' | <- SP'
664 * +----------------------+
665 * +----------------------+
666 * | SP' |
667 * | X5 |
668 * | X4 | Saved registers
669 * | LR' |
670 * | FP' | <- FP
671 * +----------------------+
672 * | uint32_t out[n-1] |
673 * | : : | Outs
674 * | uint32_t out[0] |
675 * | ArtMethod* NULL | <- SP
676 * +----------------------+
677 *
678 * Outgoing registers:
679 * x0 - Method*
680 * x1-x7 - integer parameters.
681 * d0-d7 - Floating point parameters.
682 * xSELF = self
683 * SP = & of ArtMethod*
684 * x1 = "this" pointer.
685 *
686 */
687ENTRY art_quick_invoke_stub
688 // Spill registers as per AACPS64 calling convention.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700689 INVOKE_STUB_CREATE_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +0000690
691 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters.
692 // Parse the passed shorty to determine which register to load.
693 // Load addresses for routines that load WXSD registers.
694 adr x11, .LstoreW2
695 adr x12, .LstoreX2
696 adr x13, .LstoreS0
697 adr x14, .LstoreD0
698
699 // Initialize routine offsets to 0 for integers and floats.
700 // x8 for integers, x15 for floating point.
701 mov x8, #0
702 mov x15, #0
703
704 add x10, x5, #1 // Load shorty address, plus one to skip return value.
705 ldr w1, [x9],#4 // Load "this" parameter, and increment arg pointer.
706
707 // Loop to fill registers.
708.LfillRegisters:
709 ldrb w17, [x10], #1 // Load next character in signature, and increment.
710 cbz w17, .LcallFunction // Exit at end of signature. Shorty 0 terminated.
711
712 cmp w17, #'F' // is this a float?
713 bne .LisDouble
714
715 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700716 beq .Ladvance4
Stuart Monteithb95a5342014-03-12 13:32:32 +0000717
718 add x17, x13, x15 // Calculate subroutine to jump to.
719 br x17
720
721.LisDouble:
722 cmp w17, #'D' // is this a double?
723 bne .LisLong
724
725 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700726 beq .Ladvance8
Stuart Monteithb95a5342014-03-12 13:32:32 +0000727
728 add x17, x14, x15 // Calculate subroutine to jump to.
729 br x17
730
731.LisLong:
732 cmp w17, #'J' // is this a long?
733 bne .LisOther
734
Andreas Gampe9de65ff2014-03-21 17:25:57 -0700735 cmp x8, # 6*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700736 beq .Ladvance8
Stuart Monteithb95a5342014-03-12 13:32:32 +0000737
738 add x17, x12, x8 // Calculate subroutine to jump to.
739 br x17
740
Stuart Monteithb95a5342014-03-12 13:32:32 +0000741.LisOther: // Everything else takes one vReg.
Andreas Gampe9de65ff2014-03-21 17:25:57 -0700742 cmp x8, # 6*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700743 beq .Ladvance4
744
Stuart Monteithb95a5342014-03-12 13:32:32 +0000745 add x17, x11, x8 // Calculate subroutine to jump to.
746 br x17
747
Andreas Gampe03906cf2014-04-07 12:08:28 -0700748.Ladvance4:
749 add x9, x9, #4
750 b .LfillRegisters
751
752.Ladvance8:
753 add x9, x9, #8
754 b .LfillRegisters
755
Stuart Monteithb95a5342014-03-12 13:32:32 +0000756// Macro for loading a parameter into a register.
757// counter - the register with offset into these tables
758// size - the size of the register - 4 or 8 bytes.
759// register - the name of the register to be loaded.
760.macro LOADREG counter size register return
761 ldr \register , [x9], #\size
762 add \counter, \counter, 12
763 b \return
764.endm
765
766// Store ints.
767.LstoreW2:
768 LOADREG x8 4 w2 .LfillRegisters
769 LOADREG x8 4 w3 .LfillRegisters
770 LOADREG x8 4 w4 .LfillRegisters
771 LOADREG x8 4 w5 .LfillRegisters
772 LOADREG x8 4 w6 .LfillRegisters
773 LOADREG x8 4 w7 .LfillRegisters
774
775// Store longs.
776.LstoreX2:
777 LOADREG x8 8 x2 .LfillRegisters
778 LOADREG x8 8 x3 .LfillRegisters
779 LOADREG x8 8 x4 .LfillRegisters
780 LOADREG x8 8 x5 .LfillRegisters
781 LOADREG x8 8 x6 .LfillRegisters
782 LOADREG x8 8 x7 .LfillRegisters
783
784// Store singles.
785.LstoreS0:
786 LOADREG x15 4 s0 .LfillRegisters
787 LOADREG x15 4 s1 .LfillRegisters
788 LOADREG x15 4 s2 .LfillRegisters
789 LOADREG x15 4 s3 .LfillRegisters
790 LOADREG x15 4 s4 .LfillRegisters
791 LOADREG x15 4 s5 .LfillRegisters
792 LOADREG x15 4 s6 .LfillRegisters
793 LOADREG x15 4 s7 .LfillRegisters
794
795// Store doubles.
796.LstoreD0:
797 LOADREG x15 8 d0 .LfillRegisters
798 LOADREG x15 8 d1 .LfillRegisters
799 LOADREG x15 8 d2 .LfillRegisters
800 LOADREG x15 8 d3 .LfillRegisters
801 LOADREG x15 8 d4 .LfillRegisters
802 LOADREG x15 8 d5 .LfillRegisters
803 LOADREG x15 8 d6 .LfillRegisters
804 LOADREG x15 8 d7 .LfillRegisters
805
806
807.LcallFunction:
808
Andreas Gampe03906cf2014-04-07 12:08:28 -0700809 INVOKE_STUB_CALL_AND_RETURN
Stuart Monteithb95a5342014-03-12 13:32:32 +0000810
Stuart Monteithb95a5342014-03-12 13:32:32 +0000811END art_quick_invoke_stub
812
813/* extern"C"
814 * void art_quick_invoke_static_stub(ArtMethod *method, x0
815 * uint32_t *args, x1
816 * uint32_t argsize, w2
817 * Thread *self, x3
818 * JValue *result, x4
819 * char *shorty); x5
820 */
821ENTRY art_quick_invoke_static_stub
822 // Spill registers as per AACPS64 calling convention.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700823 INVOKE_STUB_CREATE_FRAME
Stuart Monteithb95a5342014-03-12 13:32:32 +0000824
825 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters.
826 // Parse the passed shorty to determine which register to load.
827 // Load addresses for routines that load WXSD registers.
828 adr x11, .LstoreW1_2
829 adr x12, .LstoreX1_2
830 adr x13, .LstoreS0_2
831 adr x14, .LstoreD0_2
832
833 // Initialize routine offsets to 0 for integers and floats.
834 // x8 for integers, x15 for floating point.
835 mov x8, #0
836 mov x15, #0
837
838 add x10, x5, #1 // Load shorty address, plus one to skip return value.
839
840 // Loop to fill registers.
841.LfillRegisters2:
842 ldrb w17, [x10], #1 // Load next character in signature, and increment.
843 cbz w17, .LcallFunction2 // Exit at end of signature. Shorty 0 terminated.
844
845 cmp w17, #'F' // is this a float?
846 bne .LisDouble2
847
848 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700849 beq .Ladvance4_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000850
851 add x17, x13, x15 // Calculate subroutine to jump to.
852 br x17
853
854.LisDouble2:
855 cmp w17, #'D' // is this a double?
856 bne .LisLong2
857
858 cmp x15, # 8*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700859 beq .Ladvance8_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000860
861 add x17, x14, x15 // Calculate subroutine to jump to.
862 br x17
863
864.LisLong2:
865 cmp w17, #'J' // is this a long?
866 bne .LisOther2
867
868 cmp x8, # 7*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700869 beq .Ladvance8_2
Stuart Monteithb95a5342014-03-12 13:32:32 +0000870
871 add x17, x12, x8 // Calculate subroutine to jump to.
872 br x17
873
Stuart Monteithb95a5342014-03-12 13:32:32 +0000874.LisOther2: // Everything else takes one vReg.
875 cmp x8, # 7*12 // Skip this load if all registers full.
Andreas Gampe03906cf2014-04-07 12:08:28 -0700876 beq .Ladvance4_2
877
Stuart Monteithb95a5342014-03-12 13:32:32 +0000878 add x17, x11, x8 // Calculate subroutine to jump to.
879 br x17
880
Andreas Gampe03906cf2014-04-07 12:08:28 -0700881.Ladvance4_2:
882 add x9, x9, #4
883 b .LfillRegisters2
884
885.Ladvance8_2:
886 add x9, x9, #8
887 b .LfillRegisters2
888
Stuart Monteithb95a5342014-03-12 13:32:32 +0000889// Store ints.
890.LstoreW1_2:
891 LOADREG x8 4 w1 .LfillRegisters2
892 LOADREG x8 4 w2 .LfillRegisters2
893 LOADREG x8 4 w3 .LfillRegisters2
894 LOADREG x8 4 w4 .LfillRegisters2
895 LOADREG x8 4 w5 .LfillRegisters2
896 LOADREG x8 4 w6 .LfillRegisters2
897 LOADREG x8 4 w7 .LfillRegisters2
898
899// Store longs.
900.LstoreX1_2:
901 LOADREG x8 8 x1 .LfillRegisters2
902 LOADREG x8 8 x2 .LfillRegisters2
903 LOADREG x8 8 x3 .LfillRegisters2
904 LOADREG x8 8 x4 .LfillRegisters2
905 LOADREG x8 8 x5 .LfillRegisters2
906 LOADREG x8 8 x6 .LfillRegisters2
907 LOADREG x8 8 x7 .LfillRegisters2
908
909// Store singles.
910.LstoreS0_2:
911 LOADREG x15 4 s0 .LfillRegisters2
912 LOADREG x15 4 s1 .LfillRegisters2
913 LOADREG x15 4 s2 .LfillRegisters2
914 LOADREG x15 4 s3 .LfillRegisters2
915 LOADREG x15 4 s4 .LfillRegisters2
916 LOADREG x15 4 s5 .LfillRegisters2
917 LOADREG x15 4 s6 .LfillRegisters2
918 LOADREG x15 4 s7 .LfillRegisters2
919
920// Store doubles.
921.LstoreD0_2:
922 LOADREG x15 8 d0 .LfillRegisters2
923 LOADREG x15 8 d1 .LfillRegisters2
924 LOADREG x15 8 d2 .LfillRegisters2
925 LOADREG x15 8 d3 .LfillRegisters2
926 LOADREG x15 8 d4 .LfillRegisters2
927 LOADREG x15 8 d5 .LfillRegisters2
928 LOADREG x15 8 d6 .LfillRegisters2
929 LOADREG x15 8 d7 .LfillRegisters2
930
931
932.LcallFunction2:
933
Andreas Gampe03906cf2014-04-07 12:08:28 -0700934 INVOKE_STUB_CALL_AND_RETURN
Stuart Monteithb95a5342014-03-12 13:32:32 +0000935
Stuart Monteithb95a5342014-03-12 13:32:32 +0000936END art_quick_invoke_static_stub
937
Andreas Gampe03906cf2014-04-07 12:08:28 -0700938
Stuart Monteithb95a5342014-03-12 13:32:32 +0000939
940 /*
941 * On entry x0 is uintptr_t* gprs_ and x1 is uint64_t* fprs_
942 */
943
944ENTRY art_quick_do_long_jump
945 // Load FPRs
946 ldp d0, d1, [x1], #16
947 ldp d2, d3, [x1], #16
948 ldp d4, d5, [x1], #16
949 ldp d6, d7, [x1], #16
950 ldp d8, d9, [x1], #16
951 ldp d10, d11, [x1], #16
952 ldp d12, d13, [x1], #16
953 ldp d14, d15, [x1], #16
954 ldp d16, d17, [x1], #16
955 ldp d18, d19, [x1], #16
956 ldp d20, d21, [x1], #16
957 ldp d22, d23, [x1], #16
958 ldp d24, d25, [x1], #16
959 ldp d26, d27, [x1], #16
960 ldp d28, d29, [x1], #16
961 ldp d30, d31, [x1]
962
963 // Load GPRs
964 // TODO: lots of those are smashed, could optimize.
965 add x0, x0, #30*8
966 ldp x30, x1, [x0], #-16
967 ldp x28, x29, [x0], #-16
968 ldp x26, x27, [x0], #-16
969 ldp x24, x25, [x0], #-16
970 ldp x22, x23, [x0], #-16
971 ldp x20, x21, [x0], #-16
972 ldp x18, x19, [x0], #-16
973 ldp x16, x17, [x0], #-16
974 ldp x14, x15, [x0], #-16
975 ldp x12, x13, [x0], #-16
976 ldp x10, x11, [x0], #-16
977 ldp x8, x9, [x0], #-16
978 ldp x6, x7, [x0], #-16
979 ldp x4, x5, [x0], #-16
980 ldp x2, x3, [x0], #-16
981 mov sp, x1
982
983 // TODO: Is it really OK to use LR for the target PC?
984 mov x0, #0
985 mov x1, #0
986 br xLR
987END art_quick_do_long_jump
988
Andreas Gampef4e910b2014-04-29 16:55:52 -0700989 /*
990 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
991 * failure.
992 */
993 .extern artHandleFillArrayDataFromCode
994// TODO: xSELF -> x19.
995ENTRY art_quick_handle_fill_data
996 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // Save callee saves in case exception allocation triggers GC.
997 mov x2, xSELF // Pass Thread::Current.
998 mov x3, sp // Pass SP.
999 bl artHandleFillArrayDataFromCode // (Array*, const DexFile::Payload*, Thread*, SP)
1000 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1001 RETURN_IF_RESULT_IS_ZERO
1002 DELIVER_PENDING_EXCEPTION
1003END art_quick_handle_fill_data
Stuart Monteithb95a5342014-03-12 13:32:32 +00001004
1005UNIMPLEMENTED art_quick_lock_object
1006UNIMPLEMENTED art_quick_unlock_object
Andreas Gampe525cde22014-04-22 15:44:50 -07001007
1008 /*
1009 * Entry from managed code that calls artIsAssignableFromCode and on failure calls
1010 * artThrowClassCastException.
1011 */
1012 .extern artThrowClassCastException
1013ENTRY art_quick_check_cast
1014 // Store arguments and link register
1015 sub sp, sp, #32 // Stack needs to be 16b aligned on calls
1016 .cfi_adjust_cfa_offset 32
1017 stp x0, x1, [sp]
1018 .cfi_rel_offset x0, 0
1019 .cfi_rel_offset x1, 8
1020 stp xSELF, xLR, [sp, #16]
1021 .cfi_rel_offset x18, 16
1022 .cfi_rel_offset x30, 24
1023
1024 // Call runtime code
1025 bl artIsAssignableFromCode
1026
1027 // Check for exception
1028 cbz x0, .Lthrow_class_cast_exception
1029
1030 // Restore and return
1031 ldp x0, x1, [sp]
1032 .cfi_restore x0
1033 .cfi_restore x1
1034 ldp xSELF, xLR, [sp, #16]
1035 .cfi_restore x18
1036 .cfi_restore x30
1037 add sp, sp, #32
1038 .cfi_adjust_cfa_offset -32
1039 ret
1040
1041.Lthrow_class_cast_exception:
1042 // Restore
1043 ldp x0, x1, [sp]
1044 .cfi_restore x0
1045 .cfi_restore x1
1046 ldp xSELF, xLR, [sp, #16]
1047 .cfi_restore x18
1048 .cfi_restore x30
1049 add sp, sp, #32
1050 .cfi_adjust_cfa_offset -32
1051
1052 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
1053 mov x2, xSELF // pass Thread::Current
1054 mov x3, sp // pass SP
1055 b artThrowClassCastException // (Class*, Class*, Thread*, SP)
1056 brk 0 // We should not return here...
1057END art_quick_check_cast
1058
Andreas Gampef4e910b2014-04-29 16:55:52 -07001059 /*
1060 * Entry from managed code for array put operations of objects where the value being stored
1061 * needs to be checked for compatibility.
1062 * x0 = array, x1 = index, x2 = value
1063 *
1064 * Currently all values should fit into w0/w1/w2, and w1 always will as indices are 32b. We
1065 * assume, though, that the upper 32b are zeroed out. At least for x1/w1 we can do better by
1066 * using index-zero-extension in load/stores.
1067 *
1068 * Temporaries: x3, x4
1069 * TODO: x4 OK? ip seems wrong here.
1070 */
1071ENTRY art_quick_aput_obj_with_null_and_bound_check
1072 tst x0, x0
1073 bne art_quick_aput_obj_with_bound_check
1074 b art_quick_throw_null_pointer_exception
1075END art_quick_aput_obj_with_null_and_bound_check
1076
1077ENTRY art_quick_aput_obj_with_bound_check
1078 ldr w3, [x0, #ARRAY_LENGTH_OFFSET]
1079 cmp w3, w1
1080 bhi art_quick_aput_obj
1081 mov x0, x1
1082 mov x1, x3
1083 b art_quick_throw_array_bounds
1084END art_quick_aput_obj_with_bound_check
1085
1086ENTRY art_quick_aput_obj
1087 cbz x2, .Ldo_aput_null
1088 ldr w3, [x0, #CLASS_OFFSET] // Heap reference = 32b
1089 // This also zero-extends to x3
1090 ldr w4, [x2, #CLASS_OFFSET] // Heap reference = 32b
1091 // This also zero-extends to x4
1092 ldr w3, [x3, #CLASS_COMPONENT_TYPE_OFFSET] // Heap reference = 32b
1093 // This also zero-extends to x3
1094 cmp w3, w4 // value's type == array's component type - trivial assignability
1095 bne .Lcheck_assignability
1096.Ldo_aput:
1097 add x3, x0, #OBJECT_ARRAY_DATA_OFFSET
1098 // "Compress" = do nothing
1099 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1100 ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET]
1101 lsr x0, x0, #7
1102 strb w3, [x3, x0]
1103 ret
1104.Ldo_aput_null:
1105 add x3, x0, #OBJECT_ARRAY_DATA_OFFSET
1106 // "Compress" = do nothing
1107 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1108 ret
1109.Lcheck_assignability:
1110 // Store arguments and link register
1111 sub sp, sp, #48 // Stack needs to be 16b aligned on calls
1112 .cfi_adjust_cfa_offset 48
1113 stp x0, x1, [sp]
1114 .cfi_rel_offset x0, 0
1115 .cfi_rel_offset x1, 8
1116 stp x2, xSELF, [sp, #16]
1117 .cfi_rel_offset x2, 16
1118 .cfi_rel_offset x18, 24
1119 str xLR, [sp, #32]
1120 .cfi_rel_offset x30, 32
1121
1122 // Call runtime code
1123 mov x0, x3 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended
1124 mov x1, x4 // Heap reference, 32b, "uncompress" = do nothing, already zero-extended
1125 bl artIsAssignableFromCode
1126
1127 // Check for exception
1128 cbz x0, .Lthrow_array_store_exception
1129
1130 // Restore
1131 ldp x0, x1, [sp]
1132 .cfi_restore x0
1133 .cfi_restore x1
1134 ldp x2, xSELF, [sp, #16]
1135 .cfi_restore x2
1136 .cfi_restore x18
1137 ldr xLR, [sp, #32]
1138 .cfi_restore x30
1139 add sp, sp, #48
1140 .cfi_adjust_cfa_offset -48
1141
1142 add x3, x0, #OBJECT_ARRAY_DATA_OFFSET
1143 // "Compress" = do nothing
1144 str w2, [x3, x1, lsl #2] // Heap reference = 32b
1145 ldr x3, [xSELF, #THREAD_CARD_TABLE_OFFSET]
1146 lsr x0, x0, #7
1147 strb w3, [x3, x0]
1148 ret
1149.Lthrow_array_store_exception:
1150 ldp x0, x1, [sp]
1151 .cfi_restore x0
1152 .cfi_restore x1
1153 ldp x2, xSELF, [sp, #16]
1154 .cfi_restore x2
1155 .cfi_restore x18
1156 ldr xLR, [sp, #32]
1157 .cfi_restore x30
1158 add sp, sp, #48
1159 .cfi_adjust_cfa_offset -48
1160
1161 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1162 mov x1, x2 // Pass value.
1163 mov x2, xSELF // Pass Thread::Current.
1164 mov x3, sp // Pass SP.
1165 b artThrowArrayStoreException // (Object*, Object*, Thread*, SP).
1166 brk 0 // Unreached.
1167END art_quick_aput_obj
1168
Stuart Monteithb95a5342014-03-12 13:32:32 +00001169// Macro to facilitate adding new allocation entrypoints.
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001170// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY
Stuart Monteithb95a5342014-03-12 13:32:32 +00001171.macro TWO_ARG_DOWNCALL name, entrypoint, return
1172 .extern \entrypoint
1173ENTRY \name
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001174 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1175 mov x2, xSELF // pass Thread::Current
1176 mov x3, sp // pass SP
1177 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*, SP)
1178 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1179 \return
1180 DELIVER_PENDING_EXCEPTION
Stuart Monteithb95a5342014-03-12 13:32:32 +00001181END \name
1182.endm
1183
1184// Macro to facilitate adding new array allocation entrypoints.
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001185// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY
Stuart Monteithb95a5342014-03-12 13:32:32 +00001186.macro THREE_ARG_DOWNCALL name, entrypoint, return
1187 .extern \entrypoint
1188ENTRY \name
Andreas Gampe00c1e6d2014-04-25 15:47:13 -07001189 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1190 mov x3, xSELF // pass Thread::Current
1191 mov x4, sp // pass SP
1192 bl \entrypoint
1193 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1194 \return
1195 DELIVER_PENDING_EXCEPTION
Stuart Monteithb95a5342014-03-12 13:32:32 +00001196END \name
1197.endm
1198
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001199// Macros taking opportunity of code similarities for downcalls with referrer.
1200
1201// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY
1202.macro ONE_ARG_REF_DOWNCALL name, entrypoint, return
1203 .extern \entrypoint
1204ENTRY \name
1205 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1206 ldr x1, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer
1207 mov x2, xSELF // pass Thread::Current
1208 mov x3, sp // pass SP
1209 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*, SP)
1210 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1211 \return
1212END \name
1213.endm
1214
1215// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY
1216.macro TWO_ARG_REF_DOWNCALL name, entrypoint, return
1217 .extern \entrypoint
1218ENTRY \name
1219 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1220 ldr x2, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer
1221 mov x3, xSELF // pass Thread::Current
1222 mov x4, sp // pass SP
1223 bl \entrypoint
1224 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1225 \return
1226END \name
1227.endm
1228
1229// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY
1230.macro THREE_ARG_REF_DOWNCALL name, entrypoint, return
1231 .extern \entrypoint
1232ENTRY \name
1233 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1234 ldr x3, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer
1235 mov x4, xSELF // pass Thread::Current
1236 mov x5, sp // pass SP
1237 bl \entrypoint
1238 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1239 \return
1240END \name
1241.endm
1242
Matteo Franchindfd891a2014-04-30 12:17:17 +01001243 /*
1244 * Entry from managed code when uninitialized static storage, this stub will run the class
1245 * initializer and deliver the exception on error. On success the static storage base is
1246 * returned.
1247 */
1248TWO_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO
1249
1250UNIMPLEMENTED art_quick_initialize_type
1251UNIMPLEMENTED art_quick_initialize_type_and_verify_access
1252
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001253ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1254ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1255ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1256
1257TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1258TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1259TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_X1
1260
1261TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1262TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1263
1264THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1265THREE_ARG_DOWNCALL art_quick_set64_instance, artSet64InstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1266THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_W0_IS_ZERO_OR_DELIVER
1267
1268// This is separated out as the argument order is different.
1269 .extern artSet64StaticFromCode
1270ENTRY art_quick_set64_static
1271 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC
1272 mov x3, x1 // Store value
1273 ldr x1, [sp, #FRAME_SIZE_REFS_ONLY_CALLEE_SAVE] // Load referrer
1274 mov x2, x3 // Put value param
1275 mov x3, xSELF // pass Thread::Current
1276 mov x4, sp // pass SP
1277 bl artSet64StaticFromCode
1278 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1279 RETURN_IF_W0_IS_ZERO_OR_DELIVER
1280END art_quick_set64_static
1281
Matteo Franchindfd891a2014-04-30 12:17:17 +01001282 /*
1283 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1284 * exception on error. On success the String is returned. x0 holds the referring method,
1285 * w1 holds the string index. The fast path check for hit in strings cache has already been
1286 * performed.
1287 */
1288TWO_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO
Andreas Gampe6e4e59c2014-05-05 20:11:02 -07001289
Stuart Monteithb95a5342014-03-12 13:32:32 +00001290// Generate the allocation entrypoints for each allocator.
1291GENERATE_ALL_ALLOC_ENTRYPOINTS
1292
1293UNIMPLEMENTED art_quick_test_suspend
1294
Andreas Gampee62a07e2014-03-26 14:53:21 -07001295 /*
1296 * Called by managed code that is attempting to call a method on a proxy class. On entry
1297 * x0 holds the proxy method and x1 holds the receiver; The frame size of the invoked proxy
1298 * method agrees with a ref and args callee save frame.
1299 */
1300 .extern artQuickProxyInvokeHandler
1301ENTRY art_quick_proxy_invoke_handler
1302 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
1303 str x0, [sp, #0] // place proxy method at bottom of frame
1304 mov x2, xSELF // pass Thread::Current
1305 mov x3, sp // pass SP
1306 bl artQuickProxyInvokeHandler // (Method* proxy method, receiver, Thread*, SP)
1307 ldr xSELF, [sp, #200] // Restore self pointer.
1308 ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET]
1309 cbnz x2, .Lexception_in_proxy // success if no exception is pending
1310 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME_NO_D0 // keep d0
1311 ret // return on success
1312.Lexception_in_proxy:
1313 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1314 DELIVER_PENDING_EXCEPTION
1315END art_quick_proxy_invoke_handler
Stuart Monteithb95a5342014-03-12 13:32:32 +00001316
1317UNIMPLEMENTED art_quick_imt_conflict_trampoline
1318
1319
1320ENTRY art_quick_resolution_trampoline
1321 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
1322 mov x2, xSELF
1323 mov x3, sp
1324 bl artQuickResolutionTrampoline // (called, receiver, Thread*, SP)
Matteo Franchindfd891a2014-04-30 12:17:17 +01001325 cbz x0, 1f
1326 mov x9, x0 // Remember returned code pointer in x9.
1327 ldr x0, [sp, #0] // artQuickResolutionTrampoline puts called method in *SP.
Stuart Monteithb95a5342014-03-12 13:32:32 +00001328 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Andreas Gampec6ee54e2014-03-24 16:45:44 -07001329 br x9
Stuart Monteithb95a5342014-03-12 13:32:32 +000013301:
1331 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1332 DELIVER_PENDING_EXCEPTION
1333END art_quick_resolution_trampoline
1334
1335/*
1336 * Generic JNI frame layout:
1337 *
1338 * #-------------------#
1339 * | |
1340 * | caller method... |
1341 * #-------------------# <--- SP on entry
1342 * | Return X30/LR |
1343 * | X29/FP | callee save
1344 * | X28 | callee save
1345 * | X27 | callee save
1346 * | X26 | callee save
1347 * | X25 | callee save
1348 * | X24 | callee save
1349 * | X23 | callee save
1350 * | X22 | callee save
1351 * | X21 | callee save
1352 * | X20 | callee save
1353 * | X19 | callee save
1354 * | X7 | arg7
1355 * | X6 | arg6
1356 * | X5 | arg5
1357 * | X4 | arg4
1358 * | X3 | arg3
1359 * | X2 | arg2
1360 * | X1 | arg1
1361 * | D15 | float arg 8
1362 * | D14 | float arg 8
1363 * | D13 | float arg 8
1364 * | D12 | callee save
1365 * | D11 | callee save
1366 * | D10 | callee save
1367 * | D9 | callee save
1368 * | D8 | callee save
1369 * | D7 | float arg 8
1370 * | D6 | float arg 7
1371 * | D5 | float arg 6
1372 * | D4 | float arg 5
1373 * | D3 | float arg 4
1374 * | D2 | float arg 3
1375 * | D1 | float arg 2
1376 * | D0 | float arg 1
1377 * | RDI/Method* | <- X0
1378 * #-------------------#
1379 * | local ref cookie | // 4B
1380 * | SIRT size | // 4B
1381 * #-------------------#
1382 * | JNI Call Stack |
1383 * #-------------------# <--- SP on native call
1384 * | |
1385 * | Stack for Regs | The trampoline assembly will pop these values
1386 * | | into registers for native call
1387 * #-------------------#
1388 * | Native code ptr |
1389 * #-------------------#
1390 * | Free scratch |
1391 * #-------------------#
1392 * | Ptr to (1) | <--- SP
1393 * #-------------------#
1394 */
1395 /*
1396 * Called to do a generic JNI down-call
1397 */
1398ENTRY art_quick_generic_jni_trampoline
1399 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL
1400 str x0, [sp, #0] // Store native ArtMethod* to bottom of stack.
1401
1402 // Save SP , so we can have static CFI info.
1403 mov x28, sp
1404 .cfi_def_cfa_register x28
1405
1406 // This looks the same, but is different: this will be updated to point to the bottom
1407 // of the frame when the SIRT is inserted.
1408 mov xFP, sp
1409
1410 mov x8, #5120
1411 sub sp, sp, x8
1412
1413 // prepare for artQuickGenericJniTrampoline call
1414 // (Thread*, SP)
1415 // x0 x1 <= C calling convention
1416 // xSELF xFP <= where they are
1417
1418 mov x0, xSELF // Thread*
1419 mov x1, xFP
1420 bl artQuickGenericJniTrampoline // (Thread*, sp)
1421
1422 // Get the updated pointer. This is the bottom of the frame _with_ SIRT.
1423 ldr xFP, [sp]
1424 add x9, sp, #8
1425
1426 cmp x0, #0
1427 b.mi .Lentry_error // Check for error, negative value.
1428
1429 // release part of the alloca.
1430 add x9, x9, x0
1431
1432 // Get the code pointer
1433 ldr xIP0, [x9, #0]
1434
1435 // Load parameters from frame into registers.
1436 // TODO Check with artQuickGenericJniTrampoline.
1437 // Also, check again APPCS64 - the stack arguments are interleaved.
1438 ldp x0, x1, [x9, #8]
1439 ldp x2, x3, [x9, #24]
1440 ldp x4, x5, [x9, #40]
1441 ldp x6, x7, [x9, #56]
1442
1443 ldp d0, d1, [x9, #72]
1444 ldp d2, d3, [x9, #88]
1445 ldp d4, d5, [x9, #104]
1446 ldp d6, d7, [x9, #120]
1447
1448 add sp, x9, #136
1449
1450 blr xIP0 // native call.
1451
1452 // Restore self pointer.
1453 ldr xSELF, [x28, #200]
1454
1455 // result sign extension is handled in C code
1456 // prepare for artQuickGenericJniEndTrampoline call
1457 // (Thread*, SP, result, result_f)
1458 // x0 x1 x2 x3 <= C calling convention
1459 mov x5, x0 // Save return value
1460 mov x0, xSELF // Thread register
1461 mov x1, xFP // Stack pointer
1462 mov x2, x5 // Result (from saved)
1463 fmov x3, d0 // d0 will contain floating point result, but needs to go into x3
1464
1465 bl artQuickGenericJniEndTrampoline
1466
1467 // Tear down the alloca.
1468 mov sp, x28
1469 .cfi_def_cfa_register sp
1470
1471 // Restore self pointer.
1472 ldr xSELF, [x28, #200]
1473
1474 // Pending exceptions possible.
1475 ldr x1, [xSELF, THREAD_EXCEPTION_OFFSET]
1476 cbnz x1, .Lexception_in_native
1477
1478 // Tear down the callee-save frame.
1479 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1480
1481 // store into fpr, for when it's a fpr return...
1482 fmov d0, x0
1483 ret
1484
1485.Lentry_error:
1486 mov sp, x28
1487 .cfi_def_cfa_register sp
1488 ldr xSELF, [x28, #200]
1489.Lexception_in_native:
1490 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1491 DELIVER_PENDING_EXCEPTION
1492
1493END art_quick_generic_jni_trampoline
1494
1495/*
1496 * Called to bridge from the quick to interpreter ABI. On entry the arguments match those
1497 * of a quick call:
1498 * x0 = method being called/to bridge to.
1499 * x1..x7, d0..d7 = arguments to that method.
1500 */
1501ENTRY art_quick_to_interpreter_bridge
1502 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // Set up frame and save arguments.
1503
1504 // x0 will contain mirror::ArtMethod* method.
1505 mov x1, xSELF // How to get Thread::Current() ???
1506 mov x2, sp
1507
1508 // uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self,
1509 // mirror::ArtMethod** sp)
1510 bl artQuickToInterpreterBridge
1511
1512 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME // TODO: no need to restore arguments in this case.
1513
1514 fmov d0, x0
1515
1516 RETURN_OR_DELIVER_PENDING_EXCEPTION
1517END art_quick_to_interpreter_bridge
1518
1519UNIMPLEMENTED art_quick_instrumentation_entry
1520UNIMPLEMENTED art_quick_instrumentation_exit
1521UNIMPLEMENTED art_quick_deoptimize
1522UNIMPLEMENTED art_quick_mul_long
1523UNIMPLEMENTED art_quick_shl_long
1524UNIMPLEMENTED art_quick_shr_long
1525UNIMPLEMENTED art_quick_ushr_long
1526UNIMPLEMENTED art_quick_indexof
Andreas Gampe266340d2014-05-02 07:55:24 -07001527
1528 /*
1529 * String's compareTo.
1530 *
1531 * TODO: Not very optimized.
1532 *
1533 * On entry:
1534 * x0: this object pointer
1535 * x1: comp object pointer
1536 *
1537 */
1538 .extern __memcmp16
1539ENTRY art_quick_string_compareto
1540 mov x2, x0 // x0 is return, use x2 for first input.
1541 sub x0, x2, x1 // Same string object?
1542 cbnz x0,1f
1543 ret
15441: // Different string objects.
1545
1546 ldr w6, [x2, #STRING_OFFSET_OFFSET]
1547 ldr w5, [x1, #STRING_OFFSET_OFFSET]
1548 ldr w4, [x2, #STRING_COUNT_OFFSET]
1549 ldr w3, [x1, #STRING_COUNT_OFFSET]
1550 ldr w2, [x2, #STRING_VALUE_OFFSET]
1551 ldr w1, [x1, #STRING_VALUE_OFFSET]
1552
1553 /*
1554 * Now: CharArray* Offset Count
1555 * first arg x2 w6 w4
1556 * second arg x1 w5 w3
1557 */
1558
1559 // x0 := str1.length(w4) - str2.length(w3). ldr zero-extended w3/w4 into x3/x4.
1560 subs x0, x4, x3
1561 // Min(count1, count2) into w3.
1562 csel x3, x3, x4, ge
1563
1564 // Build pointer into string data.
1565
1566 // Add offset in array (substr etc.) (sign extend and << 1).
1567 add x2, x2, w6, sxtw #1
1568 add x1, x1, w5, sxtw #1
1569
1570 // Add offset in CharArray to array.
1571 add x2, x2, #STRING_DATA_OFFSET
1572 add x1, x1, #STRING_DATA_OFFSET
1573
1574 // Check for long string, do memcmp16 for them.
1575 cmp w3, #28 // Constant from arm32.
1576 bgt .Ldo_memcmp16
1577
1578 /*
1579 * Now:
1580 * x2: *first string data
1581 * x1: *second string data
1582 * w3: iteration count
1583 * x0: return value if comparison equal
1584 * x4, x5, x6, x7: free
1585 */
1586
1587 // Do a simple unrolled loop.
1588.Lloop:
1589 // At least two more elements?
1590 subs w3, w3, #2
1591 b.lt .Lremainder_or_done
1592
1593 ldrh w4, [x2], #2
1594 ldrh w5, [x1], #2
1595
1596 ldrh w6, [x2], #2
1597 ldrh w7, [x1], #2
1598
1599 subs w4, w4, w5
1600 b.ne .Lw4_result
1601
1602 subs w6, w6, w7
1603 b.ne .Lw6_result
1604
1605 b .Lloop
1606
1607.Lremainder_or_done:
1608 adds w3, w3, #1
1609 b.eq .Lremainder
1610 ret
1611
1612.Lremainder:
1613 ldrh w4, [x2], #2
1614 ldrh w5, [x1], #2
1615 subs w4, w4, w5
1616 b.ne .Lw4_result
1617 ret
1618
1619// Result is in w4
1620.Lw4_result:
1621 sxtw x0, w4
1622 ret
1623
1624// Result is in w6
1625.Lw6_result:
1626 sxtw x0, w6
1627 ret
1628
1629.Ldo_memcmp16:
1630 str x0, [sp,#-16]! // Save x0
1631
1632 mov x0, x2
1633 uxtw x2, w3
1634 bl __memcmp16
1635
1636 ldr x1, [sp], #16 // Restore old x0 = length diff
1637
1638 cmp x0, #0 // Check the memcmp difference
1639 csel x0, x0, x1, ne // x0 := x0 != 0 ? x0 : x1
1640 ret
1641END art_quick_string_compareto