blob: 87862222506b223d886ec76f9a52fbd08d5fbfbe [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
buzbee5bc5a7b2012-03-07 15:52:59 -0800742
buzbee5bc5a7b2012-03-07 15:52:59 -0800743 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700744 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800745 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800746 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700747ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800748 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700749 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700750 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700751 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700752 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700753 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800754 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700755END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800756
buzbee5bc5a7b2012-03-07 15:52:59 -0800757 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700758 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800759 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800760 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700761ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800762 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700763 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700764 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700765 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700766 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700767 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800768 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700769END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800770
buzbee5bc5a7b2012-03-07 15:52:59 -0800771 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700772 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800773 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800774 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700775ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800776 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700777 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700778 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700779 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700780 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700781 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700783END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800784
buzbee5bc5a7b2012-03-07 15:52:59 -0800785 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700786 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800787 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800788 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700789ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800790 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700791 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700792 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700793 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700794 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700795 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700797END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800798
buzbee5bc5a7b2012-03-07 15:52:59 -0800799 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700800 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800801 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800802 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700803ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800804 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700805 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700806 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700807 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700808 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700809 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700811END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800812
buzbee5bc5a7b2012-03-07 15:52:59 -0800813 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700814 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800815 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800816 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700817ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800818 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700819 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700820 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700821 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700822 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700823 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800824 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700825END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800826
buzbee5bc5a7b2012-03-07 15:52:59 -0800827 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700828 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800829 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800830 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700831ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800832 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700833 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700834 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700835 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700836 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700837 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800838 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700839END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800840
buzbee5bc5a7b2012-03-07 15:52:59 -0800841 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700842 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800843 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800844 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700845ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800846 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700847 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700848 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700849 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700850 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700851 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800852 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700853END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800854
buzbee5bc5a7b2012-03-07 15:52:59 -0800855 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700856 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800857 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800858 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700859ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800860 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700861 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700862 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700863 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700864 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700865 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700867END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800868
buzbee5bc5a7b2012-03-07 15:52:59 -0800869 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700870 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800871 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800872 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700873ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800874 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700875 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700876 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700877 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700878 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700879 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800880 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700881END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800882
buzbee5bc5a7b2012-03-07 15:52:59 -0800883 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700884 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800885 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800886 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700887ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800888 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700889 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700890 sw rSELF, 16($sp) # pass Thread::Current
891 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700892 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800893 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700894END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800895
buzbee5bc5a7b2012-03-07 15:52:59 -0800896 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700897 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800898 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800899 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700900ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800901 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700902 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700903 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700904 sw rSELF, 16($sp) # pass Thread::Current
905 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700906 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800907 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700908END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800909
buzbee5bc5a7b2012-03-07 15:52:59 -0800910 /*
911 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
912 * exception on error. On success the String is returned. R0 holds the referring method,
913 * R1 holds the string index. The fast path check for hit in strings cache has already been
914 * performed.
915 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800916 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700917ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -0800918 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700919 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
920 move $a2, rSELF # pass Thread::Current
921 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800922 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700923 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800924 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700925END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -0800926
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800927
928// Macro to facilitate adding new allocation entrypoints.
929.macro TWO_ARG_DOWNCALL name, entrypoint, return
930 .extern \entrypoint
931ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -0800932 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700933 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
934 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800935 jal \entrypoint
jeffhao7fbee072012-08-24 17:56:54 -0700936 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800937 \return
938END \name
939.endm
buzbee5bc5a7b2012-03-07 15:52:59 -0800940
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800941.macro THREE_ARG_DOWNCALL name, entrypoint, return
942 .extern \entrypoint
943ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -0800944 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700945 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
946 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800947 jal \entrypoint
jeffhao4eb68ed2012-10-17 16:41:07 -0700948 sw $sp, 16($sp) # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800949 \return
950END \name
951.endm
buzbee5bc5a7b2012-03-07 15:52:59 -0800952
Mathieu Chartier7410f292013-11-24 13:17:35 -0800953// Generate the allocation entrypoints for each allocator.
954GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700955
buzbee5bc5a7b2012-03-07 15:52:59 -0800956 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700957 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -0800958 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800959 .extern artTestSuspendFromCode
960ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -0800961 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -0700962 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -0700963 bnez $a0, 1f
964 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
965 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800966 nop
9671:
jeffhao7fbee072012-08-24 17:56:54 -0700968 move $a0, rSELF
969 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
970 jal artTestSuspendFromCode # (Thread*, $sp)
971 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800972 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800973END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -0800974
buzbee5bc5a7b2012-03-07 15:52:59 -0800975 /*
976 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -0700977 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -0800978 */
Jeff Hao5fa60c32013-04-04 17:57:01 -0700979 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800980ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -0800981 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -0800982 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700983 sw $a0, 0($sp) # place proxy method at bottom of frame
984 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -0700985 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800986 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -0700987 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -0700988 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700989 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -0700990 mtc1 $v0, $f0 # place return value to FP return value
jeffhao7fbee072012-08-24 17:56:54 -0700991 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -0700992 mtc1 $v1, $f1 # place return value to FP return value
buzbee5bc5a7b2012-03-07 15:52:59 -08009931:
994 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800995END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -0800996
Jeff Hao88474b42013-10-23 16:24:40 -0700997 /*
998 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
999 * dex method index.
1000 */
1001ENTRY art_quick_imt_conflict_trampoline
1002 GENERATE_GLOBAL_POINTER
1003 lw $a0, 0($sp) # load caller Method*
1004 lw $a0, METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
1005 sll $t0, 2 # convert target method offset to bytes
1006 add $a0, $t0 # get address of target method
1007 lw $a0, OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
1008 la $t9, art_quick_invoke_interface_trampoline
1009 jr $t9
1010END art_quick_imt_conflict_trampoline
1011
Ian Rogers468532e2013-08-05 10:56:33 -07001012 .extern artQuickResolutionTrampoline
1013ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001014 GENERATE_GLOBAL_POINTER
1015 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001016 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001017 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001018 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001019 beqz $v0, 1f
1020 lw $a0, 0($sp) # load resolved method to $a0
Mathieu Chartier19841522013-10-22 11:29:00 -07001021 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001022 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001023 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001024 nop
Ian Rogers468532e2013-08-05 10:56:33 -070010251:
Mathieu Chartier19841522013-10-22 11:29:00 -07001026 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001027 DELIVER_PENDING_EXCEPTION
1028END art_quick_resolution_trampoline
1029
Andreas Gampe2da88232014-02-27 12:26:20 -08001030UNIMPLEMENTED art_quick_generic_jni_trampoline
1031
Ian Rogers468532e2013-08-05 10:56:33 -07001032 .extern artQuickToInterpreterBridge
1033ENTRY art_quick_to_interpreter_bridge
1034 GENERATE_GLOBAL_POINTER
1035 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001036 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001037 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001038 move $a2, $sp # pass $sp
1039 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001040 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001041 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001042 mtc1 $v0, $f0 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001043 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001044 mtc1 $v1, $f1 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -080010451:
1046 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001047END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001048
buzbee5bc5a7b2012-03-07 15:52:59 -08001049 /*
jeffhao725a9572012-11-13 18:20:12 -08001050 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001051 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001052 .extern artInstrumentationMethodEntryFromCode
1053 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001054ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001055 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001056 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001057 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001058 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1059 .cfi_adjust_cfa_offset 32
1060 sw $a0, 28($sp) # save arg0
1061 sw $ra, 16($sp) # pass $ra
1062 move $a3, $t0 # pass $sp
1063 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1064 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001065 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001066 lw $a0, 28($sp) # restore arg0
1067 addiu $sp, $sp, 32 # remove args
1068 .cfi_adjust_cfa_offset -32
1069 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001070 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001071 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001072END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001073 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001074 .global art_quick_instrumentation_exit
1075art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001076 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001077 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1078 GENERATE_GLOBAL_POINTER
Douglas Leungc3d131e2014-07-16 17:32:41 -07001079 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Ian Rogers62d6c772013-02-27 08:32:07 -08001080 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
Douglas Leungc3d131e2014-07-16 17:32:41 -07001081 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001082 addiu $sp, $sp, -48 # save return values and set up args
1083 .cfi_adjust_cfa_offset 48
1084 sw $v0, 32($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001085 .cfi_rel_offset 2, 32
Ian Rogers62d6c772013-02-27 08:32:07 -08001086 sw $v1, 36($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001087 .cfi_rel_offset 3, 36
Ian Rogers62d6c772013-02-27 08:32:07 -08001088 s.s $f0, 40($sp)
1089 s.s $f1, 44($sp)
1090 s.s $f0, 16($sp) # pass fpr result
1091 s.s $f1, 20($sp)
1092 move $a2, $v0 # pass gpr result
1093 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001094 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001095 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001096 move $a0, rSELF # pass Thread::Current
1097 move $t0, $v0 # set aside returned link register
1098 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001099 lw $v0, 32($sp) # restore return values
1100 lw $v1, 36($sp)
1101 l.s $f0, 40($sp)
1102 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001103 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001104 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1105 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001106END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001107
jeffhao12051ea2013-01-10 11:24:31 -08001108 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001109 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1110 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001111 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001112 .extern artDeoptimize
1113 .extern artEnterInterpreterFromDeoptimize
1114ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001115 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001116 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001117 move $a0, rSELF # pass Thread::current
1118 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001119 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001120 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001121END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001122
buzbee5bc5a7b2012-03-07 15:52:59 -08001123 /*
1124 * Long integer shift. This is different from the generic 32/64-bit
1125 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1126 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1127 * 6 bits.
1128 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001129 * $a0: low word
1130 * $a1: high word
1131 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001132 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001133ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001134 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001135 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1136 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1137 srl $a0, 1
1138 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1139 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1140 or $v1, $a0 # rhi<- rhi | alo
1141 andi $a2, 0x20 # shift< shift & 0x20
1142 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1143 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001144 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001145END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001146
buzbee5bc5a7b2012-03-07 15:52:59 -08001147 /*
1148 * Long integer shift. This is different from the generic 32/64-bit
1149 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1150 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1151 * 6 bits.
1152 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001153 * $a0: low word
1154 * $a1: high word
1155 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001156 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001157 .global art_quick_shr_long
1158ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001159 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1160 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1161 sra $a3, $a1, 31 # $a3<- sign(ah)
1162 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1163 sll $a1, 1
1164 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1165 or $v0, $a1 # rlo<- rlo | ahi
1166 andi $a2, 0x20 # shift & 0x20
1167 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1168 jr $ra
1169 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001170END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001171
buzbee5bc5a7b2012-03-07 15:52:59 -08001172 /*
1173 * Long integer shift. This is different from the generic 32/64-bit
1174 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1175 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1176 * 6 bits.
1177 * On entry:
1178 * r0: low word
1179 * r1: high word
1180 * r2: shift count
1181 */
1182 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001183 .global art_quick_ushr_long
1184ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001185 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001186 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001187 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1188 sll $a1, 1
1189 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1190 or $v0, $a1 # rlo<- rlo | ahi
1191 andi $a2, 0x20 # shift & 0x20
1192 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1193 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001194 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001195END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001196
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001197ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001198 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001199 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001200END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001201
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001202ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001203 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001204 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001205END art_quick_string_compareto