blob: 609c65a38f59f6e9448c6cca91958e3ca89a5cc9 [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
29 /*
30 * Macro that sets up the callee save frame to conform with
31 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070032 * callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080033 */
Ian Rogers57b86d42012-03-27 16:05:41 -070034.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -070035 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080036 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -070037
38 // Ugly compile-time check, but we only have the preprocessor.
39#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 64)
40#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
41#endif
42
jeffhaofa147e22012-10-12 17:03:32 -070043 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080044 .cfi_rel_offset 31, 60
jeffhaofa147e22012-10-12 17:03:32 -070045 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080046 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070047 sw $gp, 52($sp)
48 .cfi_rel_offset 28, 52
49 sw $s7, 48($sp)
50 .cfi_rel_offset 23, 48
51 sw $s6, 44($sp)
52 .cfi_rel_offset 22, 44
53 sw $s5, 40($sp)
54 .cfi_rel_offset 21, 40
55 sw $s4, 36($sp)
56 .cfi_rel_offset 20, 36
57 sw $s3, 32($sp)
58 .cfi_rel_offset 19, 32
59 sw $s2, 28($sp)
60 .cfi_rel_offset 18, 28
61 sw $s1, 24($sp)
62 .cfi_rel_offset 17, 24
63 sw $s0, 20($sp)
64 .cfi_rel_offset 16, 20
65 # 1 word for alignment, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080066.endm
67
68 /*
69 * Macro that sets up the callee save frame to conform with
70 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
71 * Does not include rSUSPEND or rSELF
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070072 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 3 words padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080073 */
74.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070075 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080076 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -070077
78 // Ugly compile-time check, but we only have the preprocessor.
79#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 64)
80#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
81#endif
82
jeffhao4eb68ed2012-10-17 16:41:07 -070083 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080084 .cfi_rel_offset 31, 60
jeffhao4eb68ed2012-10-17 16:41:07 -070085 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080086 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070087 sw $gp, 52($sp)
88 .cfi_rel_offset 28, 52
89 sw $s7, 48($sp)
90 .cfi_rel_offset 23, 48
91 sw $s6, 44($sp)
92 .cfi_rel_offset 22, 44
93 sw $s5, 40($sp)
94 .cfi_rel_offset 21, 40
95 sw $s4, 36($sp)
96 .cfi_rel_offset 20, 36
97 sw $s3, 32($sp)
98 .cfi_rel_offset 19, 32
99 sw $s2, 28($sp)
100 .cfi_rel_offset 18, 28
jeffhaofc6a30e2012-10-18 18:24:15 -0700101 # 3 words for alignment and extra args, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800102.endm
103
104.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -0700105 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800106 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700107 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800108 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700109 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800110 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700111 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800112 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700113 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800114 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700115 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800116 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700117 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800118 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700119 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800120 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700121 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800122 .cfi_restore 18
jeffhao4eb68ed2012-10-17 16:41:07 -0700123 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800124 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800125.endm
126
127.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -0700128 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800129 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700130 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800131 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700132 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800133 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700134 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800135 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700136 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800137 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700138 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800139 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700140 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800141 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700142 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800143 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700144 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800145 .cfi_restore 18
jeffhao7fbee072012-08-24 17:56:54 -0700146 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700147 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800148 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800149.endm
150
151 /*
152 * Macro that sets up the callee save frame to conform with
153 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700154 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800155 */
156.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700157 addiu $sp, $sp, -64
158 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700159
160 // Ugly compile-time check, but we only have the preprocessor.
161#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
162#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
163#endif
164
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700165 sw $ra, 60($sp)
166 .cfi_rel_offset 31, 60
167 sw $s8, 56($sp)
168 .cfi_rel_offset 30, 56
169 sw $gp, 52($sp)
170 .cfi_rel_offset 28, 52
171 sw $s7, 48($sp)
172 .cfi_rel_offset 23, 48
173 sw $s6, 44($sp)
174 .cfi_rel_offset 22, 44
175 sw $s5, 40($sp)
176 .cfi_rel_offset 21, 40
177 sw $s4, 36($sp)
178 .cfi_rel_offset 20, 36
179 sw $s3, 32($sp)
180 .cfi_rel_offset 19, 32
181 sw $s2, 28($sp)
182 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700183 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800184 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700185 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800186 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700187 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800188 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700189 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800190.endm
191
192.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700193 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800194 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700195 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800196 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700197 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800198 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700199 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800200 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700201 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800202 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700203 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800204 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700205 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800206 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700207 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800208 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700209 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800210 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700211 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800212 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700213 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800214 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700215 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800216 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700217 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700218 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800219.endm
220
221 /*
222 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
223 * exception is Thread::Current()->exception_
224 */
225.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700226 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
227 move $a0, rSELF # pass Thread::Current
228 la $t9, artDeliverPendingExceptionFromCode
229 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
230 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800231.endm
232
233.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700234 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800235 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700236 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800237 nop
jeffhao7fbee072012-08-24 17:56:54 -0700238 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800239 nop
2401:
241 DELIVER_PENDING_EXCEPTION
242.endm
243
244.macro RETURN_IF_ZERO
245 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700246 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800247 nop
jeffhao7fbee072012-08-24 17:56:54 -0700248 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800249 nop
2501:
251 DELIVER_PENDING_EXCEPTION
252.endm
253
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800254.macro RETURN_IF_RESULT_IS_NON_ZERO
buzbee5bc5a7b2012-03-07 15:52:59 -0800255 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700256 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800257 nop
jeffhao7fbee072012-08-24 17:56:54 -0700258 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800259 nop
2601:
261 DELIVER_PENDING_EXCEPTION
262.endm
263
buzbee5bc5a7b2012-03-07 15:52:59 -0800264 /*
jeffhao7fbee072012-08-24 17:56:54 -0700265 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800266 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
267 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800268ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700269 l.s $f0, 0($a1)
270 l.s $f1, 4($a1)
271 l.s $f2, 8($a1)
272 l.s $f3, 12($a1)
273 l.s $f4, 16($a1)
274 l.s $f5, 20($a1)
275 l.s $f6, 24($a1)
276 l.s $f7, 28($a1)
277 l.s $f8, 32($a1)
278 l.s $f9, 36($a1)
279 l.s $f10, 40($a1)
280 l.s $f11, 44($a1)
281 l.s $f12, 48($a1)
282 l.s $f13, 52($a1)
283 l.s $f14, 56($a1)
284 l.s $f15, 60($a1)
285 l.s $f16, 64($a1)
286 l.s $f17, 68($a1)
287 l.s $f18, 72($a1)
288 l.s $f19, 76($a1)
289 l.s $f20, 80($a1)
290 l.s $f21, 84($a1)
291 l.s $f22, 88($a1)
292 l.s $f23, 92($a1)
293 l.s $f24, 96($a1)
294 l.s $f25, 100($a1)
295 l.s $f26, 104($a1)
296 l.s $f27, 108($a1)
297 l.s $f28, 112($a1)
298 l.s $f29, 116($a1)
299 l.s $f30, 120($a1)
300 l.s $f31, 124($a1)
Chris Dearman748dd952014-05-23 10:47:01 -0700301 .set push
302 .set nomacro
303 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700304 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700305 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700306 lw $v0, 8($a0)
307 lw $v1, 12($a0)
308 lw $a1, 20($a0)
309 lw $a2, 24($a0)
310 lw $a3, 28($a0)
311 lw $t0, 32($a0)
312 lw $t1, 36($a0)
313 lw $t2, 40($a0)
314 lw $t3, 44($a0)
315 lw $t4, 48($a0)
316 lw $t5, 52($a0)
317 lw $t6, 56($a0)
318 lw $t7, 60($a0)
319 lw $s0, 64($a0)
320 lw $s1, 68($a0)
321 lw $s2, 72($a0)
322 lw $s3, 76($a0)
323 lw $s4, 80($a0)
324 lw $s5, 84($a0)
325 lw $s6, 88($a0)
326 lw $s7, 92($a0)
327 lw $t8, 96($a0)
328 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700329 lw $gp, 112($a0)
330 lw $sp, 116($a0)
331 lw $fp, 120($a0)
332 lw $ra, 124($a0)
333 lw $a0, 16($a0)
334 move $v0, $zero # clear result registers r0 and r1
335 jr $ra # do long jump
336 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800337END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800338
buzbee5bc5a7b2012-03-07 15:52:59 -0800339 /*
340 * Called by managed code, saves most registers (forms basis of long jump context) and passes
341 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
342 * the bottom of the thread. On entry r0 holds Throwable*
343 */
Ian Rogers468532e2013-08-05 10:56:33 -0700344ENTRY art_quick_deliver_exception
jeffhao12051ea2013-01-10 11:24:31 -0800345 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700346 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700347 move $a1, rSELF # pass Thread::Current
348 la $t9, artDeliverExceptionFromCode
349 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
350 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700351END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800352
buzbee5bc5a7b2012-03-07 15:52:59 -0800353 /*
354 * Called by managed code to create and deliver a NullPointerException
355 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800356 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700357ENTRY art_quick_throw_null_pointer_exception
jeffhao12051ea2013-01-10 11:24:31 -0800358 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800359.Lart_quick_throw_null_pointer_exception_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700360 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700361 move $a0, rSELF # pass Thread::Current
362 la $t9, artThrowNullPointerExceptionFromCode
363 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
364 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700365END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800366
buzbee5bc5a7b2012-03-07 15:52:59 -0800367 /*
368 * Called by managed code to create and deliver an ArithmeticException
369 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800370 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700371ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800372 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700373 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700374 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700375 la $t9, artThrowDivZeroFromCode
376 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700377 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700378END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800379
buzbee5bc5a7b2012-03-07 15:52:59 -0800380 /*
381 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
382 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800383 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700384ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800385 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800386.Lart_quick_throw_array_bounds_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700387 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700388 move $a2, rSELF # pass Thread::Current
389 la $t9, artThrowArrayBoundsFromCode
390 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
391 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700392END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800393
Ian Rogers57b86d42012-03-27 16:05:41 -0700394 /*
395 * Called by managed code to create and deliver a StackOverflowError.
396 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800397 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700398ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800399 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700400 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700401 move $a0, rSELF # pass Thread::Current
402 la $t9, artThrowStackOverflowFromCode
403 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
404 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700405END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800406
Ian Rogers57b86d42012-03-27 16:05:41 -0700407 /*
408 * Called by managed code to create and deliver a NoSuchMethodError.
409 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800410 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700411ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800412 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700413 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700414 move $a1, rSELF # pass Thread::Current
415 la $t9, artThrowNoSuchMethodFromCode
416 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
417 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700418END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800419
buzbee5bc5a7b2012-03-07 15:52:59 -0800420 /*
421 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700422 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800423 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
424 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700425 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800426 *
jeffhao7fbee072012-08-24 17:56:54 -0700427 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
428 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800429 *
jeffhaofa147e22012-10-12 17:03:32 -0700430 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800431 * thread and we branch to another stub to deliver it.
432 *
433 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
434 * pointing back to the original caller.
435 */
436.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800437 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800438ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800439 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700440 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700441 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700442 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700443 addiu $sp, $sp, -32 # make space for extra args
444 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700445 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800446 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700447 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700448 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700449 addiu $sp, $sp, 32 # release out args
450 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700451 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700452 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800453 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700454 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800455 nop
jeffhao30a33172012-10-22 18:16:22 -0700456 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800457 nop
4581:
459 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800460END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800461.endm
462
Logan Chien8dbb7082013-01-25 20:31:17 +0800463INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
464INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800465
Logan Chien8dbb7082013-01-25 20:31:17 +0800466INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
467INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
468INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
469INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800470
Jeff Hao79fe5392013-04-24 18:41:58 -0700471 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800472 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800473 * On entry:
474 * a0 = method pointer
475 * a1 = argument array or NULL for no argument methods
476 * a2 = size of argument array in bytes
477 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700478 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800479 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800480 */
481ENTRY art_quick_invoke_stub
482 GENERATE_GLOBAL_POINTER
483 sw $a0, 0($sp) # save out a0
484 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
485 .cfi_adjust_cfa_offset 16
486 sw $ra, 12($sp)
487 .cfi_rel_offset 31, 12
488 sw $fp, 8($sp)
489 .cfi_rel_offset 30, 8
490 sw $s1, 4($sp)
491 .cfi_rel_offset 17, 4
492 sw $s0, 0($sp)
493 .cfi_rel_offset 16, 0
494 move $fp, $sp # save sp in fp
495 .cfi_def_cfa_register 30
496 move $s1, $a3 # move managed thread pointer into s1
497 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
498 addiu $t0, $a2, 16 # create space for method pointer in frame
Douglas Leungb2649372014-06-02 17:45:54 -0700499 srl $t0, $t0, 4 # shift the frame size right 4
500 sll $t0, $t0, 4 # shift the frame size left 4 to align to 16 bytes
Jeff Hao5d917302013-02-27 17:57:33 -0800501 subu $sp, $sp, $t0 # reserve stack space for argument array
502 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
503 jal memcpy # (dest, src, bytes)
504 addiu $sp, $sp, -16 # make space for argument slots for memcpy
505 addiu $sp, $sp, 16 # restore stack after memcpy
506 lw $a0, 16($fp) # restore method*
507 lw $a1, 4($sp) # copy arg value for a1
508 lw $a2, 8($sp) # copy arg value for a2
509 lw $a3, 12($sp) # copy arg value for a3
Ian Rogersef7d42f2014-01-06 12:55:46 -0800510 lw $t9, METHOD_QUICK_CODE_OFFSET($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800511 jalr $t9 # call the method
512 sw $zero, 0($sp) # store NULL for method* at bottom of frame
513 move $sp, $fp # restore the stack
514 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800515 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800516 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800517 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800518 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800519 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800520 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800521 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800522 addiu $sp, $sp, 16
523 .cfi_adjust_cfa_offset -16
524 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800525 lw $t1, 20($sp) # get shorty
526 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700527 li $t2, 68 # put char 'D' into t2
528 beq $t1, $t2, 1f # branch if result type char == 'D'
529 li $t3, 70 # put char 'F' into t3
530 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800531 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700532 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800533 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005341:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700535 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800536 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700537 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800538END art_quick_invoke_stub
539
540 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800541 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
542 * failure.
543 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800544 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700545ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800546 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700547 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers832336b2014-10-08 15:35:22 -0700548 lw $a2, 64($sp) # pass referrer's Method*
549 move $a3, rSELF # pass Thread::Current
550 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*, $sp)
551 sw $sp, 16($sp) # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700552 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700553END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800554
buzbee5bc5a7b2012-03-07 15:52:59 -0800555 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700556 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800557 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800558 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700559ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800560 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800561 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700562 nop
jeffhao7fbee072012-08-24 17:56:54 -0700563 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
564 move $a1, rSELF # pass Thread::Current
565 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
566 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700567 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700568END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800569
buzbee5bc5a7b2012-03-07 15:52:59 -0800570 /*
571 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
572 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800573 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700574ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800575 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800576 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700577 nop
jeffhao7fbee072012-08-24 17:56:54 -0700578 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
579 move $a1, rSELF # pass Thread::Current
580 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
581 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800582 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700583END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800584
buzbee5bc5a7b2012-03-07 15:52:59 -0800585 /*
586 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
587 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700588 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700589ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800590 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700591 addiu $sp, $sp, -16
592 .cfi_adjust_cfa_offset 16
593 sw $ra, 12($sp)
594 .cfi_rel_offset 31, 12
595 sw $t9, 8($sp)
596 sw $a1, 4($sp)
597 sw $a0, 0($sp)
598 jal artIsAssignableFromCode
599 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800600 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700601 lw $ra, 12($sp)
602 jr $ra
603 addiu $sp, $sp, 16
604 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800605.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700606 lw $t9, 8($sp)
607 lw $a1, 4($sp)
608 lw $a0, 0($sp)
609 addiu $sp, $sp, 16
610 .cfi_adjust_cfa_offset -16
611 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
612 move $a2, rSELF # pass Thread::Current
613 la $t9, artThrowClassCastException
614 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
615 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700616END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800617
buzbee5bc5a7b2012-03-07 15:52:59 -0800618 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700619 * Entry from managed code for array put operations of objects where the value being stored
620 * needs to be checked for compatibility.
621 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800622 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700623ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800624 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800625 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700626 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800627 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700628 nop
629END art_quick_aput_obj_with_null_and_bound_check
630
631ENTRY art_quick_aput_obj_with_bound_check
632 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800633.Lart_quick_aput_obj_with_bound_check_gp_set:
Ian Rogersa9a82542013-10-04 11:17:26 -0700634 lw $t0, ARRAY_LENGTH_OFFSET($a0)
635 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800636 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700637 nop
638 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800639 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700640 move $a1, $t0
641END art_quick_aput_obj_with_bound_check
642
643ENTRY art_quick_aput_obj
644 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800645.Lart_quick_aput_obj_gp_set:
646 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700647 nop
648 lw $t0, CLASS_OFFSET($a0)
649 lw $t1, CLASS_OFFSET($a2)
650 lw $t0, CLASS_COMPONENT_TYPE_OFFSET($t0)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800651 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700652 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800653.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700654 sll $a1, $a1, 2
655 add $t0, $a0, $a1
656 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
657 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
658 srl $t1, $a0, 7
659 add $t1, $t1, $t0
660 sb $t0, ($t1)
661 jr $ra
662 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800663.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700664 sll $a1, $a1, 2
665 add $t0, $a0, $a1
666 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
667 jr $ra
668 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800669.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700670 addiu $sp, $sp, -32
671 .cfi_adjust_cfa_offset 32
672 sw $ra, 28($sp)
673 .cfi_rel_offset 31, 28
674 sw $t9, 12($sp)
675 sw $a2, 8($sp)
676 sw $a1, 4($sp)
677 sw $a0, 0($sp)
678 move $a1, $t1
679 move $a0, $t0
680 jal artIsAssignableFromCode # (Class*, Class*)
681 nop
682 lw $ra, 28($sp)
683 lw $t9, 12($sp)
684 lw $a2, 8($sp)
685 lw $a1, 4($sp)
686 lw $a0, 0($sp)
687 add $sp, 32
688 .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
693 move $a2, rSELF # pass Thread::Current
694 la $t9, artThrowArrayStoreException
695 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
696 move $a3, $sp # pass $sp
697END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800698
buzbee5bc5a7b2012-03-07 15:52:59 -0800699 /*
700 * Entry from managed code when uninitialized static storage, this stub will run the class
701 * initializer and deliver the exception on error. On success the static storage base is
702 * returned.
703 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800704 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700705ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800706 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700707 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
708 move $a2, rSELF # pass Thread::Current
709 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800710 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700711 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800712 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700713END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800714
buzbee5bc5a7b2012-03-07 15:52:59 -0800715 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700716 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800717 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800718 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700719ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800720 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700721 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
722 move $a2, rSELF # pass Thread::Current
723 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800724 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700725 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800726 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700727END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800728
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 /*
730 * 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 -0700731 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800732 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800733 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700734ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800735 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700736 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
737 move $a2, rSELF # pass Thread::Current
738 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800739 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700740 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800741 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700742END art_quick_initialize_type_and_verify_access
Fred Shih37f05ef2014-07-16 18:38:08 -0700743 /*
744 * Called by managed code to resolve a static field and load a boolean primitive value.
745 */
746 .extern artGetBooleanStaticFromCode
747ENTRY art_quick_get_boolean_static
748 GENERATE_GLOBAL_POINTER
749 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
750 lw $a1, 64($sp) # pass referrer's Method*
751 move $a2, rSELF # pass Thread::Current
752 jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
753 move $a3, $sp # pass $sp
754 RETURN_IF_NO_EXCEPTION
755END art_quick_get_boolean_static
756 /*
757 * Called by managed code to resolve a static field and load a byte primitive value.
758 */
759 .extern artGetByteStaticFromCode
760ENTRY art_quick_get_byte_static
761 GENERATE_GLOBAL_POINTER
762 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
763 lw $a1, 64($sp) # pass referrer's Method*
764 move $a2, rSELF # pass Thread::Current
765 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
766 move $a3, $sp # pass $sp
767 RETURN_IF_NO_EXCEPTION
768END art_quick_get_byte_static
769
770 /*
771 * Called by managed code to resolve a static field and load a char primitive value.
772 */
773 .extern artGetCharStaticFromCode
774ENTRY art_quick_get_char_static
775 GENERATE_GLOBAL_POINTER
776 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
777 lw $a1, 64($sp) # pass referrer's Method*
778 move $a2, rSELF # pass Thread::Current
779 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
780 move $a3, $sp # pass $sp
781 RETURN_IF_NO_EXCEPTION
782END art_quick_get_char_static
783 /*
784 * Called by managed code to resolve a static field and load a short primitive value.
785 */
786 .extern artGetShortStaticFromCode
787ENTRY art_quick_get_short_static
788 GENERATE_GLOBAL_POINTER
789 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
790 lw $a1, 64($sp) # pass referrer's Method*
791 move $a2, rSELF # pass Thread::Current
792 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
793 move $a3, $sp # pass $sp
794 RETURN_IF_NO_EXCEPTION
795END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800796
buzbee5bc5a7b2012-03-07 15:52:59 -0800797 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700798 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800799 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800800 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700801ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800802 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700803 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700804 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700805 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700806 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700807 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800808 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700809END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800810
buzbee5bc5a7b2012-03-07 15:52:59 -0800811 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700812 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800813 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800814 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700815ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800816 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700817 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700818 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700819 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700820 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700821 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800822 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700823END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800824
buzbee5bc5a7b2012-03-07 15:52:59 -0800825 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700826 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800827 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800828 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700829ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800830 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700831 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700832 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700833 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700834 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700835 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800836 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700837END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800838
buzbee5bc5a7b2012-03-07 15:52:59 -0800839 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700840 * Called by managed code to resolve an instance field and load a boolean primitive value.
841 */
842 .extern artGetBooleanInstanceFromCode
843ENTRY art_quick_get_boolean_instance
844 GENERATE_GLOBAL_POINTER
845 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
846 lw $a2, 64($sp) # pass referrer's Method*
847 move $a3, rSELF # pass Thread::Current
848 jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
849 sw $sp, 16($sp) # pass $sp
850 RETURN_IF_NO_EXCEPTION
851END art_quick_get_boolean_instance
852 /*
853 * Called by managed code to resolve an instance field and load a byte primitive value.
854 */
855 .extern artGetByteInstanceFromCode
856ENTRY art_quick_get_byte_instance
857 GENERATE_GLOBAL_POINTER
858 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
859 lw $a2, 64($sp) # pass referrer's Method*
860 move $a3, rSELF # pass Thread::Current
861 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
862 sw $sp, 16($sp) # pass $sp
863 RETURN_IF_NO_EXCEPTION
864END art_quick_get_byte_instance
865
866 /*
867 * Called by managed code to resolve an instance field and load a char primitive value.
868 */
869 .extern artGetCharInstanceFromCode
870ENTRY art_quick_get_char_instance
871 GENERATE_GLOBAL_POINTER
872 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
873 lw $a2, 64($sp) # pass referrer's Method*
874 move $a3, rSELF # pass Thread::Current
875 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
876 sw $sp, 16($sp) # pass $sp
877 RETURN_IF_NO_EXCEPTION
878END art_quick_get_char_instance
879 /*
880 * Called by managed code to resolve an instance field and load a short primitive value.
881 */
882 .extern artGetShortInstanceFromCode
883ENTRY art_quick_get_short_instance
884 GENERATE_GLOBAL_POINTER
885 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
886 lw $a2, 64($sp) # pass referrer's Method*
887 move $a3, rSELF # pass Thread::Current
888 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
889 sw $sp, 16($sp) # pass $sp
890 RETURN_IF_NO_EXCEPTION
891END art_quick_get_short_instance
892
893 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700894 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800895 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800896 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700897ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800898 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700899 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700900 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700901 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700902 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700903 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800904 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700905END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800906
buzbee5bc5a7b2012-03-07 15:52:59 -0800907 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700908 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800909 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800910 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700911ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800912 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700913 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700914 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700915 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700916 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700917 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800918 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700919END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800920
buzbee5bc5a7b2012-03-07 15:52:59 -0800921 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700922 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800923 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800924 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700925ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800926 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700927 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700928 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700929 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700930 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700931 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800932 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700933END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800934
buzbee5bc5a7b2012-03-07 15:52:59 -0800935 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700936 * Called by managed code to resolve a static field and store a 8-bit primitive value.
937 */
938 .extern artSet8StaticFromCode
939ENTRY art_quick_set8_static
940 GENERATE_GLOBAL_POINTER
941 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
942 lw $a2, 64($sp) # pass referrer's Method*
943 move $a3, rSELF # pass Thread::Current
944 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
945 sw $sp, 16($sp) # pass $sp
946 RETURN_IF_ZERO
947END art_quick_set8_static
948
949 /*
950 * Called by managed code to resolve a static field and store a 16-bit primitive value.
951 */
952 .extern artSet16StaticFromCode
953ENTRY art_quick_set16_static
954 GENERATE_GLOBAL_POINTER
955 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
956 lw $a2, 64($sp) # pass referrer's Method*
957 move $a3, rSELF # pass Thread::Current
958 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
959 sw $sp, 16($sp) # pass $sp
960 RETURN_IF_ZERO
961END art_quick_set16_static
962
963 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700964 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800965 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800966 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700967ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800968 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700969 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700970 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700971 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700972 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700973 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800974 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700975END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800976
buzbee5bc5a7b2012-03-07 15:52:59 -0800977 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700978 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800979 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700980 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700981ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800982 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700983 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700984 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700985 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700986 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700987 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800988 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700989END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800990
buzbee5bc5a7b2012-03-07 15:52:59 -0800991 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700992 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800993 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800994 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700995ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800996 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700997 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700998 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700999 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -07001000 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001001 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001002 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001003END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001004
buzbee5bc5a7b2012-03-07 15:52:59 -08001005 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001006 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1007 */
1008 .extern artSet8InstanceFromCode
1009ENTRY art_quick_set8_instance
1010 GENERATE_GLOBAL_POINTER
1011 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1012 lw $a3, 64($sp) # pass referrer's Method*
1013 sw rSELF, 16($sp) # pass Thread::Current
1014 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
1015 sw $sp, 20($sp) # pass $sp
1016 RETURN_IF_ZERO
1017END art_quick_set8_instance
1018
1019 /*
1020 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1021 */
1022 .extern artSet16InstanceFromCode
1023ENTRY art_quick_set16_instance
1024 GENERATE_GLOBAL_POINTER
1025 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1026 lw $a3, 64($sp) # pass referrer's Method*
1027 sw rSELF, 16($sp) # pass Thread::Current
1028 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
1029 sw $sp, 20($sp) # pass $sp
1030 RETURN_IF_ZERO
1031END art_quick_set16_instance
1032
1033 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001034 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001035 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001036 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001037ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -08001038 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001039 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -07001040 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -07001041 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -07001042 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001043 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001044 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001045END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001046
buzbee5bc5a7b2012-03-07 15:52:59 -08001047 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001048 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001049 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001050 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001051ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -08001052 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001053 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -07001054 sw rSELF, 16($sp) # pass Thread::Current
1055 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001056 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001057 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001058END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001059
buzbee5bc5a7b2012-03-07 15:52:59 -08001060 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001061 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001062 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001063 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001064ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -08001065 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001066 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -07001067 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -07001068 sw rSELF, 16($sp) # pass Thread::Current
1069 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001070 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001071 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001072END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001073
buzbee5bc5a7b2012-03-07 15:52:59 -08001074 /*
1075 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1076 * exception on error. On success the String is returned. R0 holds the referring method,
1077 * R1 holds the string index. The fast path check for hit in strings cache has already been
1078 * performed.
1079 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001080 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001081ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -08001082 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001083 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1084 move $a2, rSELF # pass Thread::Current
1085 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -08001086 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -07001087 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001088 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001089END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -08001090
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001091
1092// Macro to facilitate adding new allocation entrypoints.
1093.macro TWO_ARG_DOWNCALL name, entrypoint, return
1094 .extern \entrypoint
1095ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -08001096 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001097 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1098 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001099 jal \entrypoint
jeffhao7fbee072012-08-24 17:56:54 -07001100 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001101 \return
1102END \name
1103.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001104
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001105.macro THREE_ARG_DOWNCALL name, entrypoint, return
1106 .extern \entrypoint
1107ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -08001108 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001109 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1110 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001111 jal \entrypoint
jeffhao4eb68ed2012-10-17 16:41:07 -07001112 sw $sp, 16($sp) # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001113 \return
1114END \name
1115.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001116
Mathieu Chartier7410f292013-11-24 13:17:35 -08001117// Generate the allocation entrypoints for each allocator.
1118GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001119
buzbee5bc5a7b2012-03-07 15:52:59 -08001120 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001121 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001122 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001123 .extern artTestSuspendFromCode
1124ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -08001125 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -07001126 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001127 bnez $a0, 1f
1128 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1129 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001130 nop
11311:
jeffhao7fbee072012-08-24 17:56:54 -07001132 move $a0, rSELF
1133 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1134 jal artTestSuspendFromCode # (Thread*, $sp)
1135 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001136 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001137END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001138
buzbee5bc5a7b2012-03-07 15:52:59 -08001139 /*
1140 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001141 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001142 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001143 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001144ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -08001145 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -08001146 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001147 sw $a0, 0($sp) # place proxy method at bottom of frame
1148 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001149 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001150 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001151 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001152 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001153 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001154 mtc1 $v0, $f0 # place return value to FP return value
jeffhao7fbee072012-08-24 17:56:54 -07001155 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001156 mtc1 $v1, $f1 # place return value to FP return value
buzbee5bc5a7b2012-03-07 15:52:59 -080011571:
1158 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001159END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001160
Jeff Hao88474b42013-10-23 16:24:40 -07001161 /*
1162 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1163 * dex method index.
1164 */
1165ENTRY art_quick_imt_conflict_trampoline
1166 GENERATE_GLOBAL_POINTER
1167 lw $a0, 0($sp) # load caller Method*
1168 lw $a0, METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
1169 sll $t0, 2 # convert target method offset to bytes
1170 add $a0, $t0 # get address of target method
1171 lw $a0, OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
1172 la $t9, art_quick_invoke_interface_trampoline
1173 jr $t9
1174END art_quick_imt_conflict_trampoline
1175
Ian Rogers468532e2013-08-05 10:56:33 -07001176 .extern artQuickResolutionTrampoline
1177ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001178 GENERATE_GLOBAL_POINTER
1179 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001180 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001181 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001182 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001183 beqz $v0, 1f
1184 lw $a0, 0($sp) # load resolved method to $a0
Mathieu Chartier19841522013-10-22 11:29:00 -07001185 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001186 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001187 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001188 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011891:
Mathieu Chartier19841522013-10-22 11:29:00 -07001190 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001191 DELIVER_PENDING_EXCEPTION
1192END art_quick_resolution_trampoline
1193
Andreas Gampe2da88232014-02-27 12:26:20 -08001194UNIMPLEMENTED art_quick_generic_jni_trampoline
1195
Ian Rogers468532e2013-08-05 10:56:33 -07001196 .extern artQuickToInterpreterBridge
1197ENTRY art_quick_to_interpreter_bridge
1198 GENERATE_GLOBAL_POINTER
1199 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001200 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001201 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001202 move $a2, $sp # pass $sp
1203 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001204 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001205 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001206 mtc1 $v0, $f0 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001207 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001208 mtc1 $v1, $f1 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -080012091:
1210 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001211END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001212
buzbee5bc5a7b2012-03-07 15:52:59 -08001213 /*
jeffhao725a9572012-11-13 18:20:12 -08001214 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001215 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001216 .extern artInstrumentationMethodEntryFromCode
1217 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001218ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001219 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001220 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001221 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001222 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1223 .cfi_adjust_cfa_offset 32
1224 sw $a0, 28($sp) # save arg0
1225 sw $ra, 16($sp) # pass $ra
1226 move $a3, $t0 # pass $sp
1227 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1228 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001229 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001230 lw $a0, 28($sp) # restore arg0
1231 addiu $sp, $sp, 32 # remove args
1232 .cfi_adjust_cfa_offset -32
1233 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001234 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001235 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001236END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001237 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001238 .global art_quick_instrumentation_exit
1239art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001240 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001241 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1242 GENERATE_GLOBAL_POINTER
Douglas Leungc3d131e2014-07-16 17:32:41 -07001243 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Ian Rogers62d6c772013-02-27 08:32:07 -08001244 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
Douglas Leungc3d131e2014-07-16 17:32:41 -07001245 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001246 addiu $sp, $sp, -48 # save return values and set up args
1247 .cfi_adjust_cfa_offset 48
1248 sw $v0, 32($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001249 .cfi_rel_offset 2, 32
Ian Rogers62d6c772013-02-27 08:32:07 -08001250 sw $v1, 36($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001251 .cfi_rel_offset 3, 36
Ian Rogers62d6c772013-02-27 08:32:07 -08001252 s.s $f0, 40($sp)
1253 s.s $f1, 44($sp)
1254 s.s $f0, 16($sp) # pass fpr result
1255 s.s $f1, 20($sp)
1256 move $a2, $v0 # pass gpr result
1257 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001258 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001259 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001260 move $a0, rSELF # pass Thread::Current
1261 move $t0, $v0 # set aside returned link register
1262 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001263 lw $v0, 32($sp) # restore return values
1264 lw $v1, 36($sp)
1265 l.s $f0, 40($sp)
1266 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001267 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001268 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1269 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001270END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001271
jeffhao12051ea2013-01-10 11:24:31 -08001272 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001273 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1274 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001275 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001276 .extern artDeoptimize
1277 .extern artEnterInterpreterFromDeoptimize
1278ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001279 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001280 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001281 move $a0, rSELF # pass Thread::current
1282 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001283 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001284 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001285END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001286
buzbee5bc5a7b2012-03-07 15:52:59 -08001287 /*
1288 * Long integer shift. This is different from the generic 32/64-bit
1289 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1290 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1291 * 6 bits.
1292 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001293 * $a0: low word
1294 * $a1: high word
1295 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001296 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001297ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001298 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001299 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1300 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1301 srl $a0, 1
1302 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1303 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1304 or $v1, $a0 # rhi<- rhi | alo
1305 andi $a2, 0x20 # shift< shift & 0x20
1306 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1307 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001308 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001309END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001310
buzbee5bc5a7b2012-03-07 15:52:59 -08001311 /*
1312 * Long integer shift. This is different from the generic 32/64-bit
1313 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1314 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1315 * 6 bits.
1316 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001317 * $a0: low word
1318 * $a1: high word
1319 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001320 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001321 .global art_quick_shr_long
1322ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001323 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1324 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1325 sra $a3, $a1, 31 # $a3<- sign(ah)
1326 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1327 sll $a1, 1
1328 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1329 or $v0, $a1 # rlo<- rlo | ahi
1330 andi $a2, 0x20 # shift & 0x20
1331 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1332 jr $ra
1333 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001334END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001335
buzbee5bc5a7b2012-03-07 15:52:59 -08001336 /*
1337 * Long integer shift. This is different from the generic 32/64-bit
1338 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1339 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1340 * 6 bits.
1341 * On entry:
1342 * r0: low word
1343 * r1: high word
1344 * r2: shift count
1345 */
1346 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001347 .global art_quick_ushr_long
1348ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001349 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001350 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001351 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1352 sll $a1, 1
1353 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1354 or $v0, $a1 # rlo<- rlo | ahi
1355 andi $a2, 0x20 # shift & 0x20
1356 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1357 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001358 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001359END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001360
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001361ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001362 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001363 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001364END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001365
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001366ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001367 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001368 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001369END art_quick_string_compareto