blob: a0fc6d2f9ce6a0c1a9ddaad99bd00dd09231d39c [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_mips.S"
buzbee5bc5a7b2012-03-07 15:52:59 -080018
Mathieu Chartier7410f292013-11-24 13:17:35 -080019#include "arch/quick_alloc_entrypoints.S"
20
jeffhao07030602012-09-26 14:33:14 -070021 .set noreorder
buzbee5bc5a7b2012-03-07 15:52:59 -080022 .balign 4
23
24 /* Deliver the given exception */
25 .extern artDeliverExceptionFromCode
26 /* Deliver an exception pending on a thread */
jeffhao8161c032012-10-31 15:50:00 -070027 .extern artDeliverPendingExceptionFromCode
buzbee5bc5a7b2012-03-07 15:52:59 -080028
Douglas Leung735b8552014-10-31 12:21:40 -070029#define ARG_SLOT_SIZE 32 // space for a0-a3 plus 4 more words
30
buzbee5bc5a7b2012-03-07 15:52:59 -080031 /*
32 * Macro that sets up the callee save frame to conform with
33 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Douglas Leung735b8552014-10-31 12:21:40 -070034 * Callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word for Method*
35 * Clobbers $t0 and $sp
36 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
37 * Reserves FRAME_SIZE_SAVE_ALL_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080038 */
Ian Rogers57b86d42012-03-27 16:05:41 -070039.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -070040 addiu $sp, $sp, -48
41 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -070042
43 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -070044#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -070045#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
46#endif
47
Douglas Leung735b8552014-10-31 12:21:40 -070048 sw $ra, 44($sp)
49 .cfi_rel_offset 31, 44
50 sw $s8, 40($sp)
51 .cfi_rel_offset 30, 40
52 sw $gp, 36($sp)
53 .cfi_rel_offset 28, 36
54 sw $s7, 32($sp)
55 .cfi_rel_offset 23, 32
56 sw $s6, 28($sp)
57 .cfi_rel_offset 22, 28
58 sw $s5, 24($sp)
59 .cfi_rel_offset 21, 24
60 sw $s4, 20($sp)
61 .cfi_rel_offset 20, 20
62 sw $s3, 16($sp)
63 .cfi_rel_offset 19, 16
64 sw $s2, 12($sp)
65 .cfi_rel_offset 18, 12
66 sw $s1, 8($sp)
67 .cfi_rel_offset 17, 8
68 sw $s0, 4($sp)
69 .cfi_rel_offset 16, 4
70 # 1 word for holding Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070071
Douglas Leung4af77b72014-10-22 16:32:28 -070072 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
73 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070074 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -070075 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070076 sw $t0, 0($sp) # Place Method* at bottom of stack.
77 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -070078 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
79 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -080080.endm
81
82 /*
83 * Macro that sets up the callee save frame to conform with
84 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
85 * Does not include rSUSPEND or rSELF
Douglas Leung735b8552014-10-31 12:21:40 -070086 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
87 * Clobbers $t0 and $sp
88 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
89 * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080090 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070091.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -070092 addiu $sp, $sp, -48
93 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -070094
95 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -070096#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -070097#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
98#endif
99
Douglas Leung735b8552014-10-31 12:21:40 -0700100 sw $ra, 44($sp)
101 .cfi_rel_offset 31, 44
102 sw $s8, 40($sp)
103 .cfi_rel_offset 30, 40
104 sw $gp, 36($sp)
105 .cfi_rel_offset 28, 36
106 sw $s7, 32($sp)
107 .cfi_rel_offset 23, 32
108 sw $s6, 28($sp)
109 .cfi_rel_offset 22, 28
110 sw $s5, 24($sp)
111 .cfi_rel_offset 21, 24
112 sw $s4, 20($sp)
113 .cfi_rel_offset 20, 20
114 sw $s3, 16($sp)
115 .cfi_rel_offset 19, 16
116 sw $s2, 12($sp)
117 .cfi_rel_offset 18, 12
118 # 2 words for alignment and bottom word will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700119
Douglas Leung4af77b72014-10-22 16:32:28 -0700120 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
121 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700122 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700123 lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700124 sw $t0, 0($sp) # Place Method* at bottom of stack.
125 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700126 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
127 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800128.endm
129
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700130.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700131 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
132 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
133 lw $ra, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800134 .cfi_restore 31
Douglas Leung735b8552014-10-31 12:21:40 -0700135 lw $s8, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800136 .cfi_restore 30
Douglas Leung735b8552014-10-31 12:21:40 -0700137 lw $gp, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800138 .cfi_restore 28
Douglas Leung735b8552014-10-31 12:21:40 -0700139 lw $s7, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800140 .cfi_restore 23
Douglas Leung735b8552014-10-31 12:21:40 -0700141 lw $s6, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800142 .cfi_restore 22
Douglas Leung735b8552014-10-31 12:21:40 -0700143 lw $s5, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800144 .cfi_restore 21
Douglas Leung735b8552014-10-31 12:21:40 -0700145 lw $s4, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800146 .cfi_restore 20
Douglas Leung735b8552014-10-31 12:21:40 -0700147 lw $s3, 16($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800148 .cfi_restore 19
Douglas Leung735b8552014-10-31 12:21:40 -0700149 lw $s2, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800150 .cfi_restore 18
Douglas Leung735b8552014-10-31 12:21:40 -0700151 addiu $sp, $sp, 48
152 .cfi_adjust_cfa_offset -48
buzbee5bc5a7b2012-03-07 15:52:59 -0800153.endm
154
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700155.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Douglas Leung735b8552014-10-31 12:21:40 -0700156 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700157 jr $ra
Douglas Leung735b8552014-10-31 12:21:40 -0700158 nop
buzbee5bc5a7b2012-03-07 15:52:59 -0800159.endm
160
161 /*
162 * Macro that sets up the callee save frame to conform with
Douglas Leung735b8552014-10-31 12:21:40 -0700163 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700164 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800165 */
Douglas Leung735b8552014-10-31 12:21:40 -0700166.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700167 addiu $sp, $sp, -64
168 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700169
170 // Ugly compile-time check, but we only have the preprocessor.
171#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
172#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
173#endif
174
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700175 sw $ra, 60($sp)
176 .cfi_rel_offset 31, 60
177 sw $s8, 56($sp)
178 .cfi_rel_offset 30, 56
179 sw $gp, 52($sp)
180 .cfi_rel_offset 28, 52
181 sw $s7, 48($sp)
182 .cfi_rel_offset 23, 48
183 sw $s6, 44($sp)
184 .cfi_rel_offset 22, 44
185 sw $s5, 40($sp)
186 .cfi_rel_offset 21, 40
187 sw $s4, 36($sp)
188 .cfi_rel_offset 20, 36
189 sw $s3, 32($sp)
190 .cfi_rel_offset 19, 32
191 sw $s2, 28($sp)
192 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700193 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800194 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700195 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800196 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700197 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800198 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700199 # bottom will hold Method*
Douglas Leung735b8552014-10-31 12:21:40 -0700200.endm
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700201
Douglas Leung735b8552014-10-31 12:21:40 -0700202 /*
203 * Macro that sets up the callee save frame to conform with
204 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
205 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
206 * Clobbers $t0 and $sp
207 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
208 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
209 */
210.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
211 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Douglas Leung4af77b72014-10-22 16:32:28 -0700212 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
213 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700214 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700215 lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700216 sw $t0, 0($sp) # Place Method* at bottom of stack.
217 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700218 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
219 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
220.endm
221
222 /*
223 * Macro that sets up the callee save frame to conform with
224 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
225 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
226 * Clobbers $sp
227 * Use $a0 as the Method* and loads it into bottom of stack.
228 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
229 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
230 */
231.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
232 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
233 sw $a0, 0($sp) # Place Method* at bottom of stack.
234 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
235 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
236 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800237.endm
238
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700239.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700240 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
241 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700242 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800243 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700244 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800245 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700246 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800247 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700248 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800249 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700250 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800251 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700252 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800253 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700254 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800255 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700256 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800257 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700258 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800259 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700260 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800261 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700262 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800263 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700264 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800265 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700266 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700267 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800268.endm
269
270 /*
271 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
272 * exception is Thread::Current()->exception_
273 */
274.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700275 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700276 la $t9, artDeliverPendingExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700277 jr $t9 # artDeliverPendingExceptionFromCode(Thread*)
278 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800279.endm
280
281.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700282 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700283 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700284 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800285 nop
jeffhao7fbee072012-08-24 17:56:54 -0700286 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800287 nop
2881:
289 DELIVER_PENDING_EXCEPTION
290.endm
291
292.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700293 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700294 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800295 nop
jeffhao7fbee072012-08-24 17:56:54 -0700296 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800297 nop
2981:
299 DELIVER_PENDING_EXCEPTION
300.endm
301
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800302.macro RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700303 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700304 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800305 nop
jeffhao7fbee072012-08-24 17:56:54 -0700306 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800307 nop
3081:
309 DELIVER_PENDING_EXCEPTION
310.endm
311
buzbee5bc5a7b2012-03-07 15:52:59 -0800312 /*
jeffhao7fbee072012-08-24 17:56:54 -0700313 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800314 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
315 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800316ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800317 LDu $f0, $f1, 0*8, $a1, $t1
318 LDu $f2, $f3, 1*8, $a1, $t1
319 LDu $f4, $f5, 2*8, $a1, $t1
320 LDu $f6, $f7, 3*8, $a1, $t1
321 LDu $f8, $f9, 4*8, $a1, $t1
322 LDu $f10, $f11, 5*8, $a1, $t1
323 LDu $f12, $f13, 6*8, $a1, $t1
324 LDu $f14, $f15, 7*8, $a1, $t1
325 LDu $f16, $f17, 8*8, $a1, $t1
326 LDu $f18, $f19, 9*8, $a1, $t1
327 LDu $f20, $f21, 10*8, $a1, $t1
328 LDu $f22, $f23, 11*8, $a1, $t1
329 LDu $f24, $f25, 12*8, $a1, $t1
330 LDu $f26, $f27, 13*8, $a1, $t1
331 LDu $f28, $f29, 14*8, $a1, $t1
332 LDu $f30, $f31, 15*8, $a1, $t1
333
Chris Dearman748dd952014-05-23 10:47:01 -0700334 .set push
335 .set nomacro
336 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700337 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700338 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700339 lw $v0, 8($a0)
340 lw $v1, 12($a0)
341 lw $a1, 20($a0)
342 lw $a2, 24($a0)
343 lw $a3, 28($a0)
344 lw $t0, 32($a0)
345 lw $t1, 36($a0)
346 lw $t2, 40($a0)
347 lw $t3, 44($a0)
348 lw $t4, 48($a0)
349 lw $t5, 52($a0)
350 lw $t6, 56($a0)
351 lw $t7, 60($a0)
352 lw $s0, 64($a0)
353 lw $s1, 68($a0)
354 lw $s2, 72($a0)
355 lw $s3, 76($a0)
356 lw $s4, 80($a0)
357 lw $s5, 84($a0)
358 lw $s6, 88($a0)
359 lw $s7, 92($a0)
360 lw $t8, 96($a0)
361 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700362 lw $gp, 112($a0)
363 lw $sp, 116($a0)
364 lw $fp, 120($a0)
365 lw $ra, 124($a0)
366 lw $a0, 16($a0)
367 move $v0, $zero # clear result registers r0 and r1
368 jr $ra # do long jump
369 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800370END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800371
buzbee5bc5a7b2012-03-07 15:52:59 -0800372 /*
373 * Called by managed code, saves most registers (forms basis of long jump context) and passes
374 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
375 * the bottom of the thread. On entry r0 holds Throwable*
376 */
Ian Rogers468532e2013-08-05 10:56:33 -0700377ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700378 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700379 la $t9, artDeliverExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700380 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
381 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700382END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800383
buzbee5bc5a7b2012-03-07 15:52:59 -0800384 /*
385 * Called by managed code to create and deliver a NullPointerException
386 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800387 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700388ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700389 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700390 la $t9, artThrowNullPointerExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700391 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*)
392 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700393END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800394
buzbee5bc5a7b2012-03-07 15:52:59 -0800395 /*
396 * Called by managed code to create and deliver an ArithmeticException
397 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800398 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700399ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700400 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700401 la $t9, artThrowDivZeroFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700402 jr $t9 # artThrowDivZeroFromCode(Thread*)
403 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700404END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800405
buzbee5bc5a7b2012-03-07 15:52:59 -0800406 /*
407 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
408 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800409 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700410ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700411 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700412 la $t9, artThrowArrayBoundsFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700413 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
414 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700415END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800416
Ian Rogers57b86d42012-03-27 16:05:41 -0700417 /*
418 * Called by managed code to create and deliver a StackOverflowError.
419 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800420 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700421ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700422 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700423 la $t9, artThrowStackOverflowFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700424 jr $t9 # artThrowStackOverflowFromCode(Thread*)
425 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700426END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800427
Ian Rogers57b86d42012-03-27 16:05:41 -0700428 /*
429 * Called by managed code to create and deliver a NoSuchMethodError.
430 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800431 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700432ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700433 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700434 la $t9, artThrowNoSuchMethodFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700435 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
436 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700437END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800438
buzbee5bc5a7b2012-03-07 15:52:59 -0800439 /*
440 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700441 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800442 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
443 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700444 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800445 *
jeffhao7fbee072012-08-24 17:56:54 -0700446 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
447 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800448 *
jeffhaofa147e22012-10-12 17:03:32 -0700449 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800450 * thread and we branch to another stub to deliver it.
451 *
452 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
453 * pointing back to the original caller.
454 */
455.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800456 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800457ENTRY \c_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700458 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Douglas Leung735b8552014-10-31 12:21:40 -0700459 lw $a2, FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE+ARG_SLOT_SIZE($sp) # pass caller Method*
460 addiu $t0, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -0700461 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700462 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700463 sw $t0, 16($sp) # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700464 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700465 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700466 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -0700467 move $t9, $v1 # save $v0->code_
jeffhao30a33172012-10-22 18:16:22 -0700468 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800469 nop
4701:
471 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800472END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800473.endm
474
Logan Chien8dbb7082013-01-25 20:31:17 +0800475INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
476INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800477
Logan Chien8dbb7082013-01-25 20:31:17 +0800478INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
479INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
480INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
481INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800482
Jeff Hao79fe5392013-04-24 18:41:58 -0700483 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800484 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800485 * On entry:
486 * a0 = method pointer
487 * a1 = argument array or NULL for no argument methods
488 * a2 = size of argument array in bytes
489 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700490 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800491 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800492 */
493ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800494 sw $a0, 0($sp) # save out a0
495 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
496 .cfi_adjust_cfa_offset 16
497 sw $ra, 12($sp)
498 .cfi_rel_offset 31, 12
499 sw $fp, 8($sp)
500 .cfi_rel_offset 30, 8
501 sw $s1, 4($sp)
502 .cfi_rel_offset 17, 4
503 sw $s0, 0($sp)
504 .cfi_rel_offset 16, 0
505 move $fp, $sp # save sp in fp
506 .cfi_def_cfa_register 30
507 move $s1, $a3 # move managed thread pointer into s1
508 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Douglas Leung735b8552014-10-31 12:21:40 -0700509 addiu $t0, $a2, 4 # create space for method pointer in frame.
510 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
511 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
512 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
Jeff Hao5d917302013-02-27 17:57:33 -0800513 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
514 jal memcpy # (dest, src, bytes)
515 addiu $sp, $sp, -16 # make space for argument slots for memcpy
516 addiu $sp, $sp, 16 # restore stack after memcpy
517 lw $a0, 16($fp) # restore method*
518 lw $a1, 4($sp) # copy arg value for a1
519 lw $a2, 8($sp) # copy arg value for a2
520 lw $a3, 12($sp) # copy arg value for a3
Mathieu Chartier2d721012014-11-10 11:08:06 -0800521 lw $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800522 jalr $t9 # call the method
523 sw $zero, 0($sp) # store NULL for method* at bottom of frame
524 move $sp, $fp # restore the stack
525 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800526 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800527 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800528 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800529 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800530 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800531 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800532 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800533 addiu $sp, $sp, 16
534 .cfi_adjust_cfa_offset -16
535 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800536 lw $t1, 20($sp) # get shorty
537 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700538 li $t2, 68 # put char 'D' into t2
539 beq $t1, $t2, 1f # branch if result type char == 'D'
540 li $t3, 70 # put char 'F' into t3
541 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800542 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700543 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800544 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005451:
Duane Sande34652f2014-11-04 11:09:36 -0800546 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800547 jr $ra
Duane Sande34652f2014-11-04 11:09:36 -0800548 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800549END art_quick_invoke_stub
550
551 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800552 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
553 * failure.
554 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800555 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700556ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -0700557 lw $a2, 0($sp) # pass referrer's Method*
558 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700559 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700560 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700561 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700562END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800563
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700565 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800566 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800567 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700568ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800569 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700570 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700571 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700572 jal artLockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700573 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700574 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700575END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800576
buzbee5bc5a7b2012-03-07 15:52:59 -0800577 /*
578 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
579 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800580 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700581ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800582 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700583 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700584 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700585 jal artUnlockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700586 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800587 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700588END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800589
buzbee5bc5a7b2012-03-07 15:52:59 -0800590 /*
591 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
592 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700593 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700594ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700595 addiu $sp, $sp, -16
596 .cfi_adjust_cfa_offset 16
597 sw $ra, 12($sp)
598 .cfi_rel_offset 31, 12
599 sw $t9, 8($sp)
600 sw $a1, 4($sp)
601 sw $a0, 0($sp)
602 jal artIsAssignableFromCode
Douglas Leung735b8552014-10-31 12:21:40 -0700603 addiu $sp, $sp, -16 # reserve argument slots on the stack
604 addiu $sp, $sp, 16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800605 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700606 lw $ra, 12($sp)
607 jr $ra
608 addiu $sp, $sp, 16
609 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800610.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700611 lw $t9, 8($sp)
612 lw $a1, 4($sp)
613 lw $a0, 0($sp)
614 addiu $sp, $sp, 16
615 .cfi_adjust_cfa_offset -16
616 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700617 la $t9, artThrowClassCastException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700618 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*)
619 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700620END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800621
buzbee5bc5a7b2012-03-07 15:52:59 -0800622 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700623 * Entry from managed code for array put operations of objects where the value being stored
624 * needs to be checked for compatibility.
625 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800626 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700627ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800628 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700629 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800630 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700631 nop
632END art_quick_aput_obj_with_null_and_bound_check
633
634ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700635 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700636 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800637 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700638 nop
639 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800640 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700641 move $a1, $t0
642END art_quick_aput_obj_with_bound_check
643
644ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800645 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700646 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700647 lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
648 lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
649 lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800650 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700651 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800652.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700653 sll $a1, $a1, 2
654 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700655 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700656 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
657 srl $t1, $a0, 7
658 add $t1, $t1, $t0
659 sb $t0, ($t1)
660 jr $ra
661 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800662.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700663 sll $a1, $a1, 2
664 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700665 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700666 jr $ra
667 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800668.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700669 addiu $sp, $sp, -32
670 .cfi_adjust_cfa_offset 32
671 sw $ra, 28($sp)
672 .cfi_rel_offset 31, 28
673 sw $t9, 12($sp)
674 sw $a2, 8($sp)
675 sw $a1, 4($sp)
676 sw $a0, 0($sp)
677 move $a1, $t1
678 move $a0, $t0
679 jal artIsAssignableFromCode # (Class*, Class*)
Douglas Leung735b8552014-10-31 12:21:40 -0700680 addiu $sp, $sp, -16 # reserve argument slots on the stack
681 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -0700682 lw $ra, 28($sp)
683 lw $t9, 12($sp)
684 lw $a2, 8($sp)
685 lw $a1, 4($sp)
686 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -0800687 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -0700688 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800689 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700690 nop
691 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
692 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -0700693 la $t9, artThrowArrayStoreException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700694 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
695 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -0700696END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800697
buzbee5bc5a7b2012-03-07 15:52:59 -0800698 /*
699 * Entry from managed code when uninitialized static storage, this stub will run the class
700 * initializer and deliver the exception on error. On success the static storage base is
701 * returned.
702 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800703 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700704ENTRY art_quick_initialize_static_storage
Douglas Leung735b8552014-10-31 12:21:40 -0700705 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700706 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800707 jal artInitializeStaticStorageFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700708 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800709 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700710END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800711
buzbee5bc5a7b2012-03-07 15:52:59 -0800712 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700713 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800714 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800715 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700716ENTRY art_quick_initialize_type
Douglas Leung735b8552014-10-31 12:21:40 -0700717 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700718 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800719 jal artInitializeTypeFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700720 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800721 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700722END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800723
buzbee5bc5a7b2012-03-07 15:52:59 -0800724 /*
725 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
Ian Rogers57b86d42012-03-27 16:05:41 -0700726 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800727 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800728 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700729ENTRY art_quick_initialize_type_and_verify_access
Douglas Leung735b8552014-10-31 12:21:40 -0700730 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700731 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800732 jal artInitializeTypeAndVerifyAccessFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700733 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800734 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700735END art_quick_initialize_type_and_verify_access
Fred Shih37f05ef2014-07-16 18:38:08 -0700736 /*
737 * Called by managed code to resolve a static field and load a boolean primitive value.
738 */
739 .extern artGetBooleanStaticFromCode
740ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -0700741 lw $a1, 0($sp) # pass referrer's Method*
742 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700743 jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700744 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700745 RETURN_IF_NO_EXCEPTION
746END art_quick_get_boolean_static
747 /*
748 * Called by managed code to resolve a static field and load a byte primitive value.
749 */
750 .extern artGetByteStaticFromCode
751ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -0700752 lw $a1, 0($sp) # pass referrer's Method*
753 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700754 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700755 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700756 RETURN_IF_NO_EXCEPTION
757END art_quick_get_byte_static
758
759 /*
760 * Called by managed code to resolve a static field and load a char primitive value.
761 */
762 .extern artGetCharStaticFromCode
763ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -0700764 lw $a1, 0($sp) # pass referrer's Method*
765 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700766 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700767 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700768 RETURN_IF_NO_EXCEPTION
769END art_quick_get_char_static
770 /*
771 * Called by managed code to resolve a static field and load a short primitive value.
772 */
773 .extern artGetShortStaticFromCode
774ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -0700775 lw $a1, 0($sp) # pass referrer's Method*
776 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700777 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700778 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700779 RETURN_IF_NO_EXCEPTION
780END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800781
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700783 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800784 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800785 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700786ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700787 lw $a1, 0($sp) # pass referrer's Method*
788 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700789 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700790 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800791 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700792END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800793
buzbee5bc5a7b2012-03-07 15:52:59 -0800794 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700795 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800797 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700798ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700799 lw $a1, 0($sp) # pass referrer's Method*
800 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700801 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700802 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800803 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700804END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800805
buzbee5bc5a7b2012-03-07 15:52:59 -0800806 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700807 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800808 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800809 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700810ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700811 lw $a1, 0($sp) # pass referrer's Method*
812 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700813 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700814 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800815 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700816END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800817
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700819 * Called by managed code to resolve an instance field and load a boolean primitive value.
820 */
821 .extern artGetBooleanInstanceFromCode
822ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700823 lw $a2, 0($sp) # pass referrer's Method*
824 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700825 jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700826 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700827 RETURN_IF_NO_EXCEPTION
828END art_quick_get_boolean_instance
829 /*
830 * Called by managed code to resolve an instance field and load a byte primitive value.
831 */
832 .extern artGetByteInstanceFromCode
833ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700834 lw $a2, 0($sp) # pass referrer's Method*
835 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700836 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700837 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700838 RETURN_IF_NO_EXCEPTION
839END art_quick_get_byte_instance
840
841 /*
842 * Called by managed code to resolve an instance field and load a char primitive value.
843 */
844 .extern artGetCharInstanceFromCode
845ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700846 lw $a2, 0($sp) # pass referrer's Method*
847 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700848 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700849 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700850 RETURN_IF_NO_EXCEPTION
851END art_quick_get_char_instance
852 /*
853 * Called by managed code to resolve an instance field and load a short primitive value.
854 */
855 .extern artGetShortInstanceFromCode
856ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700857 lw $a2, 0($sp) # pass referrer's Method*
858 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
859 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700860 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700861 RETURN_IF_NO_EXCEPTION
862END art_quick_get_short_instance
863
864 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700865 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800867 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700868ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700869 lw $a2, 0($sp) # pass referrer's Method*
870 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
871 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700872 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800873 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700874END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800875
buzbee5bc5a7b2012-03-07 15:52:59 -0800876 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700877 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800878 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800879 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700880ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700881 lw $a2, 0($sp) # pass referrer's Method*
882 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
883 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700884 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800885 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700886END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800887
buzbee5bc5a7b2012-03-07 15:52:59 -0800888 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700889 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800890 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800891 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700892ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700893 lw $a2, 0($sp) # pass referrer's Method*
894 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700895 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700896 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800897 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700898END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800899
buzbee5bc5a7b2012-03-07 15:52:59 -0800900 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700901 * Called by managed code to resolve a static field and store a 8-bit primitive value.
902 */
903 .extern artSet8StaticFromCode
904ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -0700905 lw $a2, 0($sp) # pass referrer's Method*
906 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700907 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700908 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700909 RETURN_IF_ZERO
910END art_quick_set8_static
911
912 /*
913 * Called by managed code to resolve a static field and store a 16-bit primitive value.
914 */
915 .extern artSet16StaticFromCode
916ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -0700917 lw $a2, 0($sp) # pass referrer's Method*
918 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Fred Shih37f05ef2014-07-16 18:38:08 -0700919 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700920 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700921 RETURN_IF_ZERO
922END art_quick_set16_static
923
924 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700925 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800926 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800927 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700928ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700929 lw $a2, 0($sp) # pass referrer's Method*
930 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700931 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700932 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800933 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700934END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800935
buzbee5bc5a7b2012-03-07 15:52:59 -0800936 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700937 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800938 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700939 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700940ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700941 lw $a1, 0($sp) # pass referrer's Method*
942 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700943 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700944 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800945 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700946END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800947
buzbee5bc5a7b2012-03-07 15:52:59 -0800948 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700949 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800950 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800951 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700952ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700953 lw $a2, 0($sp) # pass referrer's Method*
954 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao7fbee072012-08-24 17:56:54 -0700955 move $a3, rSELF # pass Thread::Current
Douglas Leung735b8552014-10-31 12:21:40 -0700956 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800957 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700958END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800959
buzbee5bc5a7b2012-03-07 15:52:59 -0800960 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700961 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
962 */
963 .extern artSet8InstanceFromCode
964ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700965 lw $a3, 0($sp) # pass referrer's Method*
966 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
967 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700968 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700969 RETURN_IF_ZERO
970END art_quick_set8_instance
971
972 /*
973 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
974 */
975 .extern artSet16InstanceFromCode
976ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700977 lw $a3, 0($sp) # pass referrer's Method*
978 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700979 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700980 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700981 RETURN_IF_ZERO
982END art_quick_set16_instance
983
984 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700985 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800986 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800987 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700988ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700989 lw $a3, 0($sp) # pass referrer's Method*
990 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700991 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700992 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800993 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700994END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800995
buzbee5bc5a7b2012-03-07 15:52:59 -0800996 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700997 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800998 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700999 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001000ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001001 lw $t1, 0($sp) # load referrer's Method*
1002 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001003 sw rSELF, 20($sp) # pass Thread::Current
1004 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001005 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001006 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001007END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001008
buzbee5bc5a7b2012-03-07 15:52:59 -08001009 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001010 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001011 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001012 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001013ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001014 lw $a3, 0($sp) # pass referrer's Method*
1015 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001016 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001017 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001018 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001019END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001020
buzbee5bc5a7b2012-03-07 15:52:59 -08001021 /*
1022 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1023 * exception on error. On success the String is returned. R0 holds the referring method,
1024 * R1 holds the string index. The fast path check for hit in strings cache has already been
1025 * performed.
1026 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001027 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001028ENTRY art_quick_resolve_string
Douglas Leung735b8552014-10-31 12:21:40 -07001029 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001030 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -08001031 jal artResolveStringFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001032 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001033 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001034END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -08001035
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001036
1037// Macro to facilitate adding new allocation entrypoints.
1038.macro TWO_ARG_DOWNCALL name, entrypoint, return
1039 .extern \entrypoint
1040ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001041 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001042 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001043 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001044 \return
1045END \name
1046.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001047
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001048.macro THREE_ARG_DOWNCALL name, entrypoint, return
1049 .extern \entrypoint
1050ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001051 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001052 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001053 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001054 \return
1055END \name
1056.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001057
Mathieu Chartier7410f292013-11-24 13:17:35 -08001058// Generate the allocation entrypoints for each allocator.
1059GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001060
buzbee5bc5a7b2012-03-07 15:52:59 -08001061 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001062 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001063 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001064 .extern artTestSuspendFromCode
1065ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001066 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001067 bnez $a0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001068 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
jeffhao7fbee072012-08-24 17:56:54 -07001069 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001070 nop
10711:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001072 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1073 jal artTestSuspendFromCode # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001074 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001075 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001076END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001077
buzbee5bc5a7b2012-03-07 15:52:59 -08001078 /*
1079 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001080 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001081 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001082 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001083ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001084 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1085 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001086 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001087 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001088 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001089 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001090 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001091 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1092 MTD $v0, $v1, $f0, $f1 # move float value to return value
jeffhao7fbee072012-08-24 17:56:54 -07001093 jr $ra
Duane Sande34652f2014-11-04 11:09:36 -08001094 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080010951:
1096 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001097END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001098
Jeff Hao88474b42013-10-23 16:24:40 -07001099 /*
1100 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1101 * dex method index.
1102 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001103ENTRY art_quick_imt_conflict_trampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001104 lw $a0, 0($sp) # load caller Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001105 lw $a0, MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
Jeff Hao88474b42013-10-23 16:24:40 -07001106 sll $t0, 2 # convert target method offset to bytes
1107 add $a0, $t0 # get address of target method
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001108 lw $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
Jeff Hao88474b42013-10-23 16:24:40 -07001109 la $t9, art_quick_invoke_interface_trampoline
1110 jr $t9
1111END art_quick_imt_conflict_trampoline
1112
Ian Rogers468532e2013-08-05 10:56:33 -07001113 .extern artQuickResolutionTrampoline
1114ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001115 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001116 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001117 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001118 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001119 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001120 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001121 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001122 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001123 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001124 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011251:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001126 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001127 DELIVER_PENDING_EXCEPTION
1128END art_quick_resolution_trampoline
1129
Douglas Leung735b8552014-10-31 12:21:40 -07001130 .extern artQuickGenericJniTrampoline
1131 .extern artQuickGenericJniEndTrampoline
1132ENTRY art_quick_generic_jni_trampoline
1133 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1134 move $s8, $sp # save $sp to $s8
1135 move $s3, $gp # save $gp to $s3
1136
1137 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1138 move $a0, rSELF # pass Thread::Current
1139 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
1140 jal artQuickGenericJniTrampoline # (Thread*, SP)
1141 addiu $sp, $sp, -5120 # reserve space on the stack
1142
1143 # The C call will have registered the complete save-frame on success.
1144 # The result of the call is:
1145 # v0: ptr to native code, 0 on error.
1146 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1147 beq $v0, $zero, 1f # check entry error
1148 move $t9, $v0 # save the code ptr
1149 move $sp, $v1 # release part of the alloca
1150
1151 # Load parameters from stack into registers
1152 lw $a0, 0($sp)
1153 lw $a1, 4($sp)
1154 lw $a2, 8($sp)
1155
1156 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1157 jalr $t9 # native call
1158 lw $a3, 12($sp)
1159 addiu $sp, $sp, 16 # remove arg slots
1160
1161 move $gp, $s3 # restore $gp from $s3
1162
1163 # result sign extension is handled in C code
1164 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1165 move $a0, rSELF # pass Thread::Current
1166 move $a2, $v0 # pass result
1167 move $a3, $v1
1168 addiu $sp, $sp, -24 # reserve arg slots
1169 jal artQuickGenericJniEndTrampoline
1170 s.d $f0, 16($sp) # pass result_f
1171 addiu $sp, $sp, 24 # remove arg slots
1172
1173 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1174 bne $t0, $zero, 2f # check for pending exceptions
1175 move $sp, $s8 # tear down the alloca
1176
1177 # tear dpown the callee-save frame
1178 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1179
Duane Sande34652f2014-11-04 11:09:36 -08001180 MTD $v0, $v1, $f0, $f1 # move float value to return value
Douglas Leung735b8552014-10-31 12:21:40 -07001181 jr $ra
Duane Sande34652f2014-11-04 11:09:36 -08001182 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001183
11841:
1185 move $sp, $s8 # tear down the alloca
11862:
1187 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1188 DELIVER_PENDING_EXCEPTION
1189END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001190
Ian Rogers468532e2013-08-05 10:56:33 -07001191 .extern artQuickToInterpreterBridge
1192ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001193 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001194 move $a1, rSELF # pass Thread::Current
1195 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
1196 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08001197 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001198 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001199 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001200 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1201 MTD $v0, $v1, $f0, $f1 # move float value to return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001202 jr $ra
Duane Sande34652f2014-11-04 11:09:36 -08001203 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080012041:
1205 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001206END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001207
buzbee5bc5a7b2012-03-07 15:52:59 -08001208 /*
jeffhao725a9572012-11-13 18:20:12 -08001209 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001210 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001211 .extern artInstrumentationMethodEntryFromCode
1212 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001213ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001214 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001215 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001216 move $a3, $ra # pass $ra
1217 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001218 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001219 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07001220 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001221 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001222 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001223 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001224END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001225 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001226 .global art_quick_instrumentation_exit
1227art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001228 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001229 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001230 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001231 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07001232
1233 addiu $sp, $sp, -16 # allocate temp storage on the stack
1234 .cfi_adjust_cfa_offset 16
1235 sw $v0, 12($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001236 .cfi_rel_offset 2, 32
Douglas Leung735b8552014-10-31 12:21:40 -07001237 sw $v1, 8($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001238 .cfi_rel_offset 3, 36
1239 s.d $f0, 0($sp)
Douglas Leung735b8552014-10-31 12:21:40 -07001240 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Duane Sande34652f2014-11-04 11:09:36 -08001241 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08001242 move $a2, $v0 # pass gpr result
1243 move $a3, $v1
Douglas Leung735b8552014-10-31 12:21:40 -07001244 addiu $a1, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers62d6c772013-02-27 08:32:07 -08001245 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001246 move $a0, rSELF # pass Thread::Current
1247 move $t0, $v0 # set aside returned link register
1248 move $ra, $v1 # set link register for deoptimization
Douglas Leung735b8552014-10-31 12:21:40 -07001249 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE # args slot + refs_only callee save frame
1250 lw $v0, 12($sp) # restore return values
1251 lw $v1, 8($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001252 l.d $f0, 0($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001253 jr $t0 # return
Douglas Leung735b8552014-10-31 12:21:40 -07001254 addiu $sp, $sp, 16 # remove temp storage from stack
1255 .cfi_adjust_cfa_offset -16
Ian Rogers468532e2013-08-05 10:56:33 -07001256END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001257
jeffhao12051ea2013-01-10 11:24:31 -08001258 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001259 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1260 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001261 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001262 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001263ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001264 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001265 jal artDeoptimize # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001266 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001267 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001268END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001269
buzbee5bc5a7b2012-03-07 15:52:59 -08001270 /*
1271 * Long integer shift. This is different from the generic 32/64-bit
1272 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1273 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1274 * 6 bits.
1275 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001276 * $a0: low word
1277 * $a1: high word
1278 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001279 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001280ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001281 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001282 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1283 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1284 srl $a0, 1
1285 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1286 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001287 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001288 beqz $a2, 1f
1289 or $v1, $a0 # rhi<- rhi | alo
1290
1291 move $v1, $v0 # rhi<- rlo (if shift&0x20)
1292 move $v0, $zero # rlo<- 0 (if shift&0x20)
1293
12941: jr $ra
1295 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001296END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001297
buzbee5bc5a7b2012-03-07 15:52:59 -08001298 /*
1299 * Long integer shift. This is different from the generic 32/64-bit
1300 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1301 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1302 * 6 bits.
1303 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001304 * $a0: low word
1305 * $a1: high word
1306 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001307 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001308ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001309 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1310 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1311 sra $a3, $a1, 31 # $a3<- sign(ah)
1312 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1313 sll $a1, 1
1314 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001315 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08001316 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001317 or $v0, $a1 # rlo<- rlo | ahi
1318
1319 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1320 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
1321
13221: jr $ra
1323 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001324END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001325
buzbee5bc5a7b2012-03-07 15:52:59 -08001326 /*
1327 * Long integer shift. This is different from the generic 32/64-bit
1328 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1329 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1330 * 6 bits.
1331 * On entry:
1332 * r0: low word
1333 * r1: high word
1334 * r2: shift count
1335 */
1336 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001337ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001338 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001339 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001340 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1341 sll $a1, 1
1342 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001343 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001344 beqz $a2, 1f
1345 or $v0, $a1 # rlo<- rlo | ahi
1346
1347 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1348 move $v1, $zero # rhi<- 0 (if shift&0x20)
1349
13501: jr $ra
1351 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001352END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001353
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001354UNIMPLEMENTED art_quick_indexof
1355UNIMPLEMENTED art_quick_string_compareto