blob: 9e9e5236af60363de297f038b3324417b3967966 [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
548 move $a2, rSELF # pass Thread::Current
549 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
550 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700551 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700552END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800553
buzbee5bc5a7b2012-03-07 15:52:59 -0800554 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700555 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800556 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800557 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700558ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800559 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800560 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700561 nop
jeffhao7fbee072012-08-24 17:56:54 -0700562 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
563 move $a1, rSELF # pass Thread::Current
564 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
565 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700566 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700567END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800568
buzbee5bc5a7b2012-03-07 15:52:59 -0800569 /*
570 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
571 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800572 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700573ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800574 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800575 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700576 nop
jeffhao7fbee072012-08-24 17:56:54 -0700577 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
578 move $a1, rSELF # pass Thread::Current
579 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
580 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800581 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700582END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800583
buzbee5bc5a7b2012-03-07 15:52:59 -0800584 /*
585 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
586 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700587 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700588ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800589 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700590 addiu $sp, $sp, -16
591 .cfi_adjust_cfa_offset 16
592 sw $ra, 12($sp)
593 .cfi_rel_offset 31, 12
594 sw $t9, 8($sp)
595 sw $a1, 4($sp)
596 sw $a0, 0($sp)
597 jal artIsAssignableFromCode
598 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800599 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700600 lw $ra, 12($sp)
601 jr $ra
602 addiu $sp, $sp, 16
603 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800604.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700605 lw $t9, 8($sp)
606 lw $a1, 4($sp)
607 lw $a0, 0($sp)
608 addiu $sp, $sp, 16
609 .cfi_adjust_cfa_offset -16
610 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
611 move $a2, rSELF # pass Thread::Current
612 la $t9, artThrowClassCastException
613 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
614 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700615END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800616
buzbee5bc5a7b2012-03-07 15:52:59 -0800617 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700618 * Entry from managed code for array put operations of objects where the value being stored
619 * needs to be checked for compatibility.
620 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800621 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700622ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800623 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800624 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700625 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800626 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700627 nop
628END art_quick_aput_obj_with_null_and_bound_check
629
630ENTRY art_quick_aput_obj_with_bound_check
631 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800632.Lart_quick_aput_obj_with_bound_check_gp_set:
Ian Rogersa9a82542013-10-04 11:17:26 -0700633 lw $t0, ARRAY_LENGTH_OFFSET($a0)
634 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800635 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700636 nop
637 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800638 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700639 move $a1, $t0
640END art_quick_aput_obj_with_bound_check
641
642ENTRY art_quick_aput_obj
643 GENERATE_GLOBAL_POINTER
Ian Rogers86bcdc22014-02-21 22:06:38 -0800644.Lart_quick_aput_obj_gp_set:
645 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700646 nop
647 lw $t0, CLASS_OFFSET($a0)
648 lw $t1, CLASS_OFFSET($a2)
649 lw $t0, 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
655 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
656 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
665 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
666 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*)
680 nop
681 lw $ra, 28($sp)
682 lw $t9, 12($sp)
683 lw $a2, 8($sp)
684 lw $a1, 4($sp)
685 lw $a0, 0($sp)
686 add $sp, 32
687 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800688 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700689 nop
690 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
691 move $a1, $a2
692 move $a2, rSELF # pass Thread::Current
693 la $t9, artThrowArrayStoreException
694 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
695 move $a3, $sp # pass $sp
696END 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
jeffhao12051ea2013-01-10 11:24:31 -0800705 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700706 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
707 move $a2, rSELF # pass Thread::Current
708 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800709 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700710 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800711 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700712END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800713
buzbee5bc5a7b2012-03-07 15:52:59 -0800714 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700715 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800716 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800717 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700718ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800719 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700720 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
721 move $a2, rSELF # pass Thread::Current
722 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800723 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700724 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800725 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700726END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800727
buzbee5bc5a7b2012-03-07 15:52:59 -0800728 /*
729 * 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 -0700730 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800731 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800732 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700733ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800734 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700735 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
736 move $a2, rSELF # pass Thread::Current
737 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800738 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700739 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800740 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700741END art_quick_initialize_type_and_verify_access
Fred Shih37f05ef2014-07-16 18:38:08 -0700742 /*
743 * Called by managed code to resolve a static field and load a boolean primitive value.
744 */
745 .extern artGetBooleanStaticFromCode
746ENTRY art_quick_get_boolean_static
747 GENERATE_GLOBAL_POINTER
748 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
749 lw $a1, 64($sp) # pass referrer's Method*
750 move $a2, rSELF # pass Thread::Current
751 jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
752 move $a3, $sp # pass $sp
753 RETURN_IF_NO_EXCEPTION
754END art_quick_get_boolean_static
755 /*
756 * Called by managed code to resolve a static field and load a byte primitive value.
757 */
758 .extern artGetByteStaticFromCode
759ENTRY art_quick_get_byte_static
760 GENERATE_GLOBAL_POINTER
761 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
762 lw $a1, 64($sp) # pass referrer's Method*
763 move $a2, rSELF # pass Thread::Current
764 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
765 move $a3, $sp # pass $sp
766 RETURN_IF_NO_EXCEPTION
767END art_quick_get_byte_static
768
769 /*
770 * Called by managed code to resolve a static field and load a char primitive value.
771 */
772 .extern artGetCharStaticFromCode
773ENTRY art_quick_get_char_static
774 GENERATE_GLOBAL_POINTER
775 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
776 lw $a1, 64($sp) # pass referrer's Method*
777 move $a2, rSELF # pass Thread::Current
778 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
779 move $a3, $sp # pass $sp
780 RETURN_IF_NO_EXCEPTION
781END art_quick_get_char_static
782 /*
783 * Called by managed code to resolve a static field and load a short primitive value.
784 */
785 .extern artGetShortStaticFromCode
786ENTRY art_quick_get_short_static
787 GENERATE_GLOBAL_POINTER
788 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
789 lw $a1, 64($sp) # pass referrer's Method*
790 move $a2, rSELF # pass Thread::Current
791 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
792 move $a3, $sp # pass $sp
793 RETURN_IF_NO_EXCEPTION
794END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800795
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700797 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800798 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800799 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700800ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800801 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700802 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700803 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700804 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700805 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700806 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800807 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700808END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800809
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700811 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800812 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800813 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700814ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800815 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700816 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700817 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700818 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700819 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700820 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800821 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700822END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800823
buzbee5bc5a7b2012-03-07 15:52:59 -0800824 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700825 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800826 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800827 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700828ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800829 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700830 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700831 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700832 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700833 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700834 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800835 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700836END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800837
buzbee5bc5a7b2012-03-07 15:52:59 -0800838 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700839 * Called by managed code to resolve an instance field and load a boolean primitive value.
840 */
841 .extern artGetBooleanInstanceFromCode
842ENTRY art_quick_get_boolean_instance
843 GENERATE_GLOBAL_POINTER
844 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
845 lw $a2, 64($sp) # pass referrer's Method*
846 move $a3, rSELF # pass Thread::Current
847 jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
848 sw $sp, 16($sp) # pass $sp
849 RETURN_IF_NO_EXCEPTION
850END art_quick_get_boolean_instance
851 /*
852 * Called by managed code to resolve an instance field and load a byte primitive value.
853 */
854 .extern artGetByteInstanceFromCode
855ENTRY art_quick_get_byte_instance
856 GENERATE_GLOBAL_POINTER
857 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
858 lw $a2, 64($sp) # pass referrer's Method*
859 move $a3, rSELF # pass Thread::Current
860 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
861 sw $sp, 16($sp) # pass $sp
862 RETURN_IF_NO_EXCEPTION
863END art_quick_get_byte_instance
864
865 /*
866 * Called by managed code to resolve an instance field and load a char primitive value.
867 */
868 .extern artGetCharInstanceFromCode
869ENTRY art_quick_get_char_instance
870 GENERATE_GLOBAL_POINTER
871 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
872 lw $a2, 64($sp) # pass referrer's Method*
873 move $a3, rSELF # pass Thread::Current
874 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
875 sw $sp, 16($sp) # pass $sp
876 RETURN_IF_NO_EXCEPTION
877END art_quick_get_char_instance
878 /*
879 * Called by managed code to resolve an instance field and load a short primitive value.
880 */
881 .extern artGetShortInstanceFromCode
882ENTRY art_quick_get_short_instance
883 GENERATE_GLOBAL_POINTER
884 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
885 lw $a2, 64($sp) # pass referrer's Method*
886 move $a3, rSELF # pass Thread::Current
887 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
888 sw $sp, 16($sp) # pass $sp
889 RETURN_IF_NO_EXCEPTION
890END art_quick_get_short_instance
891
892 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700893 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800894 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800895 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700896ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800897 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700898 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700899 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700900 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700901 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700902 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800903 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700904END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800905
buzbee5bc5a7b2012-03-07 15:52:59 -0800906 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700907 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800908 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800909 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700910ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800911 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700912 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700913 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700914 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700915 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700916 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800917 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700918END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800919
buzbee5bc5a7b2012-03-07 15:52:59 -0800920 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700921 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800922 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800923 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700924ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800925 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700926 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700927 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700928 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700929 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700930 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800931 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700932END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800933
buzbee5bc5a7b2012-03-07 15:52:59 -0800934 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700935 * Called by managed code to resolve a static field and store a 8-bit primitive value.
936 */
937 .extern artSet8StaticFromCode
938ENTRY art_quick_set8_static
939 GENERATE_GLOBAL_POINTER
940 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
941 lw $a2, 64($sp) # pass referrer's Method*
942 move $a3, rSELF # pass Thread::Current
943 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
944 sw $sp, 16($sp) # pass $sp
945 RETURN_IF_ZERO
946END art_quick_set8_static
947
948 /*
949 * Called by managed code to resolve a static field and store a 16-bit primitive value.
950 */
951 .extern artSet16StaticFromCode
952ENTRY art_quick_set16_static
953 GENERATE_GLOBAL_POINTER
954 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
955 lw $a2, 64($sp) # pass referrer's Method*
956 move $a3, rSELF # pass Thread::Current
957 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
958 sw $sp, 16($sp) # pass $sp
959 RETURN_IF_ZERO
960END art_quick_set16_static
961
962 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700963 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800964 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800965 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700966ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800967 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700968 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700969 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700970 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700971 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700972 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800973 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700974END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800975
buzbee5bc5a7b2012-03-07 15:52:59 -0800976 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700977 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800978 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700979 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700980ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800981 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700982 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700983 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700984 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700985 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700986 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800987 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700988END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800989
buzbee5bc5a7b2012-03-07 15:52:59 -0800990 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700991 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800992 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800993 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700994ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800995 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700996 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700997 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700998 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700999 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001000 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001001 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001002END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001003
buzbee5bc5a7b2012-03-07 15:52:59 -08001004 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001005 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1006 */
1007 .extern artSet8InstanceFromCode
1008ENTRY art_quick_set8_instance
1009 GENERATE_GLOBAL_POINTER
1010 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1011 lw $a3, 64($sp) # pass referrer's Method*
1012 sw rSELF, 16($sp) # pass Thread::Current
1013 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
1014 sw $sp, 20($sp) # pass $sp
1015 RETURN_IF_ZERO
1016END art_quick_set8_instance
1017
1018 /*
1019 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1020 */
1021 .extern artSet16InstanceFromCode
1022ENTRY art_quick_set16_instance
1023 GENERATE_GLOBAL_POINTER
1024 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1025 lw $a3, 64($sp) # pass referrer's Method*
1026 sw rSELF, 16($sp) # pass Thread::Current
1027 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
1028 sw $sp, 20($sp) # pass $sp
1029 RETURN_IF_ZERO
1030END art_quick_set16_instance
1031
1032 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001033 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001034 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001035 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001036ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -08001037 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001038 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -07001039 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -07001040 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -07001041 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001042 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001043 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001044END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001045
buzbee5bc5a7b2012-03-07 15:52:59 -08001046 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001047 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001048 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001049 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001050ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -08001051 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001052 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -07001053 sw rSELF, 16($sp) # pass Thread::Current
1054 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001055 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001056 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001057END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001058
buzbee5bc5a7b2012-03-07 15:52:59 -08001059 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001060 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001061 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001062 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001063ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -08001064 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001065 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -07001066 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -07001067 sw rSELF, 16($sp) # pass Thread::Current
1068 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -07001069 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001070 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001071END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001072
buzbee5bc5a7b2012-03-07 15:52:59 -08001073 /*
1074 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1075 * exception on error. On success the String is returned. R0 holds the referring method,
1076 * R1 holds the string index. The fast path check for hit in strings cache has already been
1077 * performed.
1078 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001079 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001080ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -08001081 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001082 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1083 move $a2, rSELF # pass Thread::Current
1084 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -08001085 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -07001086 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001087 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001088END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -08001089
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001090
1091// Macro to facilitate adding new allocation entrypoints.
1092.macro TWO_ARG_DOWNCALL name, entrypoint, return
1093 .extern \entrypoint
1094ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -08001095 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001096 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1097 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001098 jal \entrypoint
jeffhao7fbee072012-08-24 17:56:54 -07001099 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001100 \return
1101END \name
1102.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001103
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001104.macro THREE_ARG_DOWNCALL name, entrypoint, return
1105 .extern \entrypoint
1106ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -08001107 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001108 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1109 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001110 jal \entrypoint
jeffhao4eb68ed2012-10-17 16:41:07 -07001111 sw $sp, 16($sp) # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001112 \return
1113END \name
1114.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001115
Mathieu Chartier7410f292013-11-24 13:17:35 -08001116// Generate the allocation entrypoints for each allocator.
1117GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001118
buzbee5bc5a7b2012-03-07 15:52:59 -08001119 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001120 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001121 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001122 .extern artTestSuspendFromCode
1123ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -08001124 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -07001125 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001126 bnez $a0, 1f
1127 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1128 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001129 nop
11301:
jeffhao7fbee072012-08-24 17:56:54 -07001131 move $a0, rSELF
1132 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1133 jal artTestSuspendFromCode # (Thread*, $sp)
1134 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001135 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001136END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001137
buzbee5bc5a7b2012-03-07 15:52:59 -08001138 /*
1139 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001140 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001141 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001142 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001143ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -08001144 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -08001145 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001146 sw $a0, 0($sp) # place proxy method at bottom of frame
1147 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001148 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001149 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001150 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001151 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001152 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001153 mtc1 $v0, $f0 # place return value to FP return value
jeffhao7fbee072012-08-24 17:56:54 -07001154 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001155 mtc1 $v1, $f1 # place return value to FP return value
buzbee5bc5a7b2012-03-07 15:52:59 -080011561:
1157 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001158END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001159
Jeff Hao88474b42013-10-23 16:24:40 -07001160 /*
1161 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1162 * dex method index.
1163 */
1164ENTRY art_quick_imt_conflict_trampoline
1165 GENERATE_GLOBAL_POINTER
1166 lw $a0, 0($sp) # load caller Method*
1167 lw $a0, METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
1168 sll $t0, 2 # convert target method offset to bytes
1169 add $a0, $t0 # get address of target method
1170 lw $a0, OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
1171 la $t9, art_quick_invoke_interface_trampoline
1172 jr $t9
1173END art_quick_imt_conflict_trampoline
1174
Ian Rogers468532e2013-08-05 10:56:33 -07001175 .extern artQuickResolutionTrampoline
1176ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001177 GENERATE_GLOBAL_POINTER
1178 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001179 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001180 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001181 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001182 beqz $v0, 1f
1183 lw $a0, 0($sp) # load resolved method to $a0
Mathieu Chartier19841522013-10-22 11:29:00 -07001184 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001185 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001186 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001187 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011881:
Mathieu Chartier19841522013-10-22 11:29:00 -07001189 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001190 DELIVER_PENDING_EXCEPTION
1191END art_quick_resolution_trampoline
1192
Andreas Gampe2da88232014-02-27 12:26:20 -08001193UNIMPLEMENTED art_quick_generic_jni_trampoline
1194
Ian Rogers468532e2013-08-05 10:56:33 -07001195 .extern artQuickToInterpreterBridge
1196ENTRY art_quick_to_interpreter_bridge
1197 GENERATE_GLOBAL_POINTER
1198 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001199 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001200 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001201 move $a2, $sp # pass $sp
1202 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001203 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001204 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001205 mtc1 $v0, $f0 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001206 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001207 mtc1 $v1, $f1 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -080012081:
1209 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001210END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001211
buzbee5bc5a7b2012-03-07 15:52:59 -08001212 /*
jeffhao725a9572012-11-13 18:20:12 -08001213 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001214 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001215 .extern artInstrumentationMethodEntryFromCode
1216 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001217ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001218 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001219 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001220 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001221 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1222 .cfi_adjust_cfa_offset 32
1223 sw $a0, 28($sp) # save arg0
1224 sw $ra, 16($sp) # pass $ra
1225 move $a3, $t0 # pass $sp
1226 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1227 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001228 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001229 lw $a0, 28($sp) # restore arg0
1230 addiu $sp, $sp, 32 # remove args
1231 .cfi_adjust_cfa_offset -32
1232 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001233 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001234 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001235END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001236 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001237 .global art_quick_instrumentation_exit
1238art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001239 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001240 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1241 GENERATE_GLOBAL_POINTER
Douglas Leungc3d131e2014-07-16 17:32:41 -07001242 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Ian Rogers62d6c772013-02-27 08:32:07 -08001243 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
Douglas Leungc3d131e2014-07-16 17:32:41 -07001244 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001245 addiu $sp, $sp, -48 # save return values and set up args
1246 .cfi_adjust_cfa_offset 48
1247 sw $v0, 32($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001248 .cfi_rel_offset 2, 32
Ian Rogers62d6c772013-02-27 08:32:07 -08001249 sw $v1, 36($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001250 .cfi_rel_offset 3, 36
Ian Rogers62d6c772013-02-27 08:32:07 -08001251 s.s $f0, 40($sp)
1252 s.s $f1, 44($sp)
1253 s.s $f0, 16($sp) # pass fpr result
1254 s.s $f1, 20($sp)
1255 move $a2, $v0 # pass gpr result
1256 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001257 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001258 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001259 move $a0, rSELF # pass Thread::Current
1260 move $t0, $v0 # set aside returned link register
1261 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001262 lw $v0, 32($sp) # restore return values
1263 lw $v1, 36($sp)
1264 l.s $f0, 40($sp)
1265 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001266 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001267 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1268 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001269END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001270
jeffhao12051ea2013-01-10 11:24:31 -08001271 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001272 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1273 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001274 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001275 .extern artDeoptimize
1276 .extern artEnterInterpreterFromDeoptimize
1277ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001278 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001279 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001280 move $a0, rSELF # pass Thread::current
1281 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001282 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001283 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001284END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001285
buzbee5bc5a7b2012-03-07 15:52:59 -08001286 /*
1287 * Long integer shift. This is different from the generic 32/64-bit
1288 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1289 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1290 * 6 bits.
1291 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001292 * $a0: low word
1293 * $a1: high word
1294 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001295 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001296ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001297 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001298 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1299 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1300 srl $a0, 1
1301 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1302 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1303 or $v1, $a0 # rhi<- rhi | alo
1304 andi $a2, 0x20 # shift< shift & 0x20
1305 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1306 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001307 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001308END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001309
buzbee5bc5a7b2012-03-07 15:52:59 -08001310 /*
1311 * Long integer shift. This is different from the generic 32/64-bit
1312 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1313 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1314 * 6 bits.
1315 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001316 * $a0: low word
1317 * $a1: high word
1318 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001319 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001320 .global art_quick_shr_long
1321ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001322 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1323 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1324 sra $a3, $a1, 31 # $a3<- sign(ah)
1325 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1326 sll $a1, 1
1327 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1328 or $v0, $a1 # rlo<- rlo | ahi
1329 andi $a2, 0x20 # shift & 0x20
1330 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1331 jr $ra
1332 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001333END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001334
buzbee5bc5a7b2012-03-07 15:52:59 -08001335 /*
1336 * Long integer shift. This is different from the generic 32/64-bit
1337 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1338 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1339 * 6 bits.
1340 * On entry:
1341 * r0: low word
1342 * r1: high word
1343 * r2: shift count
1344 */
1345 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001346 .global art_quick_ushr_long
1347ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001348 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001349 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001350 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1351 sll $a1, 1
1352 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1353 or $v0, $a1 # rlo<- rlo | ahi
1354 andi $a2, 0x20 # shift & 0x20
1355 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1356 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001357 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001358END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001359
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001360ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001361 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001362 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001363END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001364
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001365ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001366 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001367 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001368END art_quick_string_compareto