blob: 0fcf866e186bc447fa643510b899218da49a0f2a [file] [log] [blame]
Elliott Hughes0f3c5532012-03-30 14:51:51 -07001/*
2 * Copyright (C) 2012 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
Ian Rogers7655f292013-07-29 11:07:13 -070017#include "asm_support_arm.S"
Ian Rogers9651f422011-09-19 20:26:07 -070018
Mathieu Chartier7410f292013-11-24 13:17:35 -080019#include "arch/quick_alloc_entrypoints.S"
20
Ian Rogersff1ed472011-09-20 13:46:24 -070021 /* Deliver the given exception */
22 .extern artDeliverExceptionFromCode
23 /* Deliver an exception pending on a thread */
24 .extern artDeliverPendingException
25
Ian Rogers4f0d07c2011-10-06 23:38:47 -070026 /*
Andreas Gampe76914b02015-07-17 20:14:50 -070027 * Macro to spill the GPRs.
Ian Rogers4f0d07c2011-10-06 23:38:47 -070028 */
Andreas Gampe76914b02015-07-17 20:14:50 -070029.macro SPILL_ALL_CALLEE_SAVE_GPRS
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070030 push {r4-r11, lr} @ 9 words (36 bytes) of callee saves.
Ian Rogers9329bbb2013-02-08 19:56:30 -080031 .cfi_adjust_cfa_offset 36
32 .cfi_rel_offset r4, 0
33 .cfi_rel_offset r5, 4
34 .cfi_rel_offset r6, 8
35 .cfi_rel_offset r7, 12
36 .cfi_rel_offset r8, 16
37 .cfi_rel_offset r9, 20
38 .cfi_rel_offset r10, 24
39 .cfi_rel_offset r11, 28
40 .cfi_rel_offset lr, 32
Andreas Gampe76914b02015-07-17 20:14:50 -070041.endm
42
43 /*
44 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +010045 * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves)
Andreas Gampe76914b02015-07-17 20:14:50 -070046 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +010047.macro SETUP_SAVE_ALL_CALLEE_SAVES_FRAME rTemp
Andreas Gampe76914b02015-07-17 20:14:50 -070048 SPILL_ALL_CALLEE_SAVE_GPRS @ 9 words (36 bytes) of callee saves.
Zheng Xu5667fdb2014-10-23 18:29:55 +080049 vpush {s16-s31} @ 16 words (64 bytes) of floats.
Zheng Xu5667fdb2014-10-23 18:29:55 +080050 .cfi_adjust_cfa_offset 64
51 sub sp, #12 @ 3 words of space, bottom word will hold Method*
Ian Rogers9329bbb2013-02-08 19:56:30 -080052 .cfi_adjust_cfa_offset 12
Vladimir Marko3098c8c2016-06-14 17:43:17 +010053 RUNTIME_CURRENT1 \rTemp @ Load Runtime::Current into rTemp.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010054 @ Load kSaveAllCalleeSaves Method* into rTemp.
55 ldr \rTemp, [\rTemp, #RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET]
Vladimir Marko3098c8c2016-06-14 17:43:17 +010056 str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070057 str sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
Andreas Gampe5c1e4352014-04-21 19:28:24 -070058
59 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010060#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 36 + 64 + 12)
61#error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(ARM) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -070062#endif
Ian Rogers4f0d07c2011-10-06 23:38:47 -070063.endm
64
65 /*
66 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +010067 * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly).
Ian Rogers4f0d07c2011-10-06 23:38:47 -070068 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +010069.macro SETUP_SAVE_REFS_ONLY_FRAME rTemp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070070 push {r5-r8, r10-r11, lr} @ 7 words of callee saves
Ian Rogers9329bbb2013-02-08 19:56:30 -080071 .cfi_adjust_cfa_offset 28
72 .cfi_rel_offset r5, 0
73 .cfi_rel_offset r6, 4
74 .cfi_rel_offset r7, 8
75 .cfi_rel_offset r8, 12
76 .cfi_rel_offset r10, 16
77 .cfi_rel_offset r11, 20
78 .cfi_rel_offset lr, 24
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070079 sub sp, #4 @ bottom word will hold Method*
Ian Rogers9329bbb2013-02-08 19:56:30 -080080 .cfi_adjust_cfa_offset 4
Vladimir Marko3098c8c2016-06-14 17:43:17 +010081 RUNTIME_CURRENT2 \rTemp @ Load Runtime::Current into rTemp.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010082 @ Load kSaveRefsOnly Method* into rTemp.
83 ldr \rTemp, [\rTemp, #RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET]
Vladimir Marko3098c8c2016-06-14 17:43:17 +010084 str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070085 str sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
Andreas Gampe5c1e4352014-04-21 19:28:24 -070086
87 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010088#if (FRAME_SIZE_SAVE_REFS_ONLY != 28 + 4)
89#error "FRAME_SIZE_SAVE_REFS_ONLY(ARM) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -070090#endif
Ian Rogers4f0d07c2011-10-06 23:38:47 -070091.endm
92
Vladimir Markofd36f1f2016-08-03 18:49:58 +010093.macro RESTORE_SAVE_REFS_ONLY_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070094 add sp, #4 @ bottom word holds Method*
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -070095 .cfi_adjust_cfa_offset -4
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070096 pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
Dave Allisonbbb32c22013-11-05 18:25:18 -080097 .cfi_restore r5
98 .cfi_restore r6
99 .cfi_restore r7
100 .cfi_restore r8
101 .cfi_restore r10
102 .cfi_restore r11
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700103 .cfi_restore lr
104 .cfi_adjust_cfa_offset -28
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700105.endm
106
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100107.macro RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN
108 RESTORE_SAVE_REFS_ONLY_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700109 bx lr @ return
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700110.endm
111
112 /*
113 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100114 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs).
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700115 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100116.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Zheng Xu5667fdb2014-10-23 18:29:55 +0800117 push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves and args.
Zheng Xu5667fdb2014-10-23 18:29:55 +0800118 .cfi_adjust_cfa_offset 40
Jeff Hao5d917302013-02-27 17:57:33 -0800119 .cfi_rel_offset r1, 0
120 .cfi_rel_offset r2, 4
121 .cfi_rel_offset r3, 8
122 .cfi_rel_offset r5, 12
123 .cfi_rel_offset r6, 16
124 .cfi_rel_offset r7, 20
125 .cfi_rel_offset r8, 24
126 .cfi_rel_offset r10, 28
127 .cfi_rel_offset r11, 32
128 .cfi_rel_offset lr, 36
Zheng Xu5667fdb2014-10-23 18:29:55 +0800129 vpush {s0-s15} @ 16 words of float args.
Zheng Xu5667fdb2014-10-23 18:29:55 +0800130 .cfi_adjust_cfa_offset 64
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100131 sub sp, #8 @ 2 words of space, alignment padding and Method*
Ian Rogers9329bbb2013-02-08 19:56:30 -0800132 .cfi_adjust_cfa_offset 8
Zheng Xu5667fdb2014-10-23 18:29:55 +0800133 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100134#if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 40 + 64 + 8)
135#error "FRAME_SIZE_SAVE_REFS_AND_ARGS(ARM) size not as expected."
Zheng Xu5667fdb2014-10-23 18:29:55 +0800136#endif
137.endm
138
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100139.macro SETUP_SAVE_REFS_AND_ARGS_FRAME rTemp
140 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Vladimir Marko3098c8c2016-06-14 17:43:17 +0100141 RUNTIME_CURRENT3 \rTemp @ Load Runtime::Current into rTemp.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100142 @ Load kSaveRefsAndArgs Method* into rTemp.
143 ldr \rTemp, [\rTemp, #RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET]
Vladimir Marko3098c8c2016-06-14 17:43:17 +0100144 str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700145 str sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700146.endm
147
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100148.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_R0
149 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
150 str r0, [sp, #0] @ Store ArtMethod* to bottom of stack.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700151 str sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
152.endm
153
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100154.macro RESTORE_SAVE_REFS_AND_ARGS_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700155 add sp, #8 @ rewind sp
Zheng Xu5667fdb2014-10-23 18:29:55 +0800156 .cfi_adjust_cfa_offset -8
157 vpop {s0-s15}
158 .cfi_adjust_cfa_offset -64
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700159 pop {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
Dave Allisonbbb32c22013-11-05 18:25:18 -0800160 .cfi_restore r1
161 .cfi_restore r2
162 .cfi_restore r3
163 .cfi_restore r5
164 .cfi_restore r6
165 .cfi_restore r7
166 .cfi_restore r8
167 .cfi_restore r10
168 .cfi_restore r11
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700169 .cfi_restore lr
Zheng Xu5667fdb2014-10-23 18:29:55 +0800170 .cfi_adjust_cfa_offset -40
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700171.endm
172
Vladimir Marko952dbb12016-07-28 12:01:51 +0100173 /*
174 * Macro that sets up the callee save frame to conform with
175 * Runtime::CreateCalleeSaveMethod(kSaveEverything)
176 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100177.macro SETUP_SAVE_EVERYTHING_FRAME rTemp
Vladimir Marko952dbb12016-07-28 12:01:51 +0100178 push {r0-r12, lr} @ 14 words of callee saves and args.
179 .cfi_adjust_cfa_offset 56
180 .cfi_rel_offset r0, 0
181 .cfi_rel_offset r1, 4
182 .cfi_rel_offset r2, 8
183 .cfi_rel_offset r3, 12
184 .cfi_rel_offset r4, 16
185 .cfi_rel_offset r5, 20
186 .cfi_rel_offset r6, 24
187 .cfi_rel_offset r7, 28
188 .cfi_rel_offset r8, 32
189 .cfi_rel_offset r9, 36
190 .cfi_rel_offset r10, 40
191 .cfi_rel_offset r11, 44
192 .cfi_rel_offset ip, 48
193 .cfi_rel_offset lr, 52
194 vpush {s0-s31} @ 32 words of float args.
195 .cfi_adjust_cfa_offset 128
196 sub sp, #8 @ 2 words of space, alignment padding and Method*
197 .cfi_adjust_cfa_offset 8
198 RUNTIME_CURRENT1 \rTemp @ Load Runtime::Current into rTemp.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100199 @ Load kSaveEverything Method* into rTemp.
200 ldr \rTemp, [\rTemp, #RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET]
201 str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
Vladimir Marko952dbb12016-07-28 12:01:51 +0100202 str sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
203
204 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100205#if (FRAME_SIZE_SAVE_EVERYTHING != 56 + 128 + 8)
206#error "FRAME_SIZE_SAVE_EVERYTHING(ARM) size not as expected."
Vladimir Marko952dbb12016-07-28 12:01:51 +0100207#endif
208.endm
209
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100210.macro RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +0100211 add sp, #8 @ rewind sp
212 .cfi_adjust_cfa_offset -8
213 vpop {s0-s31}
214 .cfi_adjust_cfa_offset -128
215 pop {r0-r12, lr} @ 14 words of callee saves
216 .cfi_restore r0
217 .cfi_restore r1
218 .cfi_restore r2
219 .cfi_restore r3
220 .cfi_restore r5
221 .cfi_restore r6
222 .cfi_restore r7
223 .cfi_restore r8
224 .cfi_restore r9
225 .cfi_restore r10
226 .cfi_restore r11
227 .cfi_restore r12
228 .cfi_restore lr
229 .cfi_adjust_cfa_offset -56
230.endm
231
Ian Rogers637859c2013-08-27 14:35:54 -0700232.macro RETURN_IF_RESULT_IS_ZERO
233 cbnz r0, 1f @ result non-zero branch over
234 bx lr @ return
2351:
236.endm
237
238.macro RETURN_IF_RESULT_IS_NON_ZERO
239 cbz r0, 1f @ result zero branch over
240 bx lr @ return
2411:
242.endm
243
Ian Rogersce9eca62011-10-07 17:11:03 -0700244 /*
245 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
246 * exception is Thread::Current()->exception_
247 */
248.macro DELIVER_PENDING_EXCEPTION
Ian Rogers9329bbb2013-02-08 19:56:30 -0800249 .fnend
250 .fnstart
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100251 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r0 @ save callee saves for throw
Ian Rogersce9eca62011-10-07 17:11:03 -0700252 mov r0, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700253 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*)
Ian Rogersce9eca62011-10-07 17:11:03 -0700254.endm
255
Ian Rogers57b86d42012-03-27 16:05:41 -0700256.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700257 .extern \cxx_name
Ian Rogers9329bbb2013-02-08 19:56:30 -0800258ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100259 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r0 @ save all registers as basis for long jump context
Ian Rogers57b86d42012-03-27 16:05:41 -0700260 mov r0, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700261 b \cxx_name @ \cxx_name(Thread*)
Ian Rogers9329bbb2013-02-08 19:56:30 -0800262END \c_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700263.endm
buzbee44b412b2012-02-04 08:50:53 -0800264
Ian Rogers57b86d42012-03-27 16:05:41 -0700265.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700266 .extern \cxx_name
Ian Rogers9329bbb2013-02-08 19:56:30 -0800267ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100268 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r1 @ save all registers as basis for long jump context
Ian Rogersff1ed472011-09-20 13:46:24 -0700269 mov r1, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700270 b \cxx_name @ \cxx_name(Thread*)
Ian Rogers9329bbb2013-02-08 19:56:30 -0800271END \c_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700272.endm
Ian Rogers9651f422011-09-19 20:26:07 -0700273
Ian Rogers57b86d42012-03-27 16:05:41 -0700274.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700275 .extern \cxx_name
Ian Rogers9329bbb2013-02-08 19:56:30 -0800276ENTRY \c_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100277 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r2 @ save all registers as basis for long jump context
Ian Rogersff1ed472011-09-20 13:46:24 -0700278 mov r2, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700279 b \cxx_name @ \cxx_name(Thread*)
Ian Rogers9329bbb2013-02-08 19:56:30 -0800280END \c_name
Ian Rogers57b86d42012-03-27 16:05:41 -0700281.endm
Ian Rogersbdb03912011-09-14 00:55:44 -0700282
Fred Shih37f05ef2014-07-16 18:38:08 -0700283.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg
284 ldr \reg, [r9, #THREAD_EXCEPTION_OFFSET] // Get exception field.
285 cbnz \reg, 1f
286 bx lr
2871:
288 DELIVER_PENDING_EXCEPTION
289.endm
290
291.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
292 RETURN_OR_DELIVER_PENDING_EXCEPTION_REG r1
293.endm
294
295.macro RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
296 RETURN_IF_RESULT_IS_ZERO
297 DELIVER_PENDING_EXCEPTION
298.endm
299
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800300.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
301 RETURN_IF_RESULT_IS_NON_ZERO
302 DELIVER_PENDING_EXCEPTION
303.endm
304
Fred Shih37f05ef2014-07-16 18:38:08 -0700305// Macros taking opportunity of code similarities for downcalls with referrer for non-wide fields.
306.macro ONE_ARG_REF_DOWNCALL name, entrypoint, return
307 .extern \entrypoint
308ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100309 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves in case of GC
310 ldr r1, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Fred Shih37f05ef2014-07-16 18:38:08 -0700311 mov r2, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700312 bl \entrypoint @ (uint32_t field_idx, const Method* referrer, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100313 RESTORE_SAVE_REFS_ONLY_FRAME
Fred Shih37f05ef2014-07-16 18:38:08 -0700314 \return
315END \name
316.endm
317
318.macro TWO_ARG_REF_DOWNCALL name, entrypoint, return
319 .extern \entrypoint
320ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100321 SETUP_SAVE_REFS_ONLY_FRAME r2 @ save callee saves in case of GC
322 ldr r2, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Fred Shih37f05ef2014-07-16 18:38:08 -0700323 mov r3, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700324 bl \entrypoint @ (field_idx, Object*, referrer, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100325 RESTORE_SAVE_REFS_ONLY_FRAME
Fred Shih37f05ef2014-07-16 18:38:08 -0700326 \return
327END \name
328.endm
329
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800330.macro THREE_ARG_REF_DOWNCALL name, entrypoint, return
Fred Shih37f05ef2014-07-16 18:38:08 -0700331 .extern \entrypoint
332ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100333 SETUP_SAVE_REFS_ONLY_FRAME r3 @ save callee saves in case of GC
334 ldr r3, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700335 str r9, [sp, #-16]! @ expand the frame and pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700336 .cfi_adjust_cfa_offset 16
337 bl \entrypoint @ (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700338 add sp, #16 @ release out args
339 .cfi_adjust_cfa_offset -16
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100340 RESTORE_SAVE_REFS_ONLY_FRAME @ TODO: we can clearly save an add here
Fred Shih37f05ef2014-07-16 18:38:08 -0700341 \return
342END \name
343.endm
344
Ian Rogers57b86d42012-03-27 16:05:41 -0700345 /*
346 * Called by managed code, saves callee saves and then calls artThrowException
347 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception.
348 */
Ian Rogers468532e2013-08-05 10:56:33 -0700349ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode
Ian Rogers932746a2011-09-22 18:57:50 -0700350
Ian Rogers57b86d42012-03-27 16:05:41 -0700351 /*
352 * Called by managed code to create and deliver a NullPointerException.
353 */
Ian Rogers468532e2013-08-05 10:56:33 -0700354NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700355
Ian Rogers57b86d42012-03-27 16:05:41 -0700356 /*
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100357 * Call installed by a signal handler to create and deliver a NullPointerException.
358 */
359ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_signal, artThrowNullPointerExceptionFromSignal
360
361 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700362 * Called by managed code to create and deliver an ArithmeticException.
363 */
Ian Rogers468532e2013-08-05 10:56:33 -0700364NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700365
Ian Rogers57b86d42012-03-27 16:05:41 -0700366 /*
367 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds
368 * index, arg2 holds limit.
369 */
Ian Rogers468532e2013-08-05 10:56:33 -0700370TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode
Ian Rogers57b86d42012-03-27 16:05:41 -0700371
372 /*
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100373 * Called by managed code to create and deliver a StringIndexOutOfBoundsException
374 * as if thrown from a call to String.charAt(). Arg1 holds index, arg2 holds limit.
375 */
376TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_string_bounds, artThrowStringBoundsFromCode
377
378 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700379 * Called by managed code to create and deliver a StackOverflowError.
380 */
Ian Rogers468532e2013-08-05 10:56:33 -0700381NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode
Ian Rogers57b86d42012-03-27 16:05:41 -0700382
383 /*
384 * Called by managed code to create and deliver a NoSuchMethodError.
385 */
Ian Rogers468532e2013-08-05 10:56:33 -0700386ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode
Ian Rogers57b86d42012-03-27 16:05:41 -0700387
388 /*
Ian Rogersc8b306f2012-02-17 21:34:44 -0800389 * All generated callsites for interface invokes and invocation slow paths will load arguments
390 * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100391 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
Elliott Hughes634eb2e2012-03-22 16:06:28 -0700392 * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700393 *
Ian Rogersc8b306f2012-02-17 21:34:44 -0800394 * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting
395 * of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700396 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700397 * If unsuccessful, the helper will return null/null. There will bea pending exception in the
Ian Rogersc8b306f2012-02-17 21:34:44 -0800398 * thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700399 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700400 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
401 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700402 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700403.macro INVOKE_TRAMPOLINE_BODY cxx_name
Ian Rogersc8b306f2012-02-17 21:34:44 -0800404 .extern \cxx_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100405 SETUP_SAVE_REFS_AND_ARGS_FRAME r2 @ save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100406 mov r2, r9 @ pass Thread::Current
407 mov r3, sp
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700408 bl \cxx_name @ (method_idx, this, Thread*, SP)
Elliott Hughes634eb2e2012-03-22 16:06:28 -0700409 mov r12, r1 @ save Method*->code_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100410 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers637859c2013-08-27 14:35:54 -0700411 cbz r0, 1f @ did we find the target? if not go to exception delivery
412 bx r12 @ tail call to target
4131:
Ian Rogersa32a6fd2012-02-06 20:18:44 -0800414 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700415.endm
416.macro INVOKE_TRAMPOLINE c_name, cxx_name
417ENTRY \c_name
418 INVOKE_TRAMPOLINE_BODY \cxx_name
Ian Rogers9329bbb2013-02-08 19:56:30 -0800419END \c_name
Ian Rogersc8b306f2012-02-17 21:34:44 -0800420.endm
Ian Rogersa32a6fd2012-02-06 20:18:44 -0800421
Logan Chien8dbb7082013-01-25 20:31:17 +0800422INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
Ian Rogersa32a6fd2012-02-06 20:18:44 -0800423
Logan Chien8dbb7082013-01-25 20:31:17 +0800424INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
425INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
426INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
427INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
Ian Rogersff1ed472011-09-20 13:46:24 -0700428
Ian Rogers57b86d42012-03-27 16:05:41 -0700429 /*
Zheng Xu5667fdb2014-10-23 18:29:55 +0800430 * Quick invocation stub internal.
Jeff Hao6474d192013-03-26 14:08:09 -0700431 * On entry:
432 * r0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700433 * r1 = argument array or null for no argument methods
Jeff Hao6474d192013-03-26 14:08:09 -0700434 * r2 = size of argument array in bytes
435 * r3 = (managed) thread pointer
436 * [sp] = JValue* result
Zheng Xu5667fdb2014-10-23 18:29:55 +0800437 * [sp + 4] = result_in_float
438 * [sp + 8] = core register argument array
439 * [sp + 12] = fp register argument array
440 * +-------------------------+
441 * | uint32_t* fp_reg_args |
442 * | uint32_t* core_reg_args |
443 * | result_in_float | <- Caller frame
444 * | Jvalue* result |
445 * +-------------------------+
446 * | lr |
447 * | r11 |
448 * | r9 |
449 * | r4 | <- r11
450 * +-------------------------+
451 * | uint32_t out[n-1] |
452 * | : : | Outs
453 * | uint32_t out[0] |
454 * | StackRef<ArtMethod> | <- SP value=null
455 * +-------------------------+
Jeff Hao5d917302013-02-27 17:57:33 -0800456 */
Zheng Xu5667fdb2014-10-23 18:29:55 +0800457ENTRY art_quick_invoke_stub_internal
Andreas Gampe76914b02015-07-17 20:14:50 -0700458 SPILL_ALL_CALLEE_SAVE_GPRS @ spill regs (9)
Jeff Hao5d917302013-02-27 17:57:33 -0800459 mov r11, sp @ save the stack pointer
460 .cfi_def_cfa_register r11
Zheng Xu5667fdb2014-10-23 18:29:55 +0800461
Jeff Hao5d917302013-02-27 17:57:33 -0800462 mov r9, r3 @ move managed thread pointer into r9
Zheng Xu5667fdb2014-10-23 18:29:55 +0800463
464 add r4, r2, #4 @ create space for method pointer in frame
465 sub r4, sp, r4 @ reserve & align *stack* to 16 bytes: native calling
466 and r4, #0xFFFFFFF0 @ convention only aligns to 8B, so we have to ensure ART
467 mov sp, r4 @ 16B alignment ourselves.
468
469 mov r4, r0 @ save method*
470 add r0, sp, #4 @ pass stack pointer + method ptr as dest for memcpy
471 bl memcpy @ memcpy (dest, src, bytes)
472 mov ip, #0 @ set ip to 0
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700473 str ip, [sp] @ store null for method* at bottom of frame
Zheng Xu5667fdb2014-10-23 18:29:55 +0800474
Nicolas Geoffray48088462014-12-12 10:29:38 +0000475 ldr ip, [r11, #48] @ load fp register argument array pointer
Zheng Xu5667fdb2014-10-23 18:29:55 +0800476 vldm ip, {s0-s15} @ copy s0 - s15
477
Nicolas Geoffray48088462014-12-12 10:29:38 +0000478 ldr ip, [r11, #44] @ load core register argument array pointer
Zheng Xu5667fdb2014-10-23 18:29:55 +0800479 mov r0, r4 @ restore method*
480 add ip, ip, #4 @ skip r0
481 ldm ip, {r1-r3} @ copy r1 - r3
482
Wei Jin04f4d8a2014-05-29 18:04:29 -0700483#ifdef ARM_R4_SUSPEND_FLAG
Jeff Hao5d917302013-02-27 17:57:33 -0800484 mov r4, #SUSPEND_CHECK_INTERVAL @ reset r4 to suspend check interval
Wei Jin04f4d8a2014-05-29 18:04:29 -0700485#endif
Andreas Gampe6e498692014-08-18 16:43:12 -0700486
Mathieu Chartiere401d142015-04-22 13:56:20 -0700487 ldr ip, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] @ get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800488 blx ip @ call the method
Zheng Xu5667fdb2014-10-23 18:29:55 +0800489
Jeff Hao6474d192013-03-26 14:08:09 -0700490 mov sp, r11 @ restore the stack pointer
Zheng Xu5667fdb2014-10-23 18:29:55 +0800491 .cfi_def_cfa_register sp
492
Nicolas Geoffray48088462014-12-12 10:29:38 +0000493 ldr r4, [sp, #40] @ load result_is_float
494 ldr r9, [sp, #36] @ load the result pointer
Zheng Xu5667fdb2014-10-23 18:29:55 +0800495 cmp r4, #0
496 ite eq
497 strdeq r0, [r9] @ store r0/r1 into result pointer
498 vstrne d0, [r9] @ store s0-s1/d0 into result pointer
499
Nicolas Geoffray48088462014-12-12 10:29:38 +0000500 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} @ restore spill regs
Zheng Xu5667fdb2014-10-23 18:29:55 +0800501END art_quick_invoke_stub_internal
Jeff Hao6474d192013-03-26 14:08:09 -0700502
Jeff Hao5d917302013-02-27 17:57:33 -0800503 /*
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000504 * On stack replacement stub.
505 * On entry:
506 * r0 = stack to copy
507 * r1 = size of stack
508 * r2 = pc to call
509 * r3 = JValue* result
510 * [sp] = shorty
511 * [sp + 4] = thread
512 */
513ENTRY art_quick_osr_stub
514 SPILL_ALL_CALLEE_SAVE_GPRS @ Spill regs (9)
515 mov r11, sp @ Save the stack pointer
516 mov r10, r1 @ Save size of stack
517 ldr r9, [r11, #40] @ Move managed thread pointer into r9
518 mov r8, r2 @ Save the pc to call
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000519 sub r7, sp, #12 @ Reserve space for stack pointer,
520 @ JValue* result, and ArtMethod* slot.
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000521 and r7, #0xFFFFFFF0 @ Align stack pointer
522 mov sp, r7 @ Update stack pointer
523 str r11, [sp, #4] @ Save old stack pointer
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000524 str r3, [sp, #8] @ Save JValue* result
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000525 mov ip, #0
526 str ip, [sp] @ Store null for ArtMethod* at bottom of frame
527 sub sp, sp, r1 @ Reserve space for callee stack
528 mov r2, r1
529 mov r1, r0
530 mov r0, sp
531 bl memcpy @ memcpy (dest r0, src r1, bytes r2)
532 bl .Losr_entry @ Call the method
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000533 ldr r10, [sp, #8] @ Restore JValue* result
534 ldr sp, [sp, #4] @ Restore saved stack pointer
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000535 ldr r4, [sp, #36] @ load shorty
Nicolas Geoffrayd9bc4332016-02-05 23:32:25 +0000536 ldrb r4, [r4, #0] @ load return type
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000537 cmp r4, #68 @ Test if result type char == 'D'.
538 beq .Losr_fp_result
539 cmp r4, #70 @ Test if result type char == 'F'.
540 beq .Losr_fp_result
541 strd r0, [r10] @ Store r0/r1 into result pointer
542 b .Losr_exit
543.Losr_fp_result:
544 vstr d0, [r10] @ Store s0-s1/d0 into result pointer
545.Losr_exit:
546 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc}
547.Losr_entry:
548 sub r10, r10, #4
549 str lr, [sp, r10] @ Store link register per the compiler ABI
550 bx r8
551END art_quick_osr_stub
552
553 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700554 * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_
555 */
Ian Rogers637859c2013-08-27 14:35:54 -0700556ARM_ENTRY art_quick_do_long_jump
Ian Rogers57b86d42012-03-27 16:05:41 -0700557 vldm r1, {s0-s31} @ load all fprs from argument fprs_
558 ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15)
Jeff Hao467f8162014-08-05 18:59:16 -0700559 ldr r14, [r0, #56] @ (LR from gprs_ 56=4*14)
Ian Rogers57b86d42012-03-27 16:05:41 -0700560 add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3
Jeff Hao467f8162014-08-05 18:59:16 -0700561 ldm r0, {r3-r13} @ load remaining gprs from argument gprs_
Andreas Gampe639bdd12015-06-03 11:22:45 -0700562 ldr r0, [r0, #-12] @ load r0 value
563 mov r1, #0 @ clear result register r1
Ian Rogers57b86d42012-03-27 16:05:41 -0700564 bx r2 @ do long jump
Ian Rogers9329bbb2013-02-08 19:56:30 -0800565END art_quick_do_long_jump
Ian Rogers57b86d42012-03-27 16:05:41 -0700566
Ian Rogers60db5ab2012-02-20 17:02:00 -0800567 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700568 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
569 * failure.
570 */
Ian Rogers832336b2014-10-08 15:35:22 -0700571TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700572
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700573 /*
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700574 * Entry from managed code that calls artLockObjectFromCode, may block for GC. r0 holds the
575 * possibly null object to lock.
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700576 */
Ian Rogers9329bbb2013-02-08 19:56:30 -0800577 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700578ENTRY art_quick_lock_object
Ian Rogers5d885c82014-02-21 20:06:23 -0800579 cbz r0, .Lslow_lock
580.Lretry_lock:
Mathieu Chartier4e6a31e2013-10-31 10:35:05 -0700581 ldr r2, [r9, #THREAD_ID_OFFSET]
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700582 ldrex r1, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800583 mov r3, r1
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700584 and r3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED @ zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800585 cbnz r3, .Lnot_unlocked @ already thin locked
586 @ unlocked case - r1: original lock word that's zero except for the read barrier bits.
587 orr r2, r1, r2 @ r2 holds thread id with count of 0 with preserved read barrier bits
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700588 strex r3, r2, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800589 cbnz r3, .Llock_strex_fail @ store failed, retry
Andreas Gampe675967d2014-05-14 16:28:34 -0700590 dmb ish @ full (LoadLoad|LoadStore) memory barrier
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700591 bx lr
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800592.Lnot_unlocked: @ r1: original lock word, r2: thread_id with count of 0 and zero read barrier bits
593 lsr r3, r1, LOCK_WORD_STATE_SHIFT
Ian Rogers5d885c82014-02-21 20:06:23 -0800594 cbnz r3, .Lslow_lock @ if either of the top two bits are set, go slow path
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700595 eor r2, r1, r2 @ lock_word.ThreadId() ^ self->ThreadId()
596 uxth r2, r2 @ zero top 16 bits
Ian Rogers5d885c82014-02-21 20:06:23 -0800597 cbnz r2, .Lslow_lock @ lock word and self thread id's match -> recursive lock
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700598 @ else contention, go to slow path
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800599 mov r3, r1 @ copy the lock word to check count overflow.
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700600 and r3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED @ zero the gc bits.
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800601 add r2, r3, #LOCK_WORD_THIN_LOCK_COUNT_ONE @ increment count in lock word placing in r2 to check overflow
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700602 lsr r3, r2, #LOCK_WORD_GC_STATE_SHIFT @ if the first gc state bit is set, we overflowed.
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800603 cbnz r3, .Lslow_lock @ if we overflow the count go slow path
604 add r2, r1, #LOCK_WORD_THIN_LOCK_COUNT_ONE @ increment count for real
605 strex r3, r2, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET] @ strex necessary for read barrier bits
606 cbnz r3, .Llock_strex_fail @ strex failed, retry
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700607 bx lr
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800608.Llock_strex_fail:
609 b .Lretry_lock @ retry
Ian Rogers5d885c82014-02-21 20:06:23 -0800610.Lslow_lock:
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100611 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves in case we block
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700612 mov r1, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700613 bl artLockObjectFromCode @ (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100614 RESTORE_SAVE_REFS_ONLY_FRAME
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700615 RETURN_IF_RESULT_IS_ZERO
616 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700617END art_quick_lock_object
Ian Rogersff1ed472011-09-20 13:46:24 -0700618
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700619ENTRY art_quick_lock_object_no_inline
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100620 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves in case we block
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700621 mov r1, r9 @ pass Thread::Current
622 bl artLockObjectFromCode @ (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100623 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700624 RETURN_IF_RESULT_IS_ZERO
625 DELIVER_PENDING_EXCEPTION
626END art_quick_lock_object_no_inline
627
Ian Rogersff1ed472011-09-20 13:46:24 -0700628 /*
629 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700630 * r0 holds the possibly null object to lock.
Ian Rogersff1ed472011-09-20 13:46:24 -0700631 */
Ian Rogers9329bbb2013-02-08 19:56:30 -0800632 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700633ENTRY art_quick_unlock_object
Ian Rogers5d885c82014-02-21 20:06:23 -0800634 cbz r0, .Lslow_unlock
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800635.Lretry_unlock:
636#ifndef USE_READ_BARRIER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700637 ldr r1, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800638#else
639 ldrex r1, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET] @ Need to use atomic instructions for read barrier
640#endif
641 lsr r2, r1, #LOCK_WORD_STATE_SHIFT
Ian Rogers5d885c82014-02-21 20:06:23 -0800642 cbnz r2, .Lslow_unlock @ if either of the top two bits are set, go slow path
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700643 ldr r2, [r9, #THREAD_ID_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800644 mov r3, r1 @ copy lock word to check thread id equality
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700645 and r3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED @ zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800646 eor r3, r3, r2 @ lock_word.ThreadId() ^ self->ThreadId()
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700647 uxth r3, r3 @ zero top 16 bits
Ian Rogers5d885c82014-02-21 20:06:23 -0800648 cbnz r3, .Lslow_unlock @ do lock word and self thread id's match?
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800649 mov r3, r1 @ copy lock word to detect transition to unlocked
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700650 and r3, #LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED @ zero the gc bits
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800651 cmp r3, #LOCK_WORD_THIN_LOCK_COUNT_ONE
Ian Rogers5d885c82014-02-21 20:06:23 -0800652 bpl .Lrecursive_thin_unlock
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800653 @ transition to unlocked
654 mov r3, r1
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700655 and r3, #LOCK_WORD_GC_STATE_MASK_SHIFTED @ r3: zero except for the preserved gc bits
Andreas Gampe675967d2014-05-14 16:28:34 -0700656 dmb ish @ full (LoadStore|StoreStore) memory barrier
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800657#ifndef USE_READ_BARRIER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700658 str r3, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800659#else
660 strex r2, r3, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET] @ strex necessary for read barrier bits
661 cbnz r2, .Lunlock_strex_fail @ store failed, retry
662#endif
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700663 bx lr
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800664.Lrecursive_thin_unlock: @ r1: original lock word
665 sub r1, r1, #LOCK_WORD_THIN_LOCK_COUNT_ONE @ decrement count
666#ifndef USE_READ_BARRIER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700667 str r1, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800668#else
669 strex r2, r1, [r0, #MIRROR_OBJECT_LOCK_WORD_OFFSET] @ strex necessary for read barrier bits
670 cbnz r2, .Lunlock_strex_fail @ store failed, retry
671#endif
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700672 bx lr
Hiroshi Yamauchie15ea082015-02-09 17:11:42 -0800673.Lunlock_strex_fail:
674 b .Lretry_unlock @ retry
Ian Rogers5d885c82014-02-21 20:06:23 -0800675.Lslow_unlock:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700676 @ save callee saves in case exception allocation triggers GC
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100677 SETUP_SAVE_REFS_ONLY_FRAME r1
Ian Rogers637859c2013-08-27 14:35:54 -0700678 mov r1, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700679 bl artUnlockObjectFromCode @ (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100680 RESTORE_SAVE_REFS_ONLY_FRAME
Ian Rogers637859c2013-08-27 14:35:54 -0700681 RETURN_IF_RESULT_IS_ZERO
Ian Rogersce9eca62011-10-07 17:11:03 -0700682 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700683END art_quick_unlock_object
Ian Rogersff1ed472011-09-20 13:46:24 -0700684
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700685ENTRY art_quick_unlock_object_no_inline
686 @ save callee saves in case exception allocation triggers GC
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100687 SETUP_SAVE_REFS_ONLY_FRAME r1
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700688 mov r1, r9 @ pass Thread::Current
689 bl artUnlockObjectFromCode @ (Object* obj, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100690 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700691 RETURN_IF_RESULT_IS_ZERO
692 DELIVER_PENDING_EXCEPTION
693END art_quick_unlock_object_no_inline
694
Ian Rogersff1ed472011-09-20 13:46:24 -0700695 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700696 * Entry from managed code that calls artIsAssignableFromCode and on failure calls
697 * artThrowClassCastException.
Ian Rogersff1ed472011-09-20 13:46:24 -0700698 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700699 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700700ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700701 push {r0-r1, lr} @ save arguments, link register and pad
Ian Rogersa9a82542013-10-04 11:17:26 -0700702 .cfi_adjust_cfa_offset 12
703 .cfi_rel_offset r0, 0
704 .cfi_rel_offset r1, 4
705 .cfi_rel_offset lr, 8
706 sub sp, #4
Ian Rogersa9a82542013-10-04 11:17:26 -0700707 .cfi_adjust_cfa_offset 4
708 bl artIsAssignableFromCode
Ian Rogers5d885c82014-02-21 20:06:23 -0800709 cbz r0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700710 add sp, #4
711 .cfi_adjust_cfa_offset -4
712 pop {r0-r1, pc}
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700713 .cfi_adjust_cfa_offset 4 @ Reset unwind info so following code unwinds.
Ian Rogers5d885c82014-02-21 20:06:23 -0800714.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700715 add sp, #4
716 .cfi_adjust_cfa_offset -4
717 pop {r0-r1, lr}
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700718 .cfi_adjust_cfa_offset -12
Dave Allisonbbb32c22013-11-05 18:25:18 -0800719 .cfi_restore r0
720 .cfi_restore r1
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700721 .cfi_restore lr
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100722 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r2 @ save all registers as basis for long jump context
Ian Rogersa9a82542013-10-04 11:17:26 -0700723 mov r2, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700724 b artThrowClassCastException @ (Class*, Class*, Thread*)
Ian Rogersa9a82542013-10-04 11:17:26 -0700725 bkpt
Ian Rogers468532e2013-08-05 10:56:33 -0700726END art_quick_check_cast
buzbee4a3164f2011-09-03 11:25:10 -0700727
Man Cao1aee9002015-07-14 22:31:42 -0700728// Restore rReg's value from [sp, #offset] if rReg is not the same as rExclude.
729.macro POP_REG_NE rReg, offset, rExclude
730 .ifnc \rReg, \rExclude
731 ldr \rReg, [sp, #\offset] @ restore rReg
732 .cfi_restore \rReg
733 .endif
734.endm
735
Roland Levillain4359e612016-07-20 11:32:19 +0100736// Save rReg's value to [sp, #offset].
737.macro PUSH_REG rReg, offset
738 str \rReg, [sp, #\offset] @ save rReg
739 .cfi_rel_offset \rReg, \offset
740.endm
741
Man Cao1aee9002015-07-14 22:31:42 -0700742 /*
743 * Macro to insert read barrier, only used in art_quick_aput_obj.
744 * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
745 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
746 */
747.macro READ_BARRIER rDest, rObj, offset
748#ifdef USE_READ_BARRIER
749 push {r0-r3, ip, lr} @ 6 words for saved registers (used in art_quick_aput_obj)
750 .cfi_adjust_cfa_offset 24
751 .cfi_rel_offset r0, 0
752 .cfi_rel_offset r1, 4
753 .cfi_rel_offset r2, 8
754 .cfi_rel_offset r3, 12
755 .cfi_rel_offset ip, 16
756 .cfi_rel_offset lr, 20
757 sub sp, #8 @ push padding
758 .cfi_adjust_cfa_offset 8
Man Cao63069212015-08-21 15:51:39 -0700759 @ mov r0, \rRef @ pass ref in r0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -0700760 .ifnc \rObj, r1
761 mov r1, \rObj @ pass rObj
762 .endif
763 mov r2, #\offset @ pass offset
764 bl artReadBarrierSlow @ artReadBarrierSlow(ref, rObj, offset)
765 @ No need to unpoison return value in r0, artReadBarrierSlow() would do the unpoisoning.
766 .ifnc \rDest, r0
767 mov \rDest, r0 @ save return value in rDest
768 .endif
769 add sp, #8 @ pop padding
770 .cfi_adjust_cfa_offset -8
771 POP_REG_NE r0, 0, \rDest @ conditionally restore saved registers
772 POP_REG_NE r1, 4, \rDest
773 POP_REG_NE r2, 8, \rDest
774 POP_REG_NE r3, 12, \rDest
775 POP_REG_NE ip, 16, \rDest
776 add sp, #20
777 .cfi_adjust_cfa_offset -20
778 pop {lr} @ restore lr
779 .cfi_adjust_cfa_offset -4
780 .cfi_restore lr
781#else
782 ldr \rDest, [\rObj, #\offset]
783 UNPOISON_HEAP_REF \rDest
784#endif // USE_READ_BARRIER
785.endm
786
Ian Rogerse51a5112011-09-23 14:16:35 -0700787 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700788 * Entry from managed code for array put operations of objects where the value being stored
789 * needs to be checked for compatibility.
790 * r0 = array, r1 = index, r2 = value
Ian Rogerse51a5112011-09-23 14:16:35 -0700791 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700792ENTRY art_quick_aput_obj_with_null_and_bound_check
793 tst r0, r0
Dan Albertd8426482014-08-07 17:40:03 -0700794 bne art_quick_aput_obj_with_bound_check
Ian Rogersa9a82542013-10-04 11:17:26 -0700795 b art_quick_throw_null_pointer_exception
796END art_quick_aput_obj_with_null_and_bound_check
797
Dan Albert58bea4a2014-08-09 18:08:07 -0700798 .hidden art_quick_aput_obj_with_bound_check
Ian Rogersa9a82542013-10-04 11:17:26 -0700799ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700800 ldr r3, [r0, #MIRROR_ARRAY_LENGTH_OFFSET]
Ian Rogersa9a82542013-10-04 11:17:26 -0700801 cmp r3, r1
Dan Albertd8426482014-08-07 17:40:03 -0700802 bhi art_quick_aput_obj
Ian Rogersa9a82542013-10-04 11:17:26 -0700803 mov r0, r1
804 mov r1, r3
805 b art_quick_throw_array_bounds
806END art_quick_aput_obj_with_bound_check
807
Man Cao1aee9002015-07-14 22:31:42 -0700808#ifdef USE_READ_BARRIER
809 .extern artReadBarrierSlow
810#endif
Dan Albert58bea4a2014-08-09 18:08:07 -0700811 .hidden art_quick_aput_obj
Ian Rogersa9a82542013-10-04 11:17:26 -0700812ENTRY art_quick_aput_obj
Man Cao1aee9002015-07-14 22:31:42 -0700813#ifdef USE_READ_BARRIER
814 @ The offset to .Ldo_aput_null is too large to use cbz due to expansion from READ_BARRIER macro.
815 tst r2, r2
816 beq .Ldo_aput_null
817#else
Ian Rogers5d885c82014-02-21 20:06:23 -0800818 cbz r2, .Ldo_aput_null
Man Cao1aee9002015-07-14 22:31:42 -0700819#endif // USE_READ_BARRIER
820 READ_BARRIER r3, r0, MIRROR_OBJECT_CLASS_OFFSET
821 READ_BARRIER ip, r2, MIRROR_OBJECT_CLASS_OFFSET
822 READ_BARRIER r3, r3, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogersa9a82542013-10-04 11:17:26 -0700823 cmp r3, ip @ value's type == array's component type - trivial assignability
Ian Rogers5d885c82014-02-21 20:06:23 -0800824 bne .Lcheck_assignability
825.Ldo_aput:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700826 add r3, r0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700827 POISON_HEAP_REF r2
Ian Rogersa9a82542013-10-04 11:17:26 -0700828 str r2, [r3, r1, lsl #2]
829 ldr r3, [r9, #THREAD_CARD_TABLE_OFFSET]
830 lsr r0, r0, #7
831 strb r3, [r3, r0]
832 blx lr
Ian Rogers5d885c82014-02-21 20:06:23 -0800833.Ldo_aput_null:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700834 add r3, r0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Ian Rogersa9a82542013-10-04 11:17:26 -0700835 str r2, [r3, r1, lsl #2]
836 blx lr
Ian Rogers5d885c82014-02-21 20:06:23 -0800837.Lcheck_assignability:
838 push {r0-r2, lr} @ save arguments
Andreas Gampe525cde22014-04-22 15:44:50 -0700839 .cfi_adjust_cfa_offset 16
840 .cfi_rel_offset r0, 0
841 .cfi_rel_offset r1, 4
842 .cfi_rel_offset r2, 8
843 .cfi_rel_offset lr, 12
Ian Rogersa9a82542013-10-04 11:17:26 -0700844 mov r1, ip
845 mov r0, r3
846 bl artIsAssignableFromCode
Ian Rogers5d885c82014-02-21 20:06:23 -0800847 cbz r0, .Lthrow_array_store_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700848 pop {r0-r2, lr}
Andreas Gampe525cde22014-04-22 15:44:50 -0700849 .cfi_restore r0
850 .cfi_restore r1
851 .cfi_restore r2
852 .cfi_restore lr
853 .cfi_adjust_cfa_offset -16
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700854 add r3, r0, #MIRROR_OBJECT_ARRAY_DATA_OFFSET
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700855 POISON_HEAP_REF r2
Ian Rogersa9a82542013-10-04 11:17:26 -0700856 str r2, [r3, r1, lsl #2]
857 ldr r3, [r9, #THREAD_CARD_TABLE_OFFSET]
858 lsr r0, r0, #7
859 strb r3, [r3, r0]
860 blx lr
Ian Rogers5d885c82014-02-21 20:06:23 -0800861.Lthrow_array_store_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700862 pop {r0-r2, lr}
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -0700863 /* No need to repeat restore cfi directives, the ones above apply here. */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100864 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r3
Ian Rogersa9a82542013-10-04 11:17:26 -0700865 mov r1, r2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700866 mov r2, r9 @ pass Thread::Current
867 b artThrowArrayStoreException @ (Class*, Class*, Thread*)
868 bkpt @ unreached
Ian Rogersa9a82542013-10-04 11:17:26 -0700869END art_quick_aput_obj
Ian Rogerse51a5112011-09-23 14:16:35 -0700870
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800871// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +0100872.macro ONE_ARG_DOWNCALL name, entrypoint, return
873 .extern \entrypoint
874ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100875 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves in case of GC
Vladimir Marko5ea536a2015-04-20 20:11:30 +0100876 mov r1, r9 @ pass Thread::Current
877 bl \entrypoint @ (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100878 RESTORE_SAVE_REFS_ONLY_FRAME
Vladimir Marko5ea536a2015-04-20 20:11:30 +0100879 \return
880END \name
881.endm
882
883// Macro to facilitate adding new allocation entrypoints.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800884.macro TWO_ARG_DOWNCALL name, entrypoint, return
885 .extern \entrypoint
886ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100887 SETUP_SAVE_REFS_ONLY_FRAME r2 @ save callee saves in case of GC
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800888 mov r2, r9 @ pass Thread::Current
889 bl \entrypoint @ (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100890 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800891 \return
892END \name
893.endm
Ian Rogersce9eca62011-10-07 17:11:03 -0700894
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800895// Macro to facilitate adding new array allocation entrypoints.
896.macro THREE_ARG_DOWNCALL name, entrypoint, return
897 .extern \entrypoint
898ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100899 SETUP_SAVE_REFS_ONLY_FRAME r3 @ save callee saves in case of GC
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800900 mov r3, r9 @ pass Thread::Current
901 @ (uint32_t type_idx, Method* method, int32_t component_count, Thread*)
902 bl \entrypoint
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100903 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800904 \return
905END \name
906.endm
Ian Rogers28ad40d2011-10-27 15:19:26 -0700907
Jeff Hao848f70a2014-01-15 13:49:50 -0800908// Macro to facilitate adding new allocation entrypoints.
909.macro FOUR_ARG_DOWNCALL name, entrypoint, return
910 .extern \entrypoint
911ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100912 SETUP_SAVE_REFS_ONLY_FRAME r12 @ save callee saves in case of GC
Jeff Hao848f70a2014-01-15 13:49:50 -0800913 str r9, [sp, #-16]! @ expand the frame and pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -0800914 .cfi_adjust_cfa_offset 16
915 bl \entrypoint
916 add sp, #16 @ strip the extra frame
917 .cfi_adjust_cfa_offset -16
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100918 RESTORE_SAVE_REFS_ONLY_FRAME
Jeff Hao848f70a2014-01-15 13:49:50 -0800919 \return
920END \name
921.endm
922
Vladimir Marko5ea536a2015-04-20 20:11:30 +0100923ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
924ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
925ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Ian Rogersb093c6b2011-10-31 16:19:55 -0700926
Ian Rogersce9eca62011-10-07 17:11:03 -0700927 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700928 * Called by managed code to resolve a static field and load a non-wide value.
Ian Rogersce9eca62011-10-07 17:11:03 -0700929 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700930ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
931ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
932ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
933ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
934ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
935ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
Ian Rogersce9eca62011-10-07 17:11:03 -0700936 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700937 * Called by managed code to resolve a static field and load a 64-bit primitive value.
Ian Rogersce9eca62011-10-07 17:11:03 -0700938 */
Ian Rogers9329bbb2013-02-08 19:56:30 -0800939 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700940ENTRY art_quick_get64_static
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100941 SETUP_SAVE_REFS_ONLY_FRAME r2 @ save callee saves in case of GC
942 ldr r1, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Ian Rogersce9eca62011-10-07 17:11:03 -0700943 mov r2, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700944 bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*)
Ian Rogers637859c2013-08-27 14:35:54 -0700945 ldr r2, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100946 RESTORE_SAVE_REFS_ONLY_FRAME
Ian Rogers637859c2013-08-27 14:35:54 -0700947 cbnz r2, 1f @ success if no exception pending
948 bx lr @ return on success
9491:
Ian Rogersce9eca62011-10-07 17:11:03 -0700950 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700951END art_quick_get64_static
Ian Rogersce9eca62011-10-07 17:11:03 -0700952
Ian Rogersce9eca62011-10-07 17:11:03 -0700953 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700954 * Called by managed code to resolve an instance field and load a non-wide value.
Ian Rogersce9eca62011-10-07 17:11:03 -0700955 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700956TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
957TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
958TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
959TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
960TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
961TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
Ian Rogers1bddec32012-02-04 12:27:34 -0800962 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700963 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
Ian Rogers1bddec32012-02-04 12:27:34 -0800964 */
Ian Rogers9329bbb2013-02-08 19:56:30 -0800965 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700966ENTRY art_quick_get64_instance
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100967 SETUP_SAVE_REFS_ONLY_FRAME r2 @ save callee saves in case of GC
968 ldr r2, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Ian Rogers1bddec32012-02-04 12:27:34 -0800969 mov r3, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700970 bl artGet64InstanceFromCode @ (field_idx, Object*, referrer, Thread*)
Ian Rogers637859c2013-08-27 14:35:54 -0700971 ldr r2, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100972 RESTORE_SAVE_REFS_ONLY_FRAME
Ian Rogers637859c2013-08-27 14:35:54 -0700973 cbnz r2, 1f @ success if no exception pending
974 bx lr @ return on success
9751:
Ian Rogers1bddec32012-02-04 12:27:34 -0800976 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700977END art_quick_get64_instance
Ian Rogers1bddec32012-02-04 12:27:34 -0800978
Ian Rogers1bddec32012-02-04 12:27:34 -0800979 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700980 * Called by managed code to resolve a static field and store a non-wide value.
Ian Rogers1bddec32012-02-04 12:27:34 -0800981 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700982TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
983TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
984TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
985TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
Ian Rogersce9eca62011-10-07 17:11:03 -0700986 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700987 * Called by managed code to resolve a static field and store a 64-bit primitive value.
Calin Juravlee460d1d2015-09-29 04:52:17 +0100988 * On entry r0 holds field index, r2:r3 hold new_val
Ian Rogersce9eca62011-10-07 17:11:03 -0700989 */
Ian Rogers9329bbb2013-02-08 19:56:30 -0800990 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700991ENTRY art_quick_set64_static
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100992 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves in case of GC
Calin Juravlee460d1d2015-09-29 04:52:17 +0100993 @ r2:r3 contain the wide argument
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100994 ldr r1, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700995 str r9, [sp, #-16]! @ expand the frame and pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700996 .cfi_adjust_cfa_offset 16
997 bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*)
Ian Rogersce9eca62011-10-07 17:11:03 -0700998 add sp, #16 @ release out args
Dave Allisonbbb32c22013-11-05 18:25:18 -0800999 .cfi_adjust_cfa_offset -16
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001000 RESTORE_SAVE_REFS_ONLY_FRAME @ TODO: we can clearly save an add here
Ian Rogers637859c2013-08-27 14:35:54 -07001001 RETURN_IF_RESULT_IS_ZERO
Ian Rogersce9eca62011-10-07 17:11:03 -07001002 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001003END art_quick_set64_static
Ian Rogersce9eca62011-10-07 17:11:03 -07001004
Ian Rogersce9eca62011-10-07 17:11:03 -07001005 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001006 * Called by managed code to resolve an instance field and store a non-wide value.
Ian Rogersce9eca62011-10-07 17:11:03 -07001007 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001008THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
1009THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
1010THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
1011THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_RESULT_IS_ZERO_OR_DELIVER
Ian Rogers1bddec32012-02-04 12:27:34 -08001012 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001013 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
Ian Rogers1bddec32012-02-04 12:27:34 -08001014 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001015 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001016ENTRY art_quick_set64_instance
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001017 SETUP_SAVE_REFS_ONLY_FRAME r12 @ save callee saves in case of GC
Calin Juravlee460d1d2015-09-29 04:52:17 +01001018 @ r2:r3 contain the wide argument
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001019 ldr r12, [sp, #FRAME_SIZE_SAVE_REFS_ONLY] @ pass referrer
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001020 str r9, [sp, #-12]! @ expand the frame and pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001021 .cfi_adjust_cfa_offset 12
1022 str r12, [sp, #-4]! @ expand the frame and pass the referrer
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001023 .cfi_adjust_cfa_offset 4
1024 bl artSet64InstanceFromCode @ (field_idx, Object*, new_val, Method* referrer, Thread*)
Ian Rogers1bddec32012-02-04 12:27:34 -08001025 add sp, #16 @ release out args
Ian Rogers9329bbb2013-02-08 19:56:30 -08001026 .cfi_adjust_cfa_offset -16
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001027 RESTORE_SAVE_REFS_ONLY_FRAME @ TODO: we can clearly save an add here
Ian Rogers637859c2013-08-27 14:35:54 -07001028 RETURN_IF_RESULT_IS_ZERO
Ian Rogers1bddec32012-02-04 12:27:34 -08001029 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001030END art_quick_set64_instance
Ian Rogers1bddec32012-02-04 12:27:34 -08001031
Ian Rogers1bddec32012-02-04 12:27:34 -08001032 /*
Ian Rogerscaab8c42011-10-12 12:11:18 -07001033 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001034 * exception on error. On success the String is returned. R0 holds the string index. The fast
1035 * path check for hit in strings cache has already been performed.
Brian Carlstromaded5f72011-10-07 17:15:04 -07001036 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001037ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Ian Rogersb886da82011-09-23 16:27:54 -07001038
Mathieu Chartier7410f292013-11-24 13:17:35 -08001039// Generate the allocation entrypoints for each allocator.
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001040GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi7e1ce282015-12-11 15:46:19 -08001041
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001042// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1043ENTRY art_quick_alloc_object_rosalloc
1044 // Fast path rosalloc allocation.
1045 // r0: type_idx/return value, r1: ArtMethod*, r9: Thread::Current
1046 // r2, r3, r12: free.
1047 ldr r2, [r1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_32] // Load dex cache resolved types array
1048 // Load the class (r2)
1049 ldr r2, [r2, r0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1050 cbz r2, .Lart_quick_alloc_object_rosalloc_slow_path // Check null class
1051 // Check class status.
1052 ldr r3, [r2, #MIRROR_CLASS_STATUS_OFFSET]
1053 cmp r3, #MIRROR_CLASS_STATUS_INITIALIZED
1054 bne .Lart_quick_alloc_object_rosalloc_slow_path
1055 // Add a fake dependence from the
1056 // following access flag and size
1057 // loads to the status load.
1058 // This is to prevent those loads
1059 // from being reordered above the
1060 // status load and reading wrong
1061 // values (an alternative is to use
1062 // a load-acquire for the status).
1063 eor r3, r3, r3
1064 add r2, r2, r3
1065 // Check access flags has
1066 // kAccClassIsFinalizable
1067 ldr r3, [r2, #MIRROR_CLASS_ACCESS_FLAGS_OFFSET]
1068 tst r3, #ACCESS_FLAGS_CLASS_IS_FINALIZABLE
1069 bne .Lart_quick_alloc_object_rosalloc_slow_path
1070
1071 ldr r3, [r9, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET] // Check if the thread local
1072 // allocation stack has room.
1073 // TODO: consider using ldrd.
1074 ldr r12, [r9, #THREAD_LOCAL_ALLOC_STACK_END_OFFSET]
1075 cmp r3, r12
1076 bhs .Lart_quick_alloc_object_rosalloc_slow_path
1077
1078 ldr r3, [r2, #MIRROR_CLASS_OBJECT_SIZE_OFFSET] // Load the object size (r3)
1079 cmp r3, #ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE // Check if the size is for a thread
1080 // local allocation
1081 bhs .Lart_quick_alloc_object_rosalloc_slow_path
1082 // Compute the rosalloc bracket index
1083 // from the size.
1084 // Align up the size by the rosalloc
1085 // bracket quantum size and divide
1086 // by the quantum size and subtract
1087 // by 1. This code is a shorter but
1088 // equivalent version.
1089 sub r3, r3, #1
1090 lsr r3, r3, #ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT
1091 // Load the rosalloc run (r12)
1092 add r12, r9, r3, lsl #POINTER_SIZE_SHIFT
1093 ldr r12, [r12, #THREAD_ROSALLOC_RUNS_OFFSET]
1094 // Load the free list head (r3). This
1095 // will be the return val.
1096 ldr r3, [r12, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)]
1097 cbz r3, .Lart_quick_alloc_object_rosalloc_slow_path
1098 // "Point of no slow path". Won't go to the slow path from here on. OK to clobber r0 and r1.
1099 ldr r1, [r3, #ROSALLOC_SLOT_NEXT_OFFSET] // Load the next pointer of the head
1100 // and update the list head with the
1101 // next pointer.
1102 str r1, [r12, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)]
1103 // Store the class pointer in the
1104 // header. This also overwrites the
1105 // next pointer. The offsets are
1106 // asserted to match.
1107#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1108#error "Class pointer needs to overwrite next pointer."
1109#endif
1110 POISON_HEAP_REF r2
1111 str r2, [r3, #MIRROR_OBJECT_CLASS_OFFSET]
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001112 // Fence. This is "ish" not "ishst" so
1113 // that it also ensures ordering of
1114 // the class status load with respect
1115 // to later accesses to the class
1116 // object. Alternatively we could use
1117 // "ishst" if we use load-acquire for
1118 // the class status load.)
1119 // Needs to be done before pushing on
1120 // allocation since Heap::VisitObjects
1121 // relies on seeing the class pointer.
1122 // b/28790624
1123 dmb ish
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001124 // Push the new object onto the thread
1125 // local allocation stack and
1126 // increment the thread local
1127 // allocation stack top.
1128 ldr r1, [r9, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET]
1129 str r3, [r1], #COMPRESSED_REFERENCE_SIZE // (Increment r1 as a side effect.)
1130 str r1, [r9, #THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET]
1131 // Decrement the size of the free list
1132 ldr r1, [r12, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)]
1133 sub r1, #1
1134 // TODO: consider combining this store
1135 // and the list head store above using
1136 // strd.
1137 str r1, [r12, #(ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)]
Mathieu Chartier011dc2c2016-07-18 11:11:45 -07001138
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001139 mov r0, r3 // Set the return value and return.
1140 bx lr
1141
1142.Lart_quick_alloc_object_rosalloc_slow_path:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001143 SETUP_SAVE_REFS_ONLY_FRAME r2 @ save callee saves in case of GC
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001144 mov r2, r9 @ pass Thread::Current
1145 bl artAllocObjectFromCodeRosAlloc @ (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001146 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchidc412b62015-10-15 12:26:57 -07001147 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1148END art_quick_alloc_object_rosalloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001149
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001150// The common fast path code for art_quick_alloc_object_tlab and art_quick_alloc_object_region_tlab.
1151//
1152// r0: type_idx/return value, r1: ArtMethod*, r2: class, r9: Thread::Current, r3, r12: free.
1153// Need to preserve r0 and r1 to the slow path.
1154.macro ALLOC_OBJECT_TLAB_FAST_PATH slowPathLabel
1155 cbz r2, \slowPathLabel // Check null class
1156 // Check class status.
1157 ldr r3, [r2, #MIRROR_CLASS_STATUS_OFFSET]
1158 cmp r3, #MIRROR_CLASS_STATUS_INITIALIZED
1159 bne \slowPathLabel
1160 // Add a fake dependence from the
1161 // following access flag and size
1162 // loads to the status load.
1163 // This is to prevent those loads
1164 // from being reordered above the
1165 // status load and reading wrong
1166 // values (an alternative is to use
1167 // a load-acquire for the status).
1168 eor r3, r3, r3
1169 add r2, r2, r3
1170 // Check access flags has
1171 // kAccClassIsFinalizable.
1172 ldr r3, [r2, #MIRROR_CLASS_ACCESS_FLAGS_OFFSET]
1173 tst r3, #ACCESS_FLAGS_CLASS_IS_FINALIZABLE
1174 bne \slowPathLabel
1175 // Load thread_local_pos (r12) and
1176 // thread_local_end (r3) with ldrd.
1177 // Check constraints for ldrd.
1178#if !((THREAD_LOCAL_POS_OFFSET + 4 == THREAD_LOCAL_END_OFFSET) && (THREAD_LOCAL_POS_OFFSET % 8 == 0))
1179#error "Thread::thread_local_pos/end must be consecutive and are 8 byte aligned for performance"
1180#endif
1181 ldrd r12, r3, [r9, #THREAD_LOCAL_POS_OFFSET]
1182 sub r12, r3, r12 // Compute the remaining buf size.
1183 ldr r3, [r2, #MIRROR_CLASS_OBJECT_SIZE_OFFSET] // Load the object size (r3).
1184 cmp r3, r12 // Check if it fits. OK to do this
1185 // before rounding up the object size
1186 // assuming the buf size alignment.
1187 bhi \slowPathLabel
1188 // "Point of no slow path". Won't go to the slow path from here on. OK to clobber r0 and r1.
1189 // Round up the object size by the
1190 // object alignment. (addr + 7) & ~7.
1191 add r3, r3, #OBJECT_ALIGNMENT_MASK
1192 and r3, r3, #OBJECT_ALIGNMENT_MASK_TOGGLED
1193 // Reload old thread_local_pos (r0)
1194 // for the return value.
1195 ldr r0, [r9, #THREAD_LOCAL_POS_OFFSET]
1196 add r1, r0, r3
1197 str r1, [r9, #THREAD_LOCAL_POS_OFFSET] // Store new thread_local_pos.
1198 ldr r1, [r9, #THREAD_LOCAL_OBJECTS_OFFSET] // Increment thread_local_objects.
1199 add r1, r1, #1
1200 str r1, [r9, #THREAD_LOCAL_OBJECTS_OFFSET]
1201 POISON_HEAP_REF r2
1202 str r2, [r0, #MIRROR_OBJECT_CLASS_OFFSET] // Store the class pointer.
1203 // Fence. This is "ish" not "ishst" so
1204 // that the code after this allocation
1205 // site will see the right values in
1206 // the fields of the class.
1207 // Alternatively we could use "ishst"
1208 // if we use load-acquire for the
1209 // class status load.)
1210 dmb ish
1211 bx lr
1212.endm
1213
1214// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB).
1215ENTRY art_quick_alloc_object_tlab
1216 // Fast path tlab allocation.
1217 // r0: type_idx/return value, r1: ArtMethod*, r9: Thread::Current
1218 // r2, r3, r12: free.
1219#if defined(USE_READ_BARRIER)
Hiroshi Yamauchid72945c2016-03-16 11:23:10 -07001220 mvn r0, #0 // Read barrier not supported here.
1221 bx lr // Return -1.
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001222#endif
1223 ldr r2, [r1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_32] // Load dex cache resolved types array
1224 // Load the class (r2)
1225 ldr r2, [r2, r0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1226 ALLOC_OBJECT_TLAB_FAST_PATH .Lart_quick_alloc_object_tlab_slow_path
1227.Lart_quick_alloc_object_tlab_slow_path:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001228 SETUP_SAVE_REFS_ONLY_FRAME r2 // Save callee saves in case of GC.
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001229 mov r2, r9 // Pass Thread::Current.
1230 bl artAllocObjectFromCodeTLAB // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001231 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001232 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1233END art_quick_alloc_object_tlab
1234
1235// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB)
1236ENTRY art_quick_alloc_object_region_tlab
1237 // Fast path tlab allocation.
1238 // r0: type_idx/return value, r1: ArtMethod*, r9: Thread::Current, r2, r3, r12: free.
1239#if !defined(USE_READ_BARRIER)
1240 eor r0, r0, r0 // Read barrier must be enabled here.
1241 sub r0, r0, #1 // Return -1.
1242 bx lr
1243#endif
1244 ldr r2, [r1, #ART_METHOD_DEX_CACHE_TYPES_OFFSET_32] // Load dex cache resolved types array
1245 // Load the class (r2)
1246 ldr r2, [r2, r0, lsl #COMPRESSED_REFERENCE_SIZE_SHIFT]
1247 // Read barrier for class load.
1248 ldr r3, [r9, #THREAD_IS_GC_MARKING_OFFSET]
1249 cbnz r3, .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path
1250.Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit:
1251 ALLOC_OBJECT_TLAB_FAST_PATH .Lart_quick_alloc_object_region_tlab_slow_path
1252.Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path:
1253 // The read barrier slow path. Mark
1254 // the class.
1255 push {r0, r1, r3, lr} // Save registers. r3 is pushed only
1256 // to align sp by 16 bytes.
1257 mov r0, r2 // Pass the class as the first param.
1258 bl artReadBarrierMark
1259 mov r2, r0 // Get the (marked) class back.
1260 pop {r0, r1, r3, lr}
1261 b .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit
1262.Lart_quick_alloc_object_region_tlab_slow_path:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001263 SETUP_SAVE_REFS_ONLY_FRAME r2 // Save callee saves in case of GC.
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001264 mov r2, r9 // Pass Thread::Current.
1265 bl artAllocObjectFromCodeRegionTLAB // (uint32_t type_idx, Method* method, Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001266 RESTORE_SAVE_REFS_ONLY_FRAME
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001267 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1268END art_quick_alloc_object_region_tlab
1269
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001270 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001271 * Called by managed code when the value in rSUSPEND has been decremented to 0.
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001272 */
Ian Rogers9329bbb2013-02-08 19:56:30 -08001273 .extern artTestSuspendFromCode
1274ENTRY art_quick_test_suspend
Wei Jin04f4d8a2014-05-29 18:04:29 -07001275#ifdef ARM_R4_SUSPEND_FLAG
Vladimir Marko952dbb12016-07-28 12:01:51 +01001276 ldrh rSUSPEND, [rSELF, #THREAD_FLAGS_OFFSET]
1277 cbnz rSUSPEND, 1f @ check Thread::Current()->suspend_count_ == 0
1278 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1279 bx lr @ return if suspend_count_ == 0
Ian Rogers637859c2013-08-27 14:35:54 -070012801:
Vladimir Marko952dbb12016-07-28 12:01:51 +01001281 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Wei Jin04f4d8a2014-05-29 18:04:29 -07001282#endif
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001283 SETUP_SAVE_EVERYTHING_FRAME r0 @ save everything for GC stack crawl
Ian Rogers4f0d07c2011-10-06 23:38:47 -07001284 mov r0, rSELF
Vladimir Marko952dbb12016-07-28 12:01:51 +01001285 bl artTestSuspendFromCode @ (Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001286 RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +01001287 bx lr
Ian Rogers9329bbb2013-02-08 19:56:30 -08001288END art_quick_test_suspend
Ian Rogers4f0d07c2011-10-06 23:38:47 -07001289
Dave Allison83252962014-04-03 16:33:48 -07001290ENTRY art_quick_implicit_suspend
1291 mov r0, rSELF
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001292 SETUP_SAVE_REFS_ONLY_FRAME r1 @ save callee saves for stack crawl
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001293 bl artTestSuspendFromCode @ (Thread*)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001294 RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN
Dave Allison83252962014-04-03 16:33:48 -07001295END art_quick_implicit_suspend
1296
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001297 /*
1298 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001299 * r0 holds the proxy method and r1 holds the receiver; r2 and r3 may contain arguments. The
1300 * frame size of the invoked proxy method agrees with a ref and args callee save frame.
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001301 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001302 .extern artQuickProxyInvokeHandler
Ian Rogers9329bbb2013-02-08 19:56:30 -08001303ENTRY art_quick_proxy_invoke_handler
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001304 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_R0
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001305 mov r2, r9 @ pass Thread::Current
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001306 mov r3, sp @ pass SP
Jeff Hao5fa60c32013-04-04 17:57:01 -07001307 blx artQuickProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, SP)
Ian Rogers637859c2013-08-27 14:35:54 -07001308 ldr r2, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Zheng Xu5667fdb2014-10-23 18:29:55 +08001309 // Tear down the callee-save frame. Skip arg registers.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001310 add sp, #(FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY)
1311 .cfi_adjust_cfa_offset -(FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY)
1312 RESTORE_SAVE_REFS_ONLY_FRAME
Zheng Xu5667fdb2014-10-23 18:29:55 +08001313 cbnz r2, 1f @ success if no exception is pending
1314 vmov d0, r0, r1 @ store into fpr, for when it's a fpr return...
Ian Rogers637859c2013-08-27 14:35:54 -07001315 bx lr @ return on success
13161:
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001317 DELIVER_PENDING_EXCEPTION
Ian Rogers9329bbb2013-02-08 19:56:30 -08001318END art_quick_proxy_invoke_handler
Ian Rogersdfcdf1a2011-10-10 17:50:35 -07001319
Jeff Hao88474b42013-10-23 16:24:40 -07001320 /*
Nicolas Geoffray796d6302016-03-13 22:22:31 +00001321 * Called to resolve an imt conflict.
1322 * r0 is the conflict ArtMethod.
1323 * r12 is a hidden argument that holds the target interface method's dex method index.
1324 *
1325 * Note that this stub writes to r0, r4, and r12.
Jeff Hao88474b42013-10-23 16:24:40 -07001326 */
1327ENTRY art_quick_imt_conflict_trampoline
Nicolas Geoffray796d6302016-03-13 22:22:31 +00001328 ldr r4, [sp, #0] // Load referrer
1329 ldr r4, [r4, #ART_METHOD_DEX_CACHE_METHODS_OFFSET_32] // Load dex cache methods array
1330 ldr r12, [r4, r12, lsl #POINTER_SIZE_SHIFT] // Load interface method
1331 ldr r0, [r0, #ART_METHOD_JNI_OFFSET_32] // Load ImtConflictTable
1332 ldr r4, [r0] // Load first entry in ImtConflictTable.
1333.Limt_table_iterate:
1334 cmp r4, r12
1335 // Branch if found. Benchmarks have shown doing a branch here is better.
1336 beq .Limt_table_found
1337 // If the entry is null, the interface method is not in the ImtConflictTable.
1338 cbz r4, .Lconflict_trampoline
1339 // Iterate over the entries of the ImtConflictTable.
1340 ldr r4, [r0, #(2 * __SIZEOF_POINTER__)]!
1341 b .Limt_table_iterate
1342.Limt_table_found:
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001343 // We successfully hit an entry in the table. Load the target method
Nicolas Geoffray796d6302016-03-13 22:22:31 +00001344 // and jump to it.
1345 ldr r0, [r0, #__SIZEOF_POINTER__]
1346 ldr pc, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32]
1347.Lconflict_trampoline:
1348 // Call the runtime stub to populate the ImtConflictTable and jump to the
1349 // resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001350 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001351END art_quick_imt_conflict_trampoline
1352
Ian Rogers468532e2013-08-05 10:56:33 -07001353 .extern artQuickResolutionTrampoline
1354ENTRY art_quick_resolution_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001355 SETUP_SAVE_REFS_AND_ARGS_FRAME r2
Ian Rogers468532e2013-08-05 10:56:33 -07001356 mov r2, r9 @ pass Thread::Current
1357 mov r3, sp @ pass SP
1358 blx artQuickResolutionTrampoline @ (Method* called, receiver, Thread*, SP)
Ian Rogers637859c2013-08-27 14:35:54 -07001359 cbz r0, 1f @ is code pointer null? goto exception
Ian Rogers468532e2013-08-05 10:56:33 -07001360 mov r12, r0
1361 ldr r0, [sp, #0] @ load resolved method in r0
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001362 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001363 bx r12 @ tail-call into actual code
13641:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001365 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001366 DELIVER_PENDING_EXCEPTION
1367END art_quick_resolution_trampoline
1368
Andreas Gampec200a4a2014-06-16 18:39:09 -07001369 /*
1370 * Called to do a generic JNI down-call
1371 */
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001372ENTRY art_quick_generic_jni_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001373 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_R0
Andreas Gampec200a4a2014-06-16 18:39:09 -07001374
1375 // Save rSELF
1376 mov r11, rSELF
1377 // Save SP , so we can have static CFI info. r10 is saved in ref_and_args.
1378 mov r10, sp
1379 .cfi_def_cfa_register r10
1380
1381 sub sp, sp, #5120
1382
1383 // prepare for artQuickGenericJniTrampoline call
1384 // (Thread*, SP)
1385 // r0 r1 <= C calling convention
1386 // rSELF r10 <= where they are
1387
1388 mov r0, rSELF // Thread*
1389 mov r1, r10
1390 blx artQuickGenericJniTrampoline // (Thread*, sp)
1391
1392 // The C call will have registered the complete save-frame on success.
1393 // The result of the call is:
1394 // r0: pointer to native code, 0 on error.
1395 // r1: pointer to the bottom of the used area of the alloca, can restore stack till there.
1396
1397 // Check for error = 0.
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001398 cbz r0, .Lexception_in_native
Andreas Gampec200a4a2014-06-16 18:39:09 -07001399
1400 // Release part of the alloca.
1401 mov sp, r1
1402
1403 // Save the code pointer
1404 mov r12, r0
1405
1406 // Load parameters from frame into registers.
1407 pop {r0-r3}
1408
1409 // Softfloat.
1410 // TODO: Change to hardfloat when supported.
1411
1412 blx r12 // native call.
1413
1414 // result sign extension is handled in C code
1415 // prepare for artQuickGenericJniEndTrampoline call
1416 // (Thread*, result, result_f)
Nicolas Geoffray54accbc2014-08-13 03:40:45 +01001417 // r0 r2,r3 stack <= C calling convention
Andreas Gampec200a4a2014-06-16 18:39:09 -07001418 // r11 r0,r1 r0,r1 <= where they are
Nicolas Geoffray54accbc2014-08-13 03:40:45 +01001419 sub sp, sp, #8 // Stack alignment.
Andreas Gampec200a4a2014-06-16 18:39:09 -07001420
Nicolas Geoffray54accbc2014-08-13 03:40:45 +01001421 push {r0-r1}
1422 mov r3, r1
1423 mov r2, r0
Andreas Gampec200a4a2014-06-16 18:39:09 -07001424 mov r0, r11
1425
1426 blx artQuickGenericJniEndTrampoline
1427
Andreas Gampec200a4a2014-06-16 18:39:09 -07001428 // Restore self pointer.
1429 mov r9, r11
1430
1431 // Pending exceptions possible.
1432 ldr r2, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
1433 cbnz r2, .Lexception_in_native
1434
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001435 // Tear down the alloca.
1436 mov sp, r10
1437 .cfi_def_cfa_register sp
1438
Zheng Xu5667fdb2014-10-23 18:29:55 +08001439 // Tear down the callee-save frame. Skip arg registers.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001440 add sp, #FRAME_SIZE_SAVE_REFS_AND_ARGS-FRAME_SIZE_SAVE_REFS_ONLY
1441 .cfi_adjust_cfa_offset -(FRAME_SIZE_SAVE_REFS_AND_ARGS-FRAME_SIZE_SAVE_REFS_ONLY)
1442 RESTORE_SAVE_REFS_ONLY_FRAME
Andreas Gampec200a4a2014-06-16 18:39:09 -07001443
Zheng Xu5667fdb2014-10-23 18:29:55 +08001444 // store into fpr, for when it's a fpr return...
1445 vmov d0, r0, r1
Andreas Gampec200a4a2014-06-16 18:39:09 -07001446 bx lr // ret
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -07001447 // Undo the unwinding information from above since it doesn't apply below.
1448 .cfi_def_cfa_register r10
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001449 .cfi_adjust_cfa_offset FRAME_SIZE_SAVE_REFS_AND_ARGS-FRAME_SIZE_SAVE_REFS_ONLY
Andreas Gampec200a4a2014-06-16 18:39:09 -07001450
Andreas Gampec200a4a2014-06-16 18:39:09 -07001451.Lexception_in_native:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001452 ldr sp, [r9, #THREAD_TOP_QUICK_FRAME_OFFSET]
1453 .cfi_def_cfa_register sp
1454 # This will create a new save-all frame, required by the runtime.
Andreas Gampec200a4a2014-06-16 18:39:09 -07001455 DELIVER_PENDING_EXCEPTION
Andreas Gampec200a4a2014-06-16 18:39:09 -07001456END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001457
Ian Rogers468532e2013-08-05 10:56:33 -07001458 .extern artQuickToInterpreterBridge
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001459ENTRY art_quick_to_interpreter_bridge
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001460 SETUP_SAVE_REFS_AND_ARGS_FRAME r1
Ian Rogers7db619b2013-01-16 18:35:48 -08001461 mov r1, r9 @ pass Thread::Current
1462 mov r2, sp @ pass SP
Ian Rogers468532e2013-08-05 10:56:33 -07001463 blx artQuickToInterpreterBridge @ (Method* method, Thread*, SP)
Ian Rogers637859c2013-08-27 14:35:54 -07001464 ldr r2, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_
Zheng Xu5667fdb2014-10-23 18:29:55 +08001465 // Tear down the callee-save frame. Skip arg registers.
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001466 add sp, #(FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY)
1467 .cfi_adjust_cfa_offset -(FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY)
1468 RESTORE_SAVE_REFS_ONLY_FRAME
Mathieu Chartier590fee92013-09-13 13:46:47 -07001469 cbnz r2, 1f @ success if no exception is pending
Zheng Xu5667fdb2014-10-23 18:29:55 +08001470 vmov d0, r0, r1 @ store into fpr, for when it's a fpr return...
1471 bx lr @ return on success
Ian Rogers637859c2013-08-27 14:35:54 -070014721:
Ian Rogers7db619b2013-01-16 18:35:48 -08001473 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001474END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001475
jeffhaoe343b762011-12-05 16:36:44 -08001476 /*
jeffhao0791adc2012-04-04 11:14:32 -07001477 * Routine that intercepts method calls and returns.
jeffhaoe343b762011-12-05 16:36:44 -08001478 */
Ian Rogers9329bbb2013-02-08 19:56:30 -08001479 .extern artInstrumentationMethodEntryFromCode
1480 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001481ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001482 @ Make stack crawlable and clobber r2 and r3 (post saving)
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001483 SETUP_SAVE_REFS_AND_ARGS_FRAME r2
1484 @ preserve r0 (not normally an arg) knowing there is a spare slot in kSaveRefsAndArgs.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001485 str r0, [sp, #4]
Ian Rogers62d6c772013-02-27 08:32:07 -08001486 mov r2, r9 @ pass Thread::Current
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001487 mov r3, lr @ pass LR
1488 blx artInstrumentationMethodEntryFromCode @ (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001489 mov r12, r0 @ r12 holds reference to code
1490 ldr r0, [sp, #4] @ restore r0
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001491 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001492 blx r12 @ call method with lr set to art_quick_instrumentation_exit
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001493@ Deliberate fall-through into art_quick_instrumentation_exit.
Ian Rogers468532e2013-08-05 10:56:33 -07001494 .type art_quick_instrumentation_exit, #function
1495 .global art_quick_instrumentation_exit
1496art_quick_instrumentation_exit:
Ian Rogers62d6c772013-02-27 08:32:07 -08001497 mov lr, #0 @ link register is to here, so clobber with 0 for later checks
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001498 SETUP_SAVE_REFS_ONLY_FRAME r2 @ set up frame knowing r2 and r3 must be dead on exit
Ian Rogers306057f2012-11-26 12:45:53 -08001499 mov r12, sp @ remember bottom of caller's frame
jeffhaoe343b762011-12-05 16:36:44 -08001500 push {r0-r1} @ save return value
Ian Rogers9329bbb2013-02-08 19:56:30 -08001501 .cfi_adjust_cfa_offset 8
1502 .cfi_rel_offset r0, 0
1503 .cfi_rel_offset r1, 4
Andreas Gampec89b0472015-06-23 23:28:59 -07001504 vpush {d0} @ save fp return value
Ian Rogers9329bbb2013-02-08 19:56:30 -08001505 .cfi_adjust_cfa_offset 8
Andreas Gampec89b0472015-06-23 23:28:59 -07001506 sub sp, #8 @ space for return value argument. Note: AAPCS stack alignment is 8B, no
1507 @ need to align by 16.
1508 .cfi_adjust_cfa_offset 8
1509 vstr d0, [sp] @ d0 -> [sp] for fpr_res
Ian Rogers62d6c772013-02-27 08:32:07 -08001510 mov r2, r0 @ pass return value as gpr_res
1511 mov r3, r1
Ian Rogers306057f2012-11-26 12:45:53 -08001512 mov r0, r9 @ pass Thread::Current
1513 mov r1, r12 @ pass SP
Ian Rogers62d6c772013-02-27 08:32:07 -08001514 blx artInstrumentationMethodExitFromCode @ (Thread*, SP, gpr_res, fpr_res)
Ian Rogers306057f2012-11-26 12:45:53 -08001515 add sp, #8
Ian Rogers9329bbb2013-02-08 19:56:30 -08001516 .cfi_adjust_cfa_offset -8
Ian Rogers62d6c772013-02-27 08:32:07 -08001517
Ian Rogers306057f2012-11-26 12:45:53 -08001518 mov r2, r0 @ link register saved by instrumentation
1519 mov lr, r1 @ r1 is holding link register if we're to bounce to deoptimize
Andreas Gampec89b0472015-06-23 23:28:59 -07001520 vpop {d0} @ restore fp return value
1521 .cfi_adjust_cfa_offset -8
jeffhaoe343b762011-12-05 16:36:44 -08001522 pop {r0, r1} @ restore return value
Christopher Ferrisd0a0b3e2014-10-30 19:04:13 -07001523 .cfi_adjust_cfa_offset -8
Dave Allisonbbb32c22013-11-05 18:25:18 -08001524 .cfi_restore r0
1525 .cfi_restore r1
Ian Rogers62d6c772013-02-27 08:32:07 -08001526 add sp, #32 @ remove callee save frame
1527 .cfi_adjust_cfa_offset -32
Ian Rogers306057f2012-11-26 12:45:53 -08001528 bx r2 @ return
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001529END art_quick_instrumentation_entry
Ian Rogers306057f2012-11-26 12:45:53 -08001530
Ian Rogers306057f2012-11-26 12:45:53 -08001531 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001532 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1533 * will long jump to the upcall with a special exception of -1.
Ian Rogers306057f2012-11-26 12:45:53 -08001534 */
Ian Rogers9329bbb2013-02-08 19:56:30 -08001535 .extern artDeoptimize
Ian Rogers9329bbb2013-02-08 19:56:30 -08001536ENTRY art_quick_deoptimize
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001537 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r0
Ian Rogers62d6c772013-02-27 08:32:07 -08001538 mov r0, r9 @ Set up args.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001539 blx artDeoptimize @ artDeoptimize(Thread*)
Ian Rogers9329bbb2013-02-08 19:56:30 -08001540END art_quick_deoptimize
jeffhaoe343b762011-12-05 16:36:44 -08001541
Ian Rogers324e1902012-09-09 12:17:52 -07001542 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00001543 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
Andreas Gampe639bdd12015-06-03 11:22:45 -07001544 * will long jump to the interpreter bridge.
Sebastien Hertz07474662015-08-25 15:12:33 +00001545 */
1546 .extern artDeoptimizeFromCompiledCode
1547ENTRY art_quick_deoptimize_from_compiled_code
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001548 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME r0
Sebastien Hertz07474662015-08-25 15:12:33 +00001549 mov r0, r9 @ Set up args.
1550 blx artDeoptimizeFromCompiledCode @ artDeoptimizeFromCompiledCode(Thread*)
1551END art_quick_deoptimize_from_compiled_code
1552
1553 /*
Ian Rogers324e1902012-09-09 12:17:52 -07001554 * Signed 64-bit integer multiply.
1555 *
1556 * Consider WXxYZ (r1r0 x r3r2) with a long multiply:
1557 * WX
1558 * x YZ
1559 * --------
1560 * ZW ZX
1561 * YW YX
1562 *
1563 * The low word of the result holds ZX, the high word holds
1564 * (ZW+YX) + (the high overflow from ZX). YW doesn't matter because
1565 * it doesn't fit in the low 64 bits.
1566 *
1567 * Unlike most ARM math operations, multiply instructions have
1568 * restrictions on using the same register more than once (Rd and Rm
1569 * cannot be the same).
1570 */
1571 /* mul-long vAA, vBB, vCC */
Ian Rogers9329bbb2013-02-08 19:56:30 -08001572ENTRY art_quick_mul_long
Ian Rogers324e1902012-09-09 12:17:52 -07001573 push {r9 - r10}
Ian Rogers9329bbb2013-02-08 19:56:30 -08001574 .cfi_adjust_cfa_offset 8
1575 .cfi_rel_offset r9, 0
1576 .cfi_rel_offset r10, 4
Ian Rogers324e1902012-09-09 12:17:52 -07001577 mul ip, r2, r1 @ ip<- ZxW
1578 umull r9, r10, r2, r0 @ r9/r10 <- ZxX
1579 mla r2, r0, r3, ip @ r2<- YxX + (ZxW)
1580 add r10, r2, r10 @ r10<- r10 + low(ZxW + (YxX))
1581 mov r0,r9
1582 mov r1,r10
1583 pop {r9 - r10}
Ian Rogers9329bbb2013-02-08 19:56:30 -08001584 .cfi_adjust_cfa_offset -8
Dave Allisonbbb32c22013-11-05 18:25:18 -08001585 .cfi_restore r9
1586 .cfi_restore r10
Ian Rogers324e1902012-09-09 12:17:52 -07001587 bx lr
Ian Rogers9329bbb2013-02-08 19:56:30 -08001588END art_quick_mul_long
Ian Rogers324e1902012-09-09 12:17:52 -07001589
buzbee54330722011-08-23 16:46:55 -07001590 /*
1591 * Long integer shift. This is different from the generic 32/64-bit
1592 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1593 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1594 * 6 bits.
1595 * On entry:
1596 * r0: low word
1597 * r1: high word
1598 * r2: shift count
1599 */
1600 /* shl-long vAA, vBB, vCC */
Ian Rogers637859c2013-08-27 14:35:54 -07001601ARM_ENTRY art_quick_shl_long @ ARM code as thumb code requires spills
buzbee54330722011-08-23 16:46:55 -07001602 and r2, r2, #63 @ r2<- r2 & 0x3f
1603 mov r1, r1, asl r2 @ r1<- r1 << r2
1604 rsb r3, r2, #32 @ r3<- 32 - r2
1605 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
1606 subs ip, r2, #32 @ ip<- r2 - 32
1607 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
1608 mov r0, r0, asl r2 @ r0<- r0 << r2
1609 bx lr
Ian Rogers9329bbb2013-02-08 19:56:30 -08001610END art_quick_shl_long
buzbee54330722011-08-23 16:46:55 -07001611
buzbee54330722011-08-23 16:46:55 -07001612 /*
1613 * Long integer shift. This is different from the generic 32/64-bit
1614 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1615 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1616 * 6 bits.
1617 * On entry:
1618 * r0: low word
1619 * r1: high word
1620 * r2: shift count
1621 */
1622 /* shr-long vAA, vBB, vCC */
Ian Rogers637859c2013-08-27 14:35:54 -07001623ARM_ENTRY art_quick_shr_long @ ARM code as thumb code requires spills
buzbee54330722011-08-23 16:46:55 -07001624 and r2, r2, #63 @ r0<- r0 & 0x3f
1625 mov r0, r0, lsr r2 @ r0<- r2 >> r2
1626 rsb r3, r2, #32 @ r3<- 32 - r2
1627 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
1628 subs ip, r2, #32 @ ip<- r2 - 32
1629 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
1630 mov r1, r1, asr r2 @ r1<- r1 >> r2
1631 bx lr
Ian Rogers9329bbb2013-02-08 19:56:30 -08001632END art_quick_shr_long
buzbee54330722011-08-23 16:46:55 -07001633
buzbee54330722011-08-23 16:46:55 -07001634 /*
1635 * Long integer shift. This is different from the generic 32/64-bit
1636 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1637 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1638 * 6 bits.
1639 * On entry:
1640 * r0: low word
1641 * r1: high word
1642 * r2: shift count
1643 */
1644 /* ushr-long vAA, vBB, vCC */
Ian Rogers637859c2013-08-27 14:35:54 -07001645ARM_ENTRY art_quick_ushr_long @ ARM code as thumb code requires spills
buzbee54330722011-08-23 16:46:55 -07001646 and r2, r2, #63 @ r0<- r0 & 0x3f
1647 mov r0, r0, lsr r2 @ r0<- r2 >> r2
1648 rsb r3, r2, #32 @ r3<- 32 - r2
1649 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
1650 subs ip, r2, #32 @ ip<- r2 - 32
1651 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
1652 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
1653 bx lr
Ian Rogers9329bbb2013-02-08 19:56:30 -08001654END art_quick_ushr_long
buzbeefc9e6fa2012-03-23 15:14:29 -07001655
buzbeefc9e6fa2012-03-23 15:14:29 -07001656 /*
1657 * String's indexOf.
1658 *
1659 * On entry:
1660 * r0: string object (known non-null)
jeffhao86e46712012-08-08 17:30:59 -07001661 * r1: char to match (known <= 0xFFFF)
buzbeefc9e6fa2012-03-23 15:14:29 -07001662 * r2: Starting offset in string data
1663 */
Ian Rogers9329bbb2013-02-08 19:56:30 -08001664ENTRY art_quick_indexof
buzbeefc9e6fa2012-03-23 15:14:29 -07001665 push {r4, r10-r11, lr} @ 4 words of callee saves
Ian Rogers9329bbb2013-02-08 19:56:30 -08001666 .cfi_adjust_cfa_offset 16
1667 .cfi_rel_offset r4, 0
1668 .cfi_rel_offset r10, 4
1669 .cfi_rel_offset r11, 8
1670 .cfi_rel_offset lr, 12
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001671 ldr r3, [r0, #MIRROR_STRING_COUNT_OFFSET]
Jeff Hao848f70a2014-01-15 13:49:50 -08001672 add r0, #MIRROR_STRING_VALUE_OFFSET
buzbeefc9e6fa2012-03-23 15:14:29 -07001673
1674 /* Clamp start to [0..count] */
1675 cmp r2, #0
Ian Rogers637859c2013-08-27 14:35:54 -07001676 it lt
buzbeefc9e6fa2012-03-23 15:14:29 -07001677 movlt r2, #0
1678 cmp r2, r3
Ian Rogers637859c2013-08-27 14:35:54 -07001679 it gt
buzbeefc9e6fa2012-03-23 15:14:29 -07001680 movgt r2, r3
1681
buzbeefc9e6fa2012-03-23 15:14:29 -07001682 /* Save a copy in r12 to later compute result */
1683 mov r12, r0
1684
1685 /* Build pointer to start of data to compare and pre-bias */
1686 add r0, r0, r2, lsl #1
1687 sub r0, #2
1688
1689 /* Compute iteration count */
1690 sub r2, r3, r2
1691
1692 /*
1693 * At this point we have:
1694 * r0: start of data to test
1695 * r1: char to compare
1696 * r2: iteration count
1697 * r12: original start of string data
1698 * r3, r4, r10, r11 available for loading string data
1699 */
1700
1701 subs r2, #4
Ian Rogers5d885c82014-02-21 20:06:23 -08001702 blt .Lindexof_remainder
buzbeefc9e6fa2012-03-23 15:14:29 -07001703
Ian Rogers5d885c82014-02-21 20:06:23 -08001704.Lindexof_loop4:
buzbeefc9e6fa2012-03-23 15:14:29 -07001705 ldrh r3, [r0, #2]!
1706 ldrh r4, [r0, #2]!
1707 ldrh r10, [r0, #2]!
1708 ldrh r11, [r0, #2]!
1709 cmp r3, r1
Ian Rogers5d885c82014-02-21 20:06:23 -08001710 beq .Lmatch_0
buzbeefc9e6fa2012-03-23 15:14:29 -07001711 cmp r4, r1
Ian Rogers5d885c82014-02-21 20:06:23 -08001712 beq .Lmatch_1
buzbeefc9e6fa2012-03-23 15:14:29 -07001713 cmp r10, r1
Ian Rogers5d885c82014-02-21 20:06:23 -08001714 beq .Lmatch_2
buzbeefc9e6fa2012-03-23 15:14:29 -07001715 cmp r11, r1
Ian Rogers5d885c82014-02-21 20:06:23 -08001716 beq .Lmatch_3
buzbeefc9e6fa2012-03-23 15:14:29 -07001717 subs r2, #4
Ian Rogers5d885c82014-02-21 20:06:23 -08001718 bge .Lindexof_loop4
buzbeefc9e6fa2012-03-23 15:14:29 -07001719
Ian Rogers5d885c82014-02-21 20:06:23 -08001720.Lindexof_remainder:
1721 adds r2, #4
1722 beq .Lindexof_nomatch
buzbeefc9e6fa2012-03-23 15:14:29 -07001723
Ian Rogers5d885c82014-02-21 20:06:23 -08001724.Lindexof_loop1:
buzbeefc9e6fa2012-03-23 15:14:29 -07001725 ldrh r3, [r0, #2]!
1726 cmp r3, r1
Ian Rogers5d885c82014-02-21 20:06:23 -08001727 beq .Lmatch_3
buzbeefc9e6fa2012-03-23 15:14:29 -07001728 subs r2, #1
Ian Rogers5d885c82014-02-21 20:06:23 -08001729 bne .Lindexof_loop1
buzbeefc9e6fa2012-03-23 15:14:29 -07001730
Ian Rogers5d885c82014-02-21 20:06:23 -08001731.Lindexof_nomatch:
buzbeefc9e6fa2012-03-23 15:14:29 -07001732 mov r0, #-1
1733 pop {r4, r10-r11, pc}
1734
Ian Rogers5d885c82014-02-21 20:06:23 -08001735.Lmatch_0:
buzbeefc9e6fa2012-03-23 15:14:29 -07001736 sub r0, #6
1737 sub r0, r12
1738 asr r0, r0, #1
1739 pop {r4, r10-r11, pc}
Ian Rogers5d885c82014-02-21 20:06:23 -08001740.Lmatch_1:
buzbeefc9e6fa2012-03-23 15:14:29 -07001741 sub r0, #4
1742 sub r0, r12
1743 asr r0, r0, #1
1744 pop {r4, r10-r11, pc}
Ian Rogers5d885c82014-02-21 20:06:23 -08001745.Lmatch_2:
buzbeefc9e6fa2012-03-23 15:14:29 -07001746 sub r0, #2
1747 sub r0, r12
1748 asr r0, r0, #1
1749 pop {r4, r10-r11, pc}
Ian Rogers5d885c82014-02-21 20:06:23 -08001750.Lmatch_3:
buzbeefc9e6fa2012-03-23 15:14:29 -07001751 sub r0, r12
1752 asr r0, r0, #1
1753 pop {r4, r10-r11, pc}
Ian Rogers9329bbb2013-02-08 19:56:30 -08001754END art_quick_indexof
buzbeefc9e6fa2012-03-23 15:14:29 -07001755
Zheng Xu5667fdb2014-10-23 18:29:55 +08001756 /* Assembly routines used to handle ABI differences. */
1757
1758 /* double fmod(double a, double b) */
1759 .extern fmod
1760ENTRY art_quick_fmod
1761 push {lr}
1762 .cfi_adjust_cfa_offset 4
1763 .cfi_rel_offset lr, 0
1764 sub sp, #4
1765 .cfi_adjust_cfa_offset 4
1766 vmov r0, r1, d0
1767 vmov r2, r3, d1
1768 bl fmod
1769 vmov d0, r0, r1
1770 add sp, #4
1771 .cfi_adjust_cfa_offset -4
1772 pop {pc}
Zheng Xu5667fdb2014-10-23 18:29:55 +08001773END art_quick_fmod
1774
1775 /* float fmodf(float a, float b) */
1776 .extern fmodf
1777ENTRY art_quick_fmodf
1778 push {lr}
1779 .cfi_adjust_cfa_offset 4
1780 .cfi_rel_offset lr, 0
1781 sub sp, #4
1782 .cfi_adjust_cfa_offset 4
1783 vmov r0, r1, d0
1784 bl fmodf
1785 vmov s0, r0
1786 add sp, #4
1787 .cfi_adjust_cfa_offset -4
1788 pop {pc}
Goran Jakovljevicab4c64b2016-04-14 11:46:58 +02001789END art_quick_fmodf
Zheng Xu5667fdb2014-10-23 18:29:55 +08001790
1791 /* int64_t art_d2l(double d) */
1792 .extern art_d2l
1793ENTRY art_quick_d2l
1794 vmov r0, r1, d0
1795 b art_d2l
1796END art_quick_d2l
1797
1798 /* int64_t art_f2l(float f) */
1799 .extern art_f2l
1800ENTRY art_quick_f2l
1801 vmov r0, s0
1802 b art_f2l
1803END art_quick_f2l
Roland Levillain5b3ee562015-04-14 16:02:41 +01001804
1805 /* float art_l2f(int64_t l) */
1806 .extern art_l2f
1807ENTRY art_quick_l2f
1808 push {lr}
1809 .cfi_adjust_cfa_offset 4
1810 .cfi_rel_offset lr, 0
1811 sub sp, #4
1812 .cfi_adjust_cfa_offset 4
1813 bl art_l2f
1814 vmov s0, r0
1815 add sp, #4
1816 .cfi_adjust_cfa_offset -4
1817 pop {pc}
1818END art_quick_l2f
Roland Levillain02b75802016-07-13 11:54:35 +01001819
1820 /*
1821 * Create a function `name` calling the ReadBarrier::Mark routine,
1822 * getting its argument and returning its result through register
Roland Levillain4359e612016-07-20 11:32:19 +01001823 * `reg`, saving and restoring all caller-save registers.
1824 *
1825 * If `reg` is different from `r0`, the generated function follows a
1826 * non-standard runtime calling convention:
1827 * - register `reg` is used to pass the (sole) argument of this
1828 * function (instead of R0);
1829 * - register `reg` is used to return the result of this function
Roland Levillain02b75802016-07-13 11:54:35 +01001830 * (instead of R0);
Roland Levillain02b75802016-07-13 11:54:35 +01001831 * - R0 is treated like a normal (non-argument) caller-save register;
1832 * - everything else is the same as in the standard runtime calling
Roland Levillain4359e612016-07-20 11:32:19 +01001833 * convention (e.g. standard callee-save registers are preserved).
Roland Levillain02b75802016-07-13 11:54:35 +01001834 */
1835.macro READ_BARRIER_MARK_REG name, reg
1836ENTRY \name
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001837 // Null check so that we can load the lock word.
1838 cmp \reg, #0
1839 beq .Lret_rb_\name
1840 // Check lock word for mark bit, if marked return.
1841 push {r0}
1842 ldr r0, [\reg, MIRROR_OBJECT_LOCK_WORD_OFFSET]
1843 and r0, #LOCK_WORD_MARK_BIT_MASK_SHIFTED
1844 cbz r0, .Lslow_rb_\name
1845 // Restore LR and return.
1846 pop {r0}
1847 bx lr
1848
1849.Lslow_rb_\name:
1850 pop {r0}
Roland Levillain4359e612016-07-20 11:32:19 +01001851 push {r0-r4, r9, r12, lr} @ save return address and core caller-save registers
1852 .cfi_adjust_cfa_offset 32
1853 .cfi_rel_offset r0, 0
1854 .cfi_rel_offset r1, 4
1855 .cfi_rel_offset r2, 8
1856 .cfi_rel_offset r3, 12
1857 .cfi_rel_offset r4, 16
1858 .cfi_rel_offset r9, 20
1859 .cfi_rel_offset r12, 24
1860 .cfi_rel_offset lr, 28
1861 vpush {s0-s15} @ save floating-point caller-save registers
1862 .cfi_adjust_cfa_offset 64
1863
1864 .ifnc \reg, r0
1865 mov r0, \reg @ pass arg1 - obj from `reg`
1866 .endif
1867 bl artReadBarrierMark @ r0 <- artReadBarrierMark(obj)
1868
1869 vpop {s0-s15} @ restore floating-point registers
1870 .cfi_adjust_cfa_offset -64
1871 @ If `reg` is a caller-save register, save the result to its
1872 @ corresponding stack slot; it will be restored by the "pop"
1873 @ instruction below. Otherwise, move result into `reg`.
1874 @
1875 @ (Note that saving `reg` to its stack slot will overwrite the value
1876 @ previously stored by the "push" instruction above. That is
1877 @ alright, as in that case we know that `reg` is not a live
1878 @ register, as it is used to pass the argument and return the result
1879 @ of this function.)
1880 .ifc \reg, r0
1881 PUSH_REG r0, 0 @ copy result to r0's stack location
1882 .else
1883 .ifc \reg, r1
1884 PUSH_REG r0, 4 @ copy result to r1's stack location
1885 .else
1886 .ifc \reg, r2
1887 PUSH_REG r0, 8 @ copy result to r2's stack location
1888 .else
1889 .ifc \reg, r3
1890 PUSH_REG r0, 12 @ copy result to r3's stack location
1891 .else
1892 .ifc \reg, r4
1893 PUSH_REG r0, 16 @ copy result to r4's stack location
1894 .else
1895 .ifc \reg, r9
1896 PUSH_REG r0, 20 @ copy result to r9's stack location
1897 .else
1898 .ifc \reg, r12
1899 PUSH_REG r0, 24 @ copy result to r12's stack location
1900 .else
1901 mov \reg, r0 @ return result into `reg`
1902 .endif
1903 .endif
1904 .endif
1905 .endif
1906 .endif
1907 .endif
1908 .endif
1909 pop {r0-r4, r9, r12, pc} @ restore caller-save registers and return
Mathieu Chartier36a270a2016-07-28 18:08:51 -07001910.Lret_rb_\name:
1911 bx lr
Roland Levillain02b75802016-07-13 11:54:35 +01001912END \name
1913.endm
1914
Roland Levillain4359e612016-07-20 11:32:19 +01001915READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg00, r0
Roland Levillain02b75802016-07-13 11:54:35 +01001916READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg01, r1
1917READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg02, r2
1918READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg03, r3
1919READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg04, r4
1920READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg05, r5
1921READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg06, r6
1922READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg07, r7
1923READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg08, r8
1924READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg09, r9
1925READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg10, r10
1926READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg11, r11
1927READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg12, r12