blob: 2d1e87aa6820a641fc7ef993f1a058bd76427340 [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
jeffhaofa147e22012-10-12 17:03:32 -070037 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080038 .cfi_rel_offset 31, 60
jeffhaofa147e22012-10-12 17:03:32 -070039 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080040 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070041 sw $gp, 52($sp)
42 .cfi_rel_offset 28, 52
43 sw $s7, 48($sp)
44 .cfi_rel_offset 23, 48
45 sw $s6, 44($sp)
46 .cfi_rel_offset 22, 44
47 sw $s5, 40($sp)
48 .cfi_rel_offset 21, 40
49 sw $s4, 36($sp)
50 .cfi_rel_offset 20, 36
51 sw $s3, 32($sp)
52 .cfi_rel_offset 19, 32
53 sw $s2, 28($sp)
54 .cfi_rel_offset 18, 28
55 sw $s1, 24($sp)
56 .cfi_rel_offset 17, 24
57 sw $s0, 20($sp)
58 .cfi_rel_offset 16, 20
59 # 1 word for alignment, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080060.endm
61
62 /*
63 * Macro that sets up the callee save frame to conform with
64 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
65 * Does not include rSUSPEND or rSELF
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070066 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 3 words padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080067 */
68.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070069 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080070 .cfi_adjust_cfa_offset 64
jeffhao4eb68ed2012-10-17 16:41:07 -070071 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080072 .cfi_rel_offset 31, 60
jeffhao4eb68ed2012-10-17 16:41:07 -070073 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080074 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070075 sw $gp, 52($sp)
76 .cfi_rel_offset 28, 52
77 sw $s7, 48($sp)
78 .cfi_rel_offset 23, 48
79 sw $s6, 44($sp)
80 .cfi_rel_offset 22, 44
81 sw $s5, 40($sp)
82 .cfi_rel_offset 21, 40
83 sw $s4, 36($sp)
84 .cfi_rel_offset 20, 36
85 sw $s3, 32($sp)
86 .cfi_rel_offset 19, 32
87 sw $s2, 28($sp)
88 .cfi_rel_offset 18, 28
jeffhaofc6a30e2012-10-18 18:24:15 -070089 # 3 words for alignment and extra args, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080090.endm
91
92.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070093 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080094 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070095 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080096 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070097 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -080098 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070099 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800100 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700101 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800102 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700103 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800104 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700105 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800106 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700107 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800108 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700109 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800110 .cfi_restore 18
jeffhao4eb68ed2012-10-17 16:41:07 -0700111 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800112 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800113.endm
114
115.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -0700116 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800117 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700118 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800119 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700120 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800121 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700122 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800123 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700124 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800125 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700126 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800127 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700128 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800129 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700130 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800131 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700132 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800133 .cfi_restore 18
jeffhao7fbee072012-08-24 17:56:54 -0700134 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700135 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800136 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800137.endm
138
139 /*
140 * Macro that sets up the callee save frame to conform with
141 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700142 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800143 */
144.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700145 addiu $sp, $sp, -64
146 .cfi_adjust_cfa_offset 64
147 sw $ra, 60($sp)
148 .cfi_rel_offset 31, 60
149 sw $s8, 56($sp)
150 .cfi_rel_offset 30, 56
151 sw $gp, 52($sp)
152 .cfi_rel_offset 28, 52
153 sw $s7, 48($sp)
154 .cfi_rel_offset 23, 48
155 sw $s6, 44($sp)
156 .cfi_rel_offset 22, 44
157 sw $s5, 40($sp)
158 .cfi_rel_offset 21, 40
159 sw $s4, 36($sp)
160 .cfi_rel_offset 20, 36
161 sw $s3, 32($sp)
162 .cfi_rel_offset 19, 32
163 sw $s2, 28($sp)
164 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700165 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800166 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700167 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800168 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700169 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800170 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700171 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800172.endm
173
174.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700175 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800176 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700177 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800178 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700179 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800180 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700181 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800182 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700183 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800184 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700185 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800186 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700187 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800188 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700189 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800190 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700191 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800192 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700193 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800194 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700195 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800196 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700197 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800198 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700199 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700200 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800201.endm
202
203 /*
204 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
205 * exception is Thread::Current()->exception_
206 */
207.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700208 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
209 move $a0, rSELF # pass Thread::Current
210 la $t9, artDeliverPendingExceptionFromCode
211 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
212 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800213.endm
214
215.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700216 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800217 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700218 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800219 nop
jeffhao7fbee072012-08-24 17:56:54 -0700220 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800221 nop
2221:
223 DELIVER_PENDING_EXCEPTION
224.endm
225
226.macro RETURN_IF_ZERO
227 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700228 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800229 nop
jeffhao7fbee072012-08-24 17:56:54 -0700230 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800231 nop
2321:
233 DELIVER_PENDING_EXCEPTION
234.endm
235
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800236.macro RETURN_IF_RESULT_IS_NON_ZERO
buzbee5bc5a7b2012-03-07 15:52:59 -0800237 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700238 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800239 nop
jeffhao7fbee072012-08-24 17:56:54 -0700240 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800241 nop
2421:
243 DELIVER_PENDING_EXCEPTION
244.endm
245
buzbee5bc5a7b2012-03-07 15:52:59 -0800246 /*
jeffhao7fbee072012-08-24 17:56:54 -0700247 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800248 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
249 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800250ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700251 l.s $f0, 0($a1)
252 l.s $f1, 4($a1)
253 l.s $f2, 8($a1)
254 l.s $f3, 12($a1)
255 l.s $f4, 16($a1)
256 l.s $f5, 20($a1)
257 l.s $f6, 24($a1)
258 l.s $f7, 28($a1)
259 l.s $f8, 32($a1)
260 l.s $f9, 36($a1)
261 l.s $f10, 40($a1)
262 l.s $f11, 44($a1)
263 l.s $f12, 48($a1)
264 l.s $f13, 52($a1)
265 l.s $f14, 56($a1)
266 l.s $f15, 60($a1)
267 l.s $f16, 64($a1)
268 l.s $f17, 68($a1)
269 l.s $f18, 72($a1)
270 l.s $f19, 76($a1)
271 l.s $f20, 80($a1)
272 l.s $f21, 84($a1)
273 l.s $f22, 88($a1)
274 l.s $f23, 92($a1)
275 l.s $f24, 96($a1)
276 l.s $f25, 100($a1)
277 l.s $f26, 104($a1)
278 l.s $f27, 108($a1)
279 l.s $f28, 112($a1)
280 l.s $f29, 116($a1)
281 l.s $f30, 120($a1)
282 l.s $f31, 124($a1)
283 lw $at, 4($a0)
284 lw $v0, 8($a0)
285 lw $v1, 12($a0)
286 lw $a1, 20($a0)
287 lw $a2, 24($a0)
288 lw $a3, 28($a0)
289 lw $t0, 32($a0)
290 lw $t1, 36($a0)
291 lw $t2, 40($a0)
292 lw $t3, 44($a0)
293 lw $t4, 48($a0)
294 lw $t5, 52($a0)
295 lw $t6, 56($a0)
296 lw $t7, 60($a0)
297 lw $s0, 64($a0)
298 lw $s1, 68($a0)
299 lw $s2, 72($a0)
300 lw $s3, 76($a0)
301 lw $s4, 80($a0)
302 lw $s5, 84($a0)
303 lw $s6, 88($a0)
304 lw $s7, 92($a0)
305 lw $t8, 96($a0)
306 lw $t9, 100($a0)
307 lw $k0, 104($a0)
308 lw $k1, 108($a0)
309 lw $gp, 112($a0)
310 lw $sp, 116($a0)
311 lw $fp, 120($a0)
312 lw $ra, 124($a0)
313 lw $a0, 16($a0)
314 move $v0, $zero # clear result registers r0 and r1
315 jr $ra # do long jump
316 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800317END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800318
buzbee5bc5a7b2012-03-07 15:52:59 -0800319 /*
320 * Called by managed code, saves most registers (forms basis of long jump context) and passes
321 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
322 * the bottom of the thread. On entry r0 holds Throwable*
323 */
Ian Rogers468532e2013-08-05 10:56:33 -0700324ENTRY art_quick_deliver_exception
jeffhao12051ea2013-01-10 11:24:31 -0800325 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700326 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700327 move $a1, rSELF # pass Thread::Current
328 la $t9, artDeliverExceptionFromCode
329 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
330 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700331END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800332
buzbee5bc5a7b2012-03-07 15:52:59 -0800333 /*
334 * Called by managed code to create and deliver a NullPointerException
335 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800336 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700337ENTRY art_quick_throw_null_pointer_exception
jeffhao12051ea2013-01-10 11:24:31 -0800338 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700339art_quick_throw_null_pointer_exception_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700340 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700341 move $a0, rSELF # pass Thread::Current
342 la $t9, artThrowNullPointerExceptionFromCode
343 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
344 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700345END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800346
buzbee5bc5a7b2012-03-07 15:52:59 -0800347 /*
348 * Called by managed code to create and deliver an ArithmeticException
349 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800350 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700351ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800352 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700353 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700354 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700355 la $t9, artThrowDivZeroFromCode
356 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700357 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700358END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800359
buzbee5bc5a7b2012-03-07 15:52:59 -0800360 /*
361 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
362 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800363 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700364ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800365 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700366art_quick_throw_array_bounds_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700367 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700368 move $a2, rSELF # pass Thread::Current
369 la $t9, artThrowArrayBoundsFromCode
370 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
371 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700372END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800373
Ian Rogers57b86d42012-03-27 16:05:41 -0700374 /*
375 * Called by managed code to create and deliver a StackOverflowError.
376 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800377 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700378ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800379 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700380 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700381 move $a0, rSELF # pass Thread::Current
382 la $t9, artThrowStackOverflowFromCode
383 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
384 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700385END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800386
Ian Rogers57b86d42012-03-27 16:05:41 -0700387 /*
388 * Called by managed code to create and deliver a NoSuchMethodError.
389 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800390 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700391ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800392 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700393 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700394 move $a1, rSELF # pass Thread::Current
395 la $t9, artThrowNoSuchMethodFromCode
396 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
397 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700398END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800399
buzbee5bc5a7b2012-03-07 15:52:59 -0800400 /*
401 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700402 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800403 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
404 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700405 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800406 *
jeffhao7fbee072012-08-24 17:56:54 -0700407 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
408 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800409 *
jeffhaofa147e22012-10-12 17:03:32 -0700410 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800411 * thread and we branch to another stub to deliver it.
412 *
413 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
414 * pointing back to the original caller.
415 */
416.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800417 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800418ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800419 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700420 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700421 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700422 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700423 addiu $sp, $sp, -32 # make space for extra args
424 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700425 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800426 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700427 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700428 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700429 addiu $sp, $sp, 32 # release out args
430 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700431 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700432 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800433 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700434 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800435 nop
jeffhao30a33172012-10-22 18:16:22 -0700436 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800437 nop
4381:
439 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800440END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800441.endm
442
Logan Chien8dbb7082013-01-25 20:31:17 +0800443INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
444INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800445
Logan Chien8dbb7082013-01-25 20:31:17 +0800446INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
447INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
448INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
449INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800450
Jeff Hao79fe5392013-04-24 18:41:58 -0700451 /*
Jeff Hao6474d192013-03-26 14:08:09 -0700452 * Common invocation stub for portable and quick.
Jeff Hao5d917302013-02-27 17:57:33 -0800453 * On entry:
454 * a0 = method pointer
455 * a1 = argument array or NULL for no argument methods
456 * a2 = size of argument array in bytes
457 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700458 * [sp + 16] = JValue* result
459 * [sp + 20] = result type char
Jeff Hao5d917302013-02-27 17:57:33 -0800460 */
Jeff Hao79fe5392013-04-24 18:41:58 -0700461 .type art_portable_invoke_stub, %function
462 .global art_portable_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700463art_portable_invoke_stub:
Jeff Hao5d917302013-02-27 17:57:33 -0800464ENTRY art_quick_invoke_stub
465 GENERATE_GLOBAL_POINTER
466 sw $a0, 0($sp) # save out a0
467 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
468 .cfi_adjust_cfa_offset 16
469 sw $ra, 12($sp)
470 .cfi_rel_offset 31, 12
471 sw $fp, 8($sp)
472 .cfi_rel_offset 30, 8
473 sw $s1, 4($sp)
474 .cfi_rel_offset 17, 4
475 sw $s0, 0($sp)
476 .cfi_rel_offset 16, 0
477 move $fp, $sp # save sp in fp
478 .cfi_def_cfa_register 30
479 move $s1, $a3 # move managed thread pointer into s1
480 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
481 addiu $t0, $a2, 16 # create space for method pointer in frame
482 srl $t0, $t0, 3 # shift the frame size right 3
483 sll $t0, $t0, 3 # shift the frame size left 3 to align to 16 bytes
484 subu $sp, $sp, $t0 # reserve stack space for argument array
485 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
486 jal memcpy # (dest, src, bytes)
487 addiu $sp, $sp, -16 # make space for argument slots for memcpy
488 addiu $sp, $sp, 16 # restore stack after memcpy
489 lw $a0, 16($fp) # restore method*
490 lw $a1, 4($sp) # copy arg value for a1
491 lw $a2, 8($sp) # copy arg value for a2
492 lw $a3, 12($sp) # copy arg value for a3
493 lw $t9, METHOD_CODE_OFFSET($a0) # get pointer to the code
494 jalr $t9 # call the method
495 sw $zero, 0($sp) # store NULL for method* at bottom of frame
496 move $sp, $fp # restore the stack
497 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800498 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800499 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800500 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800501 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800502 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800503 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800504 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800505 addiu $sp, $sp, 16
506 .cfi_adjust_cfa_offset -16
507 lw $t0, 16($sp) # get result pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700508 lw $t1, 20($sp) # get result type char
509 li $t2, 68 # put char 'D' into t2
510 beq $t1, $t2, 1f # branch if result type char == 'D'
511 li $t3, 70 # put char 'F' into t3
512 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800513 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700514 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800515 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005161:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700517 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800518 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700519 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800520END art_quick_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700521 .size art_portable_invoke_stub, .-art_portable_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800522
523 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800524 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
525 * failure.
526 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800527 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700528ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800529 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700530 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
531 move $a2, rSELF # pass Thread::Current
532 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
533 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700534 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700535END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800536
buzbee5bc5a7b2012-03-07 15:52:59 -0800537 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700538 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800539 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800540 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700541ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800542 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700543 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
544 nop
jeffhao7fbee072012-08-24 17:56:54 -0700545 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
546 move $a1, rSELF # pass Thread::Current
547 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
548 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700549 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700550END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800551
buzbee5bc5a7b2012-03-07 15:52:59 -0800552 /*
553 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
554 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800555 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700556ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800557 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700558 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
559 nop
jeffhao7fbee072012-08-24 17:56:54 -0700560 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
561 move $a1, rSELF # pass Thread::Current
562 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
563 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700565END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800566
buzbee5bc5a7b2012-03-07 15:52:59 -0800567 /*
568 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
569 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700570 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700571ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800572 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700573 addiu $sp, $sp, -16
574 .cfi_adjust_cfa_offset 16
575 sw $ra, 12($sp)
576 .cfi_rel_offset 31, 12
577 sw $t9, 8($sp)
578 sw $a1, 4($sp)
579 sw $a0, 0($sp)
580 jal artIsAssignableFromCode
581 nop
582 beqz $v0, throw_class_cast_exception
583 lw $ra, 12($sp)
584 jr $ra
585 addiu $sp, $sp, 16
586 .cfi_adjust_cfa_offset -16
587throw_class_cast_exception:
588 lw $t9, 8($sp)
589 lw $a1, 4($sp)
590 lw $a0, 0($sp)
591 addiu $sp, $sp, 16
592 .cfi_adjust_cfa_offset -16
593 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
594 move $a2, rSELF # pass Thread::Current
595 la $t9, artThrowClassCastException
596 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
597 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700598END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800599
buzbee5bc5a7b2012-03-07 15:52:59 -0800600 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700601 * Entry from managed code for array put operations of objects where the value being stored
602 * needs to be checked for compatibility.
603 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800604 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700605ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800606 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700607 bnez $a0, art_quick_aput_obj_with_bound_check_gp_set
608 nop
609 b art_quick_throw_null_pointer_exception_gp_set
610 nop
611END art_quick_aput_obj_with_null_and_bound_check
612
613ENTRY art_quick_aput_obj_with_bound_check
614 GENERATE_GLOBAL_POINTER
615art_quick_aput_obj_with_bound_check_gp_set:
616 lw $t0, ARRAY_LENGTH_OFFSET($a0)
617 sltu $t1, $a1, $t0
618 bnez $t1, art_quick_aput_obj_gp_set
619 nop
620 move $a0, $a1
621 b art_quick_throw_array_bounds_gp_set
622 move $a1, $t0
623END art_quick_aput_obj_with_bound_check
624
625ENTRY art_quick_aput_obj
626 GENERATE_GLOBAL_POINTER
627art_quick_aput_obj_gp_set:
628 beqz $a2, do_aput_null
629 nop
630 lw $t0, CLASS_OFFSET($a0)
631 lw $t1, CLASS_OFFSET($a2)
632 lw $t0, CLASS_COMPONENT_TYPE_OFFSET($t0)
633 bne $t1, $t0, check_assignability # value's type == array's component type - trivial assignability
634 nop
635do_aput:
636 sll $a1, $a1, 2
637 add $t0, $a0, $a1
638 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
639 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
640 srl $t1, $a0, 7
641 add $t1, $t1, $t0
642 sb $t0, ($t1)
643 jr $ra
644 nop
645do_aput_null:
646 sll $a1, $a1, 2
647 add $t0, $a0, $a1
648 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
649 jr $ra
650 nop
651check_assignability:
652 addiu $sp, $sp, -32
653 .cfi_adjust_cfa_offset 32
654 sw $ra, 28($sp)
655 .cfi_rel_offset 31, 28
656 sw $t9, 12($sp)
657 sw $a2, 8($sp)
658 sw $a1, 4($sp)
659 sw $a0, 0($sp)
660 move $a1, $t1
661 move $a0, $t0
662 jal artIsAssignableFromCode # (Class*, Class*)
663 nop
664 lw $ra, 28($sp)
665 lw $t9, 12($sp)
666 lw $a2, 8($sp)
667 lw $a1, 4($sp)
668 lw $a0, 0($sp)
669 add $sp, 32
670 .cfi_adjust_cfa_offset -32
671 bnez $v0, do_aput
672 nop
673 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
674 move $a1, $a2
675 move $a2, rSELF # pass Thread::Current
676 la $t9, artThrowArrayStoreException
677 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
678 move $a3, $sp # pass $sp
679END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800680
buzbee5bc5a7b2012-03-07 15:52:59 -0800681 /*
682 * Entry from managed code when uninitialized static storage, this stub will run the class
683 * initializer and deliver the exception on error. On success the static storage base is
684 * returned.
685 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800686 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700687ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800688 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700689 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
690 move $a2, rSELF # pass Thread::Current
691 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800692 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700693 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800694 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700695END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800696
buzbee5bc5a7b2012-03-07 15:52:59 -0800697 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700698 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800699 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800700 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700701ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800702 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700703 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
704 move $a2, rSELF # pass Thread::Current
705 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800706 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700707 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800708 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700709END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800710
buzbee5bc5a7b2012-03-07 15:52:59 -0800711 /*
712 * 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 -0700713 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800714 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800715 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700716ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800717 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700718 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
719 move $a2, rSELF # pass Thread::Current
720 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800721 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700722 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800723 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700724END art_quick_initialize_type_and_verify_access
buzbee5bc5a7b2012-03-07 15:52:59 -0800725
buzbee5bc5a7b2012-03-07 15:52:59 -0800726 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700727 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800728 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800729 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700730ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800731 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700732 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700733 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700734 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700735 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700736 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800737 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700738END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800739
buzbee5bc5a7b2012-03-07 15:52:59 -0800740 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700741 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800742 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800743 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700744ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800745 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700746 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700747 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700748 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700749 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700750 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800751 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700752END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800753
buzbee5bc5a7b2012-03-07 15:52:59 -0800754 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700755 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800756 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800757 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700758ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800759 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700760 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700761 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700762 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700763 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700764 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800765 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700766END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800767
buzbee5bc5a7b2012-03-07 15:52:59 -0800768 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700769 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800770 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800771 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700772ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800773 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700774 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700775 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700776 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700777 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700778 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800779 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700780END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800781
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700783 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800784 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800785 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700786ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800787 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700788 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700789 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700790 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700791 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700792 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800793 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700794END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800795
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700797 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800798 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800799 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700800ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800801 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700802 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700803 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700804 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700805 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700806 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800807 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700808END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800809
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700811 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800812 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800813 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700814ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800815 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700816 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700817 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700818 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700819 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700820 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800821 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700822END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800823
buzbee5bc5a7b2012-03-07 15:52:59 -0800824 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700825 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800826 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800827 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700828ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800829 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700830 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700831 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700832 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700833 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700834 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800835 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700836END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800837
buzbee5bc5a7b2012-03-07 15:52:59 -0800838 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700839 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800840 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800841 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700842ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800843 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700844 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700845 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700846 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700847 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700848 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800849 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700850END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800851
buzbee5bc5a7b2012-03-07 15:52:59 -0800852 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700853 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800854 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800855 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700856ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800857 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700858 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700859 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700860 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700861 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700862 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800863 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700864END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800865
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700867 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800868 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800869 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700870ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800871 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700872 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700873 sw rSELF, 16($sp) # pass Thread::Current
874 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700875 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800876 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700877END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800878
buzbee5bc5a7b2012-03-07 15:52:59 -0800879 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700880 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800881 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800882 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700883ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800884 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700885 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700886 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700887 sw rSELF, 16($sp) # pass Thread::Current
888 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700889 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800890 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700891END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800892
buzbee5bc5a7b2012-03-07 15:52:59 -0800893 /*
894 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
895 * exception on error. On success the String is returned. R0 holds the referring method,
896 * R1 holds the string index. The fast path check for hit in strings cache has already been
897 * performed.
898 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800899 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700900ENTRY art_quick_resolve_string
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
903 move $a2, rSELF # pass Thread::Current
904 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800905 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700906 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800907 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700908END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -0800909
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800910
911// Macro to facilitate adding new allocation entrypoints.
912.macro TWO_ARG_DOWNCALL name, entrypoint, return
913 .extern \entrypoint
914ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -0800915 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700916 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
917 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800918 jal \entrypoint
jeffhao7fbee072012-08-24 17:56:54 -0700919 move $a3, $sp # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800920 \return
921END \name
922.endm
buzbee5bc5a7b2012-03-07 15:52:59 -0800923
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800924.macro THREE_ARG_DOWNCALL name, entrypoint, return
925 .extern \entrypoint
926ENTRY \name
jeffhao12051ea2013-01-10 11:24:31 -0800927 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700928 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
929 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800930 jal \entrypoint
jeffhao4eb68ed2012-10-17 16:41:07 -0700931 sw $sp, 16($sp) # pass $sp
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800932 \return
933END \name
934.endm
buzbee5bc5a7b2012-03-07 15:52:59 -0800935
Mathieu Chartier7410f292013-11-24 13:17:35 -0800936// Generate the allocation entrypoints for each allocator.
937GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700938
buzbee5bc5a7b2012-03-07 15:52:59 -0800939 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700940 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -0800941 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800942 .extern artTestSuspendFromCode
943ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -0800944 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -0700945 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -0700946 bnez $a0, 1f
947 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
948 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800949 nop
9501:
jeffhao7fbee072012-08-24 17:56:54 -0700951 move $a0, rSELF
952 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
953 jal artTestSuspendFromCode # (Thread*, $sp)
954 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800955 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800956END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -0800957
buzbee5bc5a7b2012-03-07 15:52:59 -0800958 /*
959 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -0700960 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -0800961 */
Jeff Hao5fa60c32013-04-04 17:57:01 -0700962 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800963ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -0800964 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -0800965 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700966 sw $a0, 0($sp) # place proxy method at bottom of frame
967 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -0700968 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800969 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -0700970 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -0700971 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700972 bnez $t0, 1f
Mathieu Chartier19841522013-10-22 11:29:00 -0700973 nop
jeffhao7fbee072012-08-24 17:56:54 -0700974 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800975 nop
9761:
977 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800978END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -0800979
Jeff Hao88474b42013-10-23 16:24:40 -0700980 /*
981 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
982 * dex method index.
983 */
984ENTRY art_quick_imt_conflict_trampoline
985 GENERATE_GLOBAL_POINTER
986 lw $a0, 0($sp) # load caller Method*
987 lw $a0, METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
988 sll $t0, 2 # convert target method offset to bytes
989 add $a0, $t0 # get address of target method
990 lw $a0, OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
991 la $t9, art_quick_invoke_interface_trampoline
992 jr $t9
993END art_quick_imt_conflict_trampoline
994
Ian Rogers468532e2013-08-05 10:56:33 -0700995 .extern artQuickResolutionTrampoline
996ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -0800997 GENERATE_GLOBAL_POINTER
998 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -0700999 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001000 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001001 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001002 beqz $v0, 1f
1003 lw $a0, 0($sp) # load resolved method to $a0
Mathieu Chartier19841522013-10-22 11:29:00 -07001004 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001005 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001006 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001007 nop
Ian Rogers468532e2013-08-05 10:56:33 -070010081:
Mathieu Chartier19841522013-10-22 11:29:00 -07001009 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001010 DELIVER_PENDING_EXCEPTION
1011END art_quick_resolution_trampoline
1012
1013 .extern artQuickToInterpreterBridge
1014ENTRY art_quick_to_interpreter_bridge
1015 GENERATE_GLOBAL_POINTER
1016 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001017 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001018 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001019 move $a2, $sp # pass $sp
1020 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Mathieu Chartier19841522013-10-22 11:29:00 -07001021 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001022 bnez $t0, 1f
Mathieu Chartier19841522013-10-22 11:29:00 -07001023 nop
Ian Rogers7db619b2013-01-16 18:35:48 -08001024 jr $ra
1025 nop
10261:
1027 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001028END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001029
buzbee5bc5a7b2012-03-07 15:52:59 -08001030 /*
jeffhao725a9572012-11-13 18:20:12 -08001031 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001032 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001033 .extern artInstrumentationMethodEntryFromCode
1034 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001035ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001036 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001037 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001038 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001039 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1040 .cfi_adjust_cfa_offset 32
1041 sw $a0, 28($sp) # save arg0
1042 sw $ra, 16($sp) # pass $ra
1043 move $a3, $t0 # pass $sp
1044 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1045 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001046 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001047 lw $a0, 28($sp) # restore arg0
1048 addiu $sp, $sp, 32 # remove args
1049 .cfi_adjust_cfa_offset -32
1050 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001051 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001052 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001053END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001054 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001055 .global art_quick_instrumentation_exit
1056art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001057 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001058 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1059 GENERATE_GLOBAL_POINTER
1060 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001061 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
1062 addiu $sp, $sp, -48 # save return values and set up args
1063 .cfi_adjust_cfa_offset 48
1064 sw $v0, 32($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001065 .cfi_rel_offset 2, 0
Ian Rogers62d6c772013-02-27 08:32:07 -08001066 sw $v1, 36($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001067 .cfi_rel_offset 3, 4
Ian Rogers62d6c772013-02-27 08:32:07 -08001068 s.s $f0, 40($sp)
1069 s.s $f1, 44($sp)
1070 s.s $f0, 16($sp) # pass fpr result
1071 s.s $f1, 20($sp)
1072 move $a2, $v0 # pass gpr result
1073 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001074 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001075 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001076 move $a0, rSELF # pass Thread::Current
1077 move $t0, $v0 # set aside returned link register
1078 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001079 lw $v0, 32($sp) # restore return values
1080 lw $v1, 36($sp)
1081 l.s $f0, 40($sp)
1082 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001083 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001084 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1085 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001086END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001087
jeffhao12051ea2013-01-10 11:24:31 -08001088 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001089 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1090 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001091 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001092 .extern artDeoptimize
1093 .extern artEnterInterpreterFromDeoptimize
1094ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001095 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001096 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001097 move $a0, rSELF # pass Thread::current
1098 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001099 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001100 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001101END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001102
buzbee5bc5a7b2012-03-07 15:52:59 -08001103 /*
1104 * Long integer shift. This is different from the generic 32/64-bit
1105 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1106 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1107 * 6 bits.
1108 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001109 * $a0: low word
1110 * $a1: high word
1111 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001112 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001113ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001114 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001115 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1116 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1117 srl $a0, 1
1118 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1119 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1120 or $v1, $a0 # rhi<- rhi | alo
1121 andi $a2, 0x20 # shift< shift & 0x20
1122 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1123 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001124 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001125END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001126
buzbee5bc5a7b2012-03-07 15:52:59 -08001127 /*
1128 * Long integer shift. This is different from the generic 32/64-bit
1129 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1130 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1131 * 6 bits.
1132 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001133 * $a0: low word
1134 * $a1: high word
1135 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001136 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001137 .global art_quick_shr_long
1138ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001139 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1140 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1141 sra $a3, $a1, 31 # $a3<- sign(ah)
1142 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1143 sll $a1, 1
1144 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1145 or $v0, $a1 # rlo<- rlo | ahi
1146 andi $a2, 0x20 # shift & 0x20
1147 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1148 jr $ra
1149 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001150END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001151
buzbee5bc5a7b2012-03-07 15:52:59 -08001152 /*
1153 * Long integer shift. This is different from the generic 32/64-bit
1154 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1155 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1156 * 6 bits.
1157 * On entry:
1158 * r0: low word
1159 * r1: high word
1160 * r2: shift count
1161 */
1162 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001163 .global art_quick_ushr_long
1164ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001165 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001166 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001167 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1168 sll $a1, 1
1169 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1170 or $v0, $a1 # rlo<- rlo | ahi
1171 andi $a2, 0x20 # shift & 0x20
1172 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1173 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001174 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001175END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001176
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001177ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001178 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001179 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001180END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001181
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001182ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001183 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001184 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001185END art_quick_string_compareto