blob: 886271166c84277ba5b9f641873c9f5d78a89c5f [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
jeffhao07030602012-09-26 14:33:14 -070019 .set noreorder
buzbee5bc5a7b2012-03-07 15:52:59 -080020 .balign 4
21
22 /* Deliver the given exception */
23 .extern artDeliverExceptionFromCode
24 /* Deliver an exception pending on a thread */
jeffhao8161c032012-10-31 15:50:00 -070025 .extern artDeliverPendingExceptionFromCode
buzbee5bc5a7b2012-03-07 15:52:59 -080026
27 /*
28 * Macro that sets up the callee save frame to conform with
29 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070030 * callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080031 */
Ian Rogers57b86d42012-03-27 16:05:41 -070032.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -070033 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080034 .cfi_adjust_cfa_offset 64
jeffhaofa147e22012-10-12 17:03:32 -070035 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080036 .cfi_rel_offset 31, 60
jeffhaofa147e22012-10-12 17:03:32 -070037 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080038 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070039 sw $gp, 52($sp)
40 .cfi_rel_offset 28, 52
41 sw $s7, 48($sp)
42 .cfi_rel_offset 23, 48
43 sw $s6, 44($sp)
44 .cfi_rel_offset 22, 44
45 sw $s5, 40($sp)
46 .cfi_rel_offset 21, 40
47 sw $s4, 36($sp)
48 .cfi_rel_offset 20, 36
49 sw $s3, 32($sp)
50 .cfi_rel_offset 19, 32
51 sw $s2, 28($sp)
52 .cfi_rel_offset 18, 28
53 sw $s1, 24($sp)
54 .cfi_rel_offset 17, 24
55 sw $s0, 20($sp)
56 .cfi_rel_offset 16, 20
57 # 1 word for alignment, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080058.endm
59
60 /*
61 * Macro that sets up the callee save frame to conform with
62 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
63 * Does not include rSUSPEND or rSELF
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070064 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 3 words padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080065 */
66.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070067 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080068 .cfi_adjust_cfa_offset 64
jeffhao4eb68ed2012-10-17 16:41:07 -070069 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080070 .cfi_rel_offset 31, 60
jeffhao4eb68ed2012-10-17 16:41:07 -070071 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080072 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070073 sw $gp, 52($sp)
74 .cfi_rel_offset 28, 52
75 sw $s7, 48($sp)
76 .cfi_rel_offset 23, 48
77 sw $s6, 44($sp)
78 .cfi_rel_offset 22, 44
79 sw $s5, 40($sp)
80 .cfi_rel_offset 21, 40
81 sw $s4, 36($sp)
82 .cfi_rel_offset 20, 36
83 sw $s3, 32($sp)
84 .cfi_rel_offset 19, 32
85 sw $s2, 28($sp)
86 .cfi_rel_offset 18, 28
jeffhaofc6a30e2012-10-18 18:24:15 -070087 # 3 words for alignment and extra args, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080088.endm
89
90.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070091 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080092 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070093 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080094 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070095 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080096 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070097 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080098 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070099 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800100 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700101 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800102 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700103 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800104 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700105 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800106 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700107 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800108 .cfi_restore 18
jeffhao4eb68ed2012-10-17 16:41:07 -0700109 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800110 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800111.endm
112
113.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -0700114 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800115 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700116 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800117 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700118 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800119 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700120 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800121 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700122 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800123 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700124 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800125 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700126 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800127 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700128 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800129 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700130 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800131 .cfi_restore 18
jeffhao7fbee072012-08-24 17:56:54 -0700132 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700133 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800134 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800135.endm
136
137 /*
138 * Macro that sets up the callee save frame to conform with
139 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700140 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800141 */
142.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700143 addiu $sp, $sp, -64
144 .cfi_adjust_cfa_offset 64
145 sw $ra, 60($sp)
146 .cfi_rel_offset 31, 60
147 sw $s8, 56($sp)
148 .cfi_rel_offset 30, 56
149 sw $gp, 52($sp)
150 .cfi_rel_offset 28, 52
151 sw $s7, 48($sp)
152 .cfi_rel_offset 23, 48
153 sw $s6, 44($sp)
154 .cfi_rel_offset 22, 44
155 sw $s5, 40($sp)
156 .cfi_rel_offset 21, 40
157 sw $s4, 36($sp)
158 .cfi_rel_offset 20, 36
159 sw $s3, 32($sp)
160 .cfi_rel_offset 19, 32
161 sw $s2, 28($sp)
162 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700163 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800164 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700165 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800166 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700167 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800168 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700169 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800170.endm
171
172.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700173 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800174 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700175 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800176 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700177 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800178 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700179 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800180 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700181 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800182 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700183 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800184 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700185 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800186 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700187 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800188 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700189 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800190 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700191 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800192 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700193 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800194 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700195 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800196 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700197 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700198 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800199.endm
200
201 /*
202 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
203 * exception is Thread::Current()->exception_
204 */
205.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700206 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
207 move $a0, rSELF # pass Thread::Current
208 la $t9, artDeliverPendingExceptionFromCode
209 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
210 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800211.endm
212
213.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700214 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800215 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700216 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800217 nop
jeffhao7fbee072012-08-24 17:56:54 -0700218 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800219 nop
2201:
221 DELIVER_PENDING_EXCEPTION
222.endm
223
224.macro RETURN_IF_ZERO
225 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700226 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800227 nop
jeffhao7fbee072012-08-24 17:56:54 -0700228 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800229 nop
2301:
231 DELIVER_PENDING_EXCEPTION
232.endm
233
234.macro RETURN_IF_NONZERO
235 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700236 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800237 nop
jeffhao7fbee072012-08-24 17:56:54 -0700238 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800239 nop
2401:
241 DELIVER_PENDING_EXCEPTION
242.endm
243
buzbee5bc5a7b2012-03-07 15:52:59 -0800244 /*
jeffhao7fbee072012-08-24 17:56:54 -0700245 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800246 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
247 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800248ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700249 l.s $f0, 0($a1)
250 l.s $f1, 4($a1)
251 l.s $f2, 8($a1)
252 l.s $f3, 12($a1)
253 l.s $f4, 16($a1)
254 l.s $f5, 20($a1)
255 l.s $f6, 24($a1)
256 l.s $f7, 28($a1)
257 l.s $f8, 32($a1)
258 l.s $f9, 36($a1)
259 l.s $f10, 40($a1)
260 l.s $f11, 44($a1)
261 l.s $f12, 48($a1)
262 l.s $f13, 52($a1)
263 l.s $f14, 56($a1)
264 l.s $f15, 60($a1)
265 l.s $f16, 64($a1)
266 l.s $f17, 68($a1)
267 l.s $f18, 72($a1)
268 l.s $f19, 76($a1)
269 l.s $f20, 80($a1)
270 l.s $f21, 84($a1)
271 l.s $f22, 88($a1)
272 l.s $f23, 92($a1)
273 l.s $f24, 96($a1)
274 l.s $f25, 100($a1)
275 l.s $f26, 104($a1)
276 l.s $f27, 108($a1)
277 l.s $f28, 112($a1)
278 l.s $f29, 116($a1)
279 l.s $f30, 120($a1)
280 l.s $f31, 124($a1)
281 lw $at, 4($a0)
282 lw $v0, 8($a0)
283 lw $v1, 12($a0)
284 lw $a1, 20($a0)
285 lw $a2, 24($a0)
286 lw $a3, 28($a0)
287 lw $t0, 32($a0)
288 lw $t1, 36($a0)
289 lw $t2, 40($a0)
290 lw $t3, 44($a0)
291 lw $t4, 48($a0)
292 lw $t5, 52($a0)
293 lw $t6, 56($a0)
294 lw $t7, 60($a0)
295 lw $s0, 64($a0)
296 lw $s1, 68($a0)
297 lw $s2, 72($a0)
298 lw $s3, 76($a0)
299 lw $s4, 80($a0)
300 lw $s5, 84($a0)
301 lw $s6, 88($a0)
302 lw $s7, 92($a0)
303 lw $t8, 96($a0)
304 lw $t9, 100($a0)
305 lw $k0, 104($a0)
306 lw $k1, 108($a0)
307 lw $gp, 112($a0)
308 lw $sp, 116($a0)
309 lw $fp, 120($a0)
310 lw $ra, 124($a0)
311 lw $a0, 16($a0)
312 move $v0, $zero # clear result registers r0 and r1
313 jr $ra # do long jump
314 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800315END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800316
buzbee5bc5a7b2012-03-07 15:52:59 -0800317 /*
318 * Called by managed code, saves most registers (forms basis of long jump context) and passes
319 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
320 * the bottom of the thread. On entry r0 holds Throwable*
321 */
Ian Rogers468532e2013-08-05 10:56:33 -0700322ENTRY art_quick_deliver_exception
jeffhao12051ea2013-01-10 11:24:31 -0800323 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700324 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700325 move $a1, rSELF # pass Thread::Current
326 la $t9, artDeliverExceptionFromCode
327 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
328 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700329END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800330
buzbee5bc5a7b2012-03-07 15:52:59 -0800331 /*
332 * Called by managed code to create and deliver a NullPointerException
333 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800334 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700335ENTRY art_quick_throw_null_pointer_exception
jeffhao12051ea2013-01-10 11:24:31 -0800336 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700337art_quick_throw_null_pointer_exception_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700338 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700339 move $a0, rSELF # pass Thread::Current
340 la $t9, artThrowNullPointerExceptionFromCode
341 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
342 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700343END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800344
buzbee5bc5a7b2012-03-07 15:52:59 -0800345 /*
346 * Called by managed code to create and deliver an ArithmeticException
347 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800348 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700349ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800350 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700351 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700352 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700353 la $t9, artThrowDivZeroFromCode
354 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700355 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700356END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800357
buzbee5bc5a7b2012-03-07 15:52:59 -0800358 /*
359 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
360 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800361 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700362ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800363 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700364art_quick_throw_array_bounds_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700365 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700366 move $a2, rSELF # pass Thread::Current
367 la $t9, artThrowArrayBoundsFromCode
368 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
369 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700370END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800371
Ian Rogers57b86d42012-03-27 16:05:41 -0700372 /*
373 * Called by managed code to create and deliver a StackOverflowError.
374 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800375 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700376ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800377 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700378 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700379 move $a0, rSELF # pass Thread::Current
380 la $t9, artThrowStackOverflowFromCode
381 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
382 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700383END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800384
Ian Rogers57b86d42012-03-27 16:05:41 -0700385 /*
386 * Called by managed code to create and deliver a NoSuchMethodError.
387 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800388 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700389ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800390 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700391 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700392 move $a1, rSELF # pass Thread::Current
393 la $t9, artThrowNoSuchMethodFromCode
394 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
395 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700396END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800397
buzbee5bc5a7b2012-03-07 15:52:59 -0800398 /*
399 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700400 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800401 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
402 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700403 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800404 *
jeffhao7fbee072012-08-24 17:56:54 -0700405 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
406 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800407 *
jeffhaofa147e22012-10-12 17:03:32 -0700408 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800409 * thread and we branch to another stub to deliver it.
410 *
411 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
412 * pointing back to the original caller.
413 */
414.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800415 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800416ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800417 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700418 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700419 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700420 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700421 addiu $sp, $sp, -32 # make space for extra args
422 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700423 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800424 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700425 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700426 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700427 addiu $sp, $sp, 32 # release out args
428 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700429 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700430 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800431 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700432 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800433 nop
jeffhao30a33172012-10-22 18:16:22 -0700434 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800435 nop
4361:
437 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800438END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800439.endm
440
Logan Chien8dbb7082013-01-25 20:31:17 +0800441INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
442INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800443
Logan Chien8dbb7082013-01-25 20:31:17 +0800444INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
445INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
446INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
447INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800448
Jeff Hao79fe5392013-04-24 18:41:58 -0700449 /*
Jeff Hao6474d192013-03-26 14:08:09 -0700450 * Common invocation stub for portable and quick.
Jeff Hao5d917302013-02-27 17:57:33 -0800451 * On entry:
452 * a0 = method pointer
453 * a1 = argument array or NULL for no argument methods
454 * a2 = size of argument array in bytes
455 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700456 * [sp + 16] = JValue* result
457 * [sp + 20] = result type char
Jeff Hao5d917302013-02-27 17:57:33 -0800458 */
Jeff Hao79fe5392013-04-24 18:41:58 -0700459 .type art_portable_invoke_stub, %function
460 .global art_portable_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700461art_portable_invoke_stub:
Jeff Hao5d917302013-02-27 17:57:33 -0800462ENTRY art_quick_invoke_stub
463 GENERATE_GLOBAL_POINTER
464 sw $a0, 0($sp) # save out a0
465 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
466 .cfi_adjust_cfa_offset 16
467 sw $ra, 12($sp)
468 .cfi_rel_offset 31, 12
469 sw $fp, 8($sp)
470 .cfi_rel_offset 30, 8
471 sw $s1, 4($sp)
472 .cfi_rel_offset 17, 4
473 sw $s0, 0($sp)
474 .cfi_rel_offset 16, 0
475 move $fp, $sp # save sp in fp
476 .cfi_def_cfa_register 30
477 move $s1, $a3 # move managed thread pointer into s1
478 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
479 addiu $t0, $a2, 16 # create space for method pointer in frame
480 srl $t0, $t0, 3 # shift the frame size right 3
481 sll $t0, $t0, 3 # shift the frame size left 3 to align to 16 bytes
482 subu $sp, $sp, $t0 # reserve stack space for argument array
483 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
484 jal memcpy # (dest, src, bytes)
485 addiu $sp, $sp, -16 # make space for argument slots for memcpy
486 addiu $sp, $sp, 16 # restore stack after memcpy
487 lw $a0, 16($fp) # restore method*
488 lw $a1, 4($sp) # copy arg value for a1
489 lw $a2, 8($sp) # copy arg value for a2
490 lw $a3, 12($sp) # copy arg value for a3
491 lw $t9, METHOD_CODE_OFFSET($a0) # get pointer to the code
492 jalr $t9 # call the method
493 sw $zero, 0($sp) # store NULL for method* at bottom of frame
494 move $sp, $fp # restore the stack
495 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800496 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800497 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800498 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800499 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800500 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800501 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800502 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800503 addiu $sp, $sp, 16
504 .cfi_adjust_cfa_offset -16
505 lw $t0, 16($sp) # get result pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700506 lw $t1, 20($sp) # get result type char
507 li $t2, 68 # put char 'D' into t2
508 beq $t1, $t2, 1f # branch if result type char == 'D'
509 li $t3, 70 # put char 'F' into t3
510 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800511 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700512 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800513 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005141:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700515 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800516 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700517 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800518END art_quick_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700519 .size art_portable_invoke_stub, .-art_portable_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800520
521 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800522 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
523 * failure.
524 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800525 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700526ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800527 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700528 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
529 move $a2, rSELF # pass Thread::Current
530 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
531 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700532 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700533END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800534
buzbee5bc5a7b2012-03-07 15:52:59 -0800535 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700536 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800537 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800538 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700539ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800540 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700541 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
542 nop
jeffhao7fbee072012-08-24 17:56:54 -0700543 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
544 move $a1, rSELF # pass Thread::Current
545 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
546 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700547 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700548END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800549
buzbee5bc5a7b2012-03-07 15:52:59 -0800550 /*
551 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
552 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800553 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700554ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800555 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700556 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
557 nop
jeffhao7fbee072012-08-24 17:56:54 -0700558 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
559 move $a1, rSELF # pass Thread::Current
560 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
561 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800562 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700563END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800564
buzbee5bc5a7b2012-03-07 15:52:59 -0800565 /*
566 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
567 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700568 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700569ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800570 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700571 addiu $sp, $sp, -16
572 .cfi_adjust_cfa_offset 16
573 sw $ra, 12($sp)
574 .cfi_rel_offset 31, 12
575 sw $t9, 8($sp)
576 sw $a1, 4($sp)
577 sw $a0, 0($sp)
578 jal artIsAssignableFromCode
579 nop
580 beqz $v0, throw_class_cast_exception
581 lw $ra, 12($sp)
582 jr $ra
583 addiu $sp, $sp, 16
584 .cfi_adjust_cfa_offset -16
585throw_class_cast_exception:
586 lw $t9, 8($sp)
587 lw $a1, 4($sp)
588 lw $a0, 0($sp)
589 addiu $sp, $sp, 16
590 .cfi_adjust_cfa_offset -16
591 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
592 move $a2, rSELF # pass Thread::Current
593 la $t9, artThrowClassCastException
594 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
595 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700596END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800597
buzbee5bc5a7b2012-03-07 15:52:59 -0800598 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700599 * Entry from managed code for array put operations of objects where the value being stored
600 * needs to be checked for compatibility.
601 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800602 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700603ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800604 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700605 bnez $a0, art_quick_aput_obj_with_bound_check_gp_set
606 nop
607 b art_quick_throw_null_pointer_exception_gp_set
608 nop
609END art_quick_aput_obj_with_null_and_bound_check
610
611ENTRY art_quick_aput_obj_with_bound_check
612 GENERATE_GLOBAL_POINTER
613art_quick_aput_obj_with_bound_check_gp_set:
614 lw $t0, ARRAY_LENGTH_OFFSET($a0)
615 sltu $t1, $a1, $t0
616 bnez $t1, art_quick_aput_obj_gp_set
617 nop
618 move $a0, $a1
619 b art_quick_throw_array_bounds_gp_set
620 move $a1, $t0
621END art_quick_aput_obj_with_bound_check
622
623ENTRY art_quick_aput_obj
624 GENERATE_GLOBAL_POINTER
625art_quick_aput_obj_gp_set:
626 beqz $a2, do_aput_null
627 nop
628 lw $t0, CLASS_OFFSET($a0)
629 lw $t1, CLASS_OFFSET($a2)
630 lw $t0, CLASS_COMPONENT_TYPE_OFFSET($t0)
631 bne $t1, $t0, check_assignability # value's type == array's component type - trivial assignability
632 nop
633do_aput:
634 sll $a1, $a1, 2
635 add $t0, $a0, $a1
636 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
637 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
638 srl $t1, $a0, 7
639 add $t1, $t1, $t0
640 sb $t0, ($t1)
641 jr $ra
642 nop
643do_aput_null:
644 sll $a1, $a1, 2
645 add $t0, $a0, $a1
646 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
647 jr $ra
648 nop
649check_assignability:
650 addiu $sp, $sp, -32
651 .cfi_adjust_cfa_offset 32
652 sw $ra, 28($sp)
653 .cfi_rel_offset 31, 28
654 sw $t9, 12($sp)
655 sw $a2, 8($sp)
656 sw $a1, 4($sp)
657 sw $a0, 0($sp)
658 move $a1, $t1
659 move $a0, $t0
660 jal artIsAssignableFromCode # (Class*, Class*)
661 nop
662 lw $ra, 28($sp)
663 lw $t9, 12($sp)
664 lw $a2, 8($sp)
665 lw $a1, 4($sp)
666 lw $a0, 0($sp)
667 add $sp, 32
668 .cfi_adjust_cfa_offset -32
669 bnez $v0, do_aput
670 nop
671 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
672 move $a1, $a2
673 move $a2, rSELF # pass Thread::Current
674 la $t9, artThrowArrayStoreException
675 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
676 move $a3, $sp # pass $sp
677END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800678
buzbee5bc5a7b2012-03-07 15:52:59 -0800679 /*
680 * Entry from managed code when uninitialized static storage, this stub will run the class
681 * initializer and deliver the exception on error. On success the static storage base is
682 * returned.
683 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800684 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700685ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800686 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700687 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
688 move $a2, rSELF # pass Thread::Current
689 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800690 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700691 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800692 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700693END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800694
buzbee5bc5a7b2012-03-07 15:52:59 -0800695 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700696 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800697 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800698 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700699ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800700 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700701 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
702 move $a2, rSELF # pass Thread::Current
703 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800704 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700705 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800706 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700707END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800708
buzbee5bc5a7b2012-03-07 15:52:59 -0800709 /*
710 * 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 -0700711 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800712 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800713 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700714ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800715 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700716 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
717 move $a2, rSELF # pass Thread::Current
718 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800719 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700720 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800721 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700722END art_quick_initialize_type_and_verify_access
buzbee5bc5a7b2012-03-07 15:52:59 -0800723
buzbee5bc5a7b2012-03-07 15:52:59 -0800724 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700725 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800726 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800727 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700728ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800729 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700730 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700731 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700732 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700733 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700734 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800735 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700736END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800737
buzbee5bc5a7b2012-03-07 15:52:59 -0800738 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700739 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800740 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800741 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700742ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800743 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700744 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700745 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700746 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700747 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700748 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800749 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700750END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800751
buzbee5bc5a7b2012-03-07 15:52:59 -0800752 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700753 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800754 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800755 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700756ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800757 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700758 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700759 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700760 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700761 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700762 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800763 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700764END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800765
buzbee5bc5a7b2012-03-07 15:52:59 -0800766 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700767 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800768 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800769 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700770ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800771 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700772 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700773 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700774 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700775 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700776 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800777 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700778END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800779
buzbee5bc5a7b2012-03-07 15:52:59 -0800780 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700781 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800783 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700784ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800785 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700786 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700787 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700788 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700789 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700790 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800791 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700792END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800793
buzbee5bc5a7b2012-03-07 15:52:59 -0800794 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700795 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800797 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700798ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800799 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700800 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700801 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700802 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700803 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700804 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800805 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700806END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800807
buzbee5bc5a7b2012-03-07 15:52:59 -0800808 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700809 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800811 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700812ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800813 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700814 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700815 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700816 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700817 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700818 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800819 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700820END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800821
buzbee5bc5a7b2012-03-07 15:52:59 -0800822 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700823 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800824 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800825 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700826ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800827 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700828 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700829 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700830 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700831 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700832 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800833 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700834END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800835
buzbee5bc5a7b2012-03-07 15:52:59 -0800836 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700837 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800838 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800839 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700840ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800841 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700842 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700843 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700844 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700845 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700846 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800847 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700848END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800849
buzbee5bc5a7b2012-03-07 15:52:59 -0800850 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700851 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800852 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800853 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700854ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800855 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700856 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700857 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700858 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700859 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700860 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800861 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700862END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800863
buzbee5bc5a7b2012-03-07 15:52:59 -0800864 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700865 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800867 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700868ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800869 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700870 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700871 sw rSELF, 16($sp) # pass Thread::Current
872 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700873 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800874 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700875END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800876
buzbee5bc5a7b2012-03-07 15:52:59 -0800877 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700878 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800879 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800880 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700881ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800882 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700883 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700884 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700885 sw rSELF, 16($sp) # pass Thread::Current
886 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700887 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800888 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700889END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800890
buzbee5bc5a7b2012-03-07 15:52:59 -0800891 /*
892 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
893 * exception on error. On success the String is returned. R0 holds the referring method,
894 * R1 holds the string index. The fast path check for hit in strings cache has already been
895 * performed.
896 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800897 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700898ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -0800899 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700900 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
901 move $a2, rSELF # pass Thread::Current
902 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800903 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700904 move $a3, $sp # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700905 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700906END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -0800907
buzbee5bc5a7b2012-03-07 15:52:59 -0800908 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700909 * Called by managed code to allocate an object.
buzbee5bc5a7b2012-03-07 15:52:59 -0800910 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800911 .extern artAllocObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700912ENTRY art_quick_alloc_object
jeffhao12051ea2013-01-10 11:24:31 -0800913 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700914 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
915 move $a2, rSELF # pass Thread::Current
916 jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp)
917 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800918 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700919END art_quick_alloc_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800920
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700921 .extern artAllocObjectFromCodeInstrumented
922ENTRY art_quick_alloc_object_instrumented
923 GENERATE_GLOBAL_POINTER
924 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
925 move $a2, rSELF # pass Thread::Current
926 jal artAllocObjectFromCodeInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
927 move $a3, $sp # pass $sp
928 RETURN_IF_NONZERO
929END art_quick_alloc_object_instrumented
930
buzbee5bc5a7b2012-03-07 15:52:59 -0800931 /*
932 * Called by managed code to allocate an object when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700933 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800934 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800935 .extern artAllocObjectFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700936ENTRY art_quick_alloc_object_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800937 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700938 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
939 move $a2, rSELF # pass Thread::Current
940 jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp)
941 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800942 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700943END art_quick_alloc_object_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800944
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700945 .extern artAllocObjectFromCodeWithAccessCheckInstrumented
946ENTRY art_quick_alloc_object_with_access_check_instrumented
947 GENERATE_GLOBAL_POINTER
948 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
949 move $a2, rSELF # pass Thread::Current
950 jal artAllocObjectFromCodeWithAccessCheckInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
951 move $a3, $sp # pass $sp
952 RETURN_IF_NONZERO
953END art_quick_alloc_object_with_access_check_instrumented
954
buzbee5bc5a7b2012-03-07 15:52:59 -0800955 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700956 * Called by managed code to allocate an array.
buzbee5bc5a7b2012-03-07 15:52:59 -0800957 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800958 .extern artAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700959ENTRY art_quick_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800960 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700961 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
962 move $a3, rSELF # pass Thread::Current
963 # artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800964 jal artAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700965 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800966 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700967END art_quick_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800968
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700969 .extern artAllocArrayFromCodeInstrumented
970ENTRY art_quick_alloc_array_instrumented
971 GENERATE_GLOBAL_POINTER
972 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
973 move $a3, rSELF # pass Thread::Current
974 # artAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
975 jal artAllocArrayFromCodeInstrumented
976 sw $sp, 16($sp) # pass $sp
977 RETURN_IF_NONZERO
978END art_quick_alloc_array_instrumented
979
buzbee5bc5a7b2012-03-07 15:52:59 -0800980 /*
981 * Called by managed code to allocate an array when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700982 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800983 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800984 .extern artAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700985ENTRY art_quick_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800986 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700987 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
988 move $a3, rSELF # pass Thread::Current
989 # artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800990 jal artAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700991 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800992 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700993END art_quick_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800994
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700995 .extern artAllocArrayFromCodeWithAccessCheckInstrumented
996ENTRY art_quick_alloc_array_with_access_check_instrumented
997 GENERATE_GLOBAL_POINTER
998 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
999 move $a3, rSELF # pass Thread::Current
1000 # artAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, component_count, Thread*, $sp)
1001 jal artAllocArrayFromCodeWithAccessCheckInstrumented
1002 sw $sp, 16($sp) # pass $sp
1003 RETURN_IF_NONZERO
1004END art_quick_alloc_array_with_access_check_instrumented
1005
buzbee5bc5a7b2012-03-07 15:52:59 -08001006 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001007 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -08001008 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001009 .extern artCheckAndAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001010ENTRY art_quick_check_and_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -08001011 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001012 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1013 move $a3, rSELF # pass Thread::Current
1014 # artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -08001015 jal artCheckAndAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -07001016 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001017 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001018END art_quick_check_and_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -08001019
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001020 .extern artCheckAndAllocArrayFromCodeInstrumented
1021ENTRY art_quick_check_and_alloc_array_instrumented
1022 GENERATE_GLOBAL_POINTER
1023 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1024 move $a3, rSELF # pass Thread::Current
1025 # artCheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
1026 jal artCheckAndAllocArrayFromCodeInstrumented
1027 sw $sp, 16($sp) # pass $sp
1028 RETURN_IF_NONZERO
1029END art_quick_check_and_alloc_array_instrumented
1030
buzbee5bc5a7b2012-03-07 15:52:59 -08001031 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001032 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -08001033 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001034 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -07001035ENTRY art_quick_check_and_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -08001036 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001037 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -07001038 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -07001039 # artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -08001040 jal artCheckAndAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -07001041 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001042 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001043END art_quick_check_and_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -08001044
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001045 .extern artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
1046ENTRY art_quick_check_and_alloc_array_with_access_check_instrumented
1047 GENERATE_GLOBAL_POINTER
1048 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1049 move $a3, rSELF # pass Thread::Current
1050 # artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, count, Thread* , $sp)
1051 jal artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
1052 sw $sp, 16($sp) # pass $sp
1053 RETURN_IF_NONZERO
1054END art_quick_check_and_alloc_array_with_access_check_instrumented
1055
buzbee5bc5a7b2012-03-07 15:52:59 -08001056 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001057 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001058 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001059 .extern artTestSuspendFromCode
1060ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -08001061 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -07001062 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001063 bnez $a0, 1f
1064 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1065 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001066 nop
10671:
jeffhao7fbee072012-08-24 17:56:54 -07001068 move $a0, rSELF
1069 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1070 jal artTestSuspendFromCode # (Thread*, $sp)
1071 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001072 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001073END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001074
buzbee5bc5a7b2012-03-07 15:52:59 -08001075 /*
1076 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001077 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001078 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001079 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001080ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -08001081 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -08001082 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001083 sw $a0, 0($sp) # place proxy method at bottom of frame
1084 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001085 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001086 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001087 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001088 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001089 bnez $t0, 1f
Mathieu Chartier19841522013-10-22 11:29:00 -07001090 nop
jeffhao7fbee072012-08-24 17:56:54 -07001091 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001092 nop
10931:
1094 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001095END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001096
Jeff Hao88474b42013-10-23 16:24:40 -07001097 /*
1098 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1099 * dex method index.
1100 */
1101ENTRY art_quick_imt_conflict_trampoline
1102 GENERATE_GLOBAL_POINTER
1103 lw $a0, 0($sp) # load caller Method*
1104 lw $a0, METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
1105 sll $t0, 2 # convert target method offset to bytes
1106 add $a0, $t0 # get address of target method
1107 lw $a0, OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
1108 la $t9, art_quick_invoke_interface_trampoline
1109 jr $t9
1110END art_quick_imt_conflict_trampoline
1111
Ian Rogers468532e2013-08-05 10:56:33 -07001112 .extern artQuickResolutionTrampoline
1113ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001114 GENERATE_GLOBAL_POINTER
1115 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001116 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001117 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001118 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001119 beqz $v0, 1f
1120 lw $a0, 0($sp) # load resolved method to $a0
Mathieu Chartier19841522013-10-22 11:29:00 -07001121 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001122 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001123 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001124 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011251:
Mathieu Chartier19841522013-10-22 11:29:00 -07001126 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001127 DELIVER_PENDING_EXCEPTION
1128END art_quick_resolution_trampoline
1129
1130 .extern artQuickToInterpreterBridge
1131ENTRY art_quick_to_interpreter_bridge
1132 GENERATE_GLOBAL_POINTER
1133 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001134 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001135 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001136 move $a2, $sp # pass $sp
1137 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001138 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001139 bnez $t0, 1f
Mathieu Chartier19841522013-10-22 11:29:00 -07001140 nop
Ian Rogers7db619b2013-01-16 18:35:48 -08001141 jr $ra
1142 nop
11431:
1144 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001145END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001146
buzbee5bc5a7b2012-03-07 15:52:59 -08001147 /*
jeffhao725a9572012-11-13 18:20:12 -08001148 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001149 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001150 .extern artInstrumentationMethodEntryFromCode
1151 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001152ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001153 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001154 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001155 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001156 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1157 .cfi_adjust_cfa_offset 32
1158 sw $a0, 28($sp) # save arg0
1159 sw $ra, 16($sp) # pass $ra
1160 move $a3, $t0 # pass $sp
1161 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1162 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001163 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001164 lw $a0, 28($sp) # restore arg0
1165 addiu $sp, $sp, 32 # remove args
1166 .cfi_adjust_cfa_offset -32
1167 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001168 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001169 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001170END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001171 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001172 .global art_quick_instrumentation_exit
1173art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001174 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001175 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1176 GENERATE_GLOBAL_POINTER
1177 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001178 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
1179 addiu $sp, $sp, -48 # save return values and set up args
1180 .cfi_adjust_cfa_offset 48
1181 sw $v0, 32($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001182 .cfi_rel_offset 2, 0
Ian Rogers62d6c772013-02-27 08:32:07 -08001183 sw $v1, 36($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001184 .cfi_rel_offset 3, 4
Ian Rogers62d6c772013-02-27 08:32:07 -08001185 s.s $f0, 40($sp)
1186 s.s $f1, 44($sp)
1187 s.s $f0, 16($sp) # pass fpr result
1188 s.s $f1, 20($sp)
1189 move $a2, $v0 # pass gpr result
1190 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001191 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001192 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001193 move $a0, rSELF # pass Thread::Current
1194 move $t0, $v0 # set aside returned link register
1195 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001196 lw $v0, 32($sp) # restore return values
1197 lw $v1, 36($sp)
1198 l.s $f0, 40($sp)
1199 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001200 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001201 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1202 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001203END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001204
jeffhao12051ea2013-01-10 11:24:31 -08001205 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001206 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1207 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001208 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001209 .extern artDeoptimize
1210 .extern artEnterInterpreterFromDeoptimize
1211ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001212 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001213 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001214 move $a0, rSELF # pass Thread::current
1215 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001216 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001217 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001218END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001219
buzbee5bc5a7b2012-03-07 15:52:59 -08001220 /*
1221 * Long integer shift. This is different from the generic 32/64-bit
1222 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1223 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1224 * 6 bits.
1225 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001226 * $a0: low word
1227 * $a1: high word
1228 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001229 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001230ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001231 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001232 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1233 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1234 srl $a0, 1
1235 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1236 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1237 or $v1, $a0 # rhi<- rhi | alo
1238 andi $a2, 0x20 # shift< shift & 0x20
1239 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1240 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001241 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001242END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001243
buzbee5bc5a7b2012-03-07 15:52:59 -08001244 /*
1245 * Long integer shift. This is different from the generic 32/64-bit
1246 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1247 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1248 * 6 bits.
1249 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001250 * $a0: low word
1251 * $a1: high word
1252 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001253 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001254 .global art_quick_shr_long
1255ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001256 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1257 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1258 sra $a3, $a1, 31 # $a3<- sign(ah)
1259 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1260 sll $a1, 1
1261 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1262 or $v0, $a1 # rlo<- rlo | ahi
1263 andi $a2, 0x20 # shift & 0x20
1264 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1265 jr $ra
1266 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001267END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001268
buzbee5bc5a7b2012-03-07 15:52:59 -08001269 /*
1270 * Long integer shift. This is different from the generic 32/64-bit
1271 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1272 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1273 * 6 bits.
1274 * On entry:
1275 * r0: low word
1276 * r1: high word
1277 * r2: shift count
1278 */
1279 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001280 .global art_quick_ushr_long
1281ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001282 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001283 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001284 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1285 sll $a1, 1
1286 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1287 or $v0, $a1 # rlo<- rlo | ahi
1288 andi $a2, 0x20 # shift & 0x20
1289 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1290 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001291 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001292END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001293
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001294ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001295 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001296 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001297END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001298
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001299ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001300 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001301 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001302END art_quick_string_compareto