blob: 897aaf40361333e3a1fe890d19a5995f06848792 [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)
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -070092 lw $s8, 56($sp)
93 lw $gp, 52($sp)
94 lw $s7, 48($sp)
95 lw $s6, 44($sp)
96 lw $s5, 40($sp)
97 lw $s4, 36($sp)
98 lw $s3, 32($sp)
99 lw $s2, 28($sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700100 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800101 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800102.endm
103
104.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -0700105 lw $ra, 60($sp)
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700106 lw $s8, 56($sp)
107 lw $gp, 52($sp)
108 lw $s7, 48($sp)
109 lw $s6, 44($sp)
110 lw $s5, 40($sp)
111 lw $s4, 36($sp)
112 lw $s3, 32($sp)
113 lw $s2, 28($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700114 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700115 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800116 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800117.endm
118
119 /*
120 * Macro that sets up the callee save frame to conform with
121 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700122 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800123 */
124.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700125 addiu $sp, $sp, -64
126 .cfi_adjust_cfa_offset 64
127 sw $ra, 60($sp)
128 .cfi_rel_offset 31, 60
129 sw $s8, 56($sp)
130 .cfi_rel_offset 30, 56
131 sw $gp, 52($sp)
132 .cfi_rel_offset 28, 52
133 sw $s7, 48($sp)
134 .cfi_rel_offset 23, 48
135 sw $s6, 44($sp)
136 .cfi_rel_offset 22, 44
137 sw $s5, 40($sp)
138 .cfi_rel_offset 21, 40
139 sw $s4, 36($sp)
140 .cfi_rel_offset 20, 36
141 sw $s3, 32($sp)
142 .cfi_rel_offset 19, 32
143 sw $s2, 28($sp)
144 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700145 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800146 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700147 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800148 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700149 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800150 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700151 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800152.endm
153
154.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700155 lw $ra, 60($sp)
156 lw $s8, 56($sp)
157 lw $gp, 52($sp)
158 lw $s7, 48($sp)
159 lw $s6, 44($sp)
160 lw $s5, 40($sp)
161 lw $s4, 36($sp)
162 lw $s3, 32($sp)
163 lw $s2, 28($sp)
164 lw $a3, 12($sp)
165 lw $a2, 8($sp)
166 lw $a1, 4($sp)
Ian Rogers468532e2013-08-05 10:56:33 -0700167 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700168 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800169.endm
170
171 /*
172 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
173 * exception is Thread::Current()->exception_
174 */
175.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700176 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
177 move $a0, rSELF # pass Thread::Current
178 la $t9, artDeliverPendingExceptionFromCode
179 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
180 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800181.endm
182
183.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700184 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800185 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700186 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800187 nop
jeffhao7fbee072012-08-24 17:56:54 -0700188 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800189 nop
1901:
191 DELIVER_PENDING_EXCEPTION
192.endm
193
194.macro RETURN_IF_ZERO
195 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700196 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800197 nop
jeffhao7fbee072012-08-24 17:56:54 -0700198 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800199 nop
2001:
201 DELIVER_PENDING_EXCEPTION
202.endm
203
204.macro RETURN_IF_NONZERO
205 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700206 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800207 nop
jeffhao7fbee072012-08-24 17:56:54 -0700208 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800209 nop
2101:
211 DELIVER_PENDING_EXCEPTION
212.endm
213
buzbee5bc5a7b2012-03-07 15:52:59 -0800214 /*
jeffhao7fbee072012-08-24 17:56:54 -0700215 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800216 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
217 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800218ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700219 l.s $f0, 0($a1)
220 l.s $f1, 4($a1)
221 l.s $f2, 8($a1)
222 l.s $f3, 12($a1)
223 l.s $f4, 16($a1)
224 l.s $f5, 20($a1)
225 l.s $f6, 24($a1)
226 l.s $f7, 28($a1)
227 l.s $f8, 32($a1)
228 l.s $f9, 36($a1)
229 l.s $f10, 40($a1)
230 l.s $f11, 44($a1)
231 l.s $f12, 48($a1)
232 l.s $f13, 52($a1)
233 l.s $f14, 56($a1)
234 l.s $f15, 60($a1)
235 l.s $f16, 64($a1)
236 l.s $f17, 68($a1)
237 l.s $f18, 72($a1)
238 l.s $f19, 76($a1)
239 l.s $f20, 80($a1)
240 l.s $f21, 84($a1)
241 l.s $f22, 88($a1)
242 l.s $f23, 92($a1)
243 l.s $f24, 96($a1)
244 l.s $f25, 100($a1)
245 l.s $f26, 104($a1)
246 l.s $f27, 108($a1)
247 l.s $f28, 112($a1)
248 l.s $f29, 116($a1)
249 l.s $f30, 120($a1)
250 l.s $f31, 124($a1)
251 lw $at, 4($a0)
252 lw $v0, 8($a0)
253 lw $v1, 12($a0)
254 lw $a1, 20($a0)
255 lw $a2, 24($a0)
256 lw $a3, 28($a0)
257 lw $t0, 32($a0)
258 lw $t1, 36($a0)
259 lw $t2, 40($a0)
260 lw $t3, 44($a0)
261 lw $t4, 48($a0)
262 lw $t5, 52($a0)
263 lw $t6, 56($a0)
264 lw $t7, 60($a0)
265 lw $s0, 64($a0)
266 lw $s1, 68($a0)
267 lw $s2, 72($a0)
268 lw $s3, 76($a0)
269 lw $s4, 80($a0)
270 lw $s5, 84($a0)
271 lw $s6, 88($a0)
272 lw $s7, 92($a0)
273 lw $t8, 96($a0)
274 lw $t9, 100($a0)
275 lw $k0, 104($a0)
276 lw $k1, 108($a0)
277 lw $gp, 112($a0)
278 lw $sp, 116($a0)
279 lw $fp, 120($a0)
280 lw $ra, 124($a0)
281 lw $a0, 16($a0)
282 move $v0, $zero # clear result registers r0 and r1
283 jr $ra # do long jump
284 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800285END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800286
buzbee5bc5a7b2012-03-07 15:52:59 -0800287 /*
288 * Called by managed code, saves most registers (forms basis of long jump context) and passes
289 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
290 * the bottom of the thread. On entry r0 holds Throwable*
291 */
Ian Rogers468532e2013-08-05 10:56:33 -0700292ENTRY art_quick_deliver_exception
jeffhao12051ea2013-01-10 11:24:31 -0800293 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700294 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700295 move $a1, rSELF # pass Thread::Current
296 la $t9, artDeliverExceptionFromCode
297 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
298 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700299END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800300
buzbee5bc5a7b2012-03-07 15:52:59 -0800301 /*
302 * Called by managed code to create and deliver a NullPointerException
303 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800304 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700305ENTRY art_quick_throw_null_pointer_exception
jeffhao12051ea2013-01-10 11:24:31 -0800306 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700307art_quick_throw_null_pointer_exception_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700308 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700309 move $a0, rSELF # pass Thread::Current
310 la $t9, artThrowNullPointerExceptionFromCode
311 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
312 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700313END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800314
buzbee5bc5a7b2012-03-07 15:52:59 -0800315 /*
316 * Called by managed code to create and deliver an ArithmeticException
317 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800318 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700319ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800320 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700321 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700322 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700323 la $t9, artThrowDivZeroFromCode
324 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700325 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700326END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800327
buzbee5bc5a7b2012-03-07 15:52:59 -0800328 /*
329 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
330 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800331 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700332ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800333 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700334art_quick_throw_array_bounds_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700335 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700336 move $a2, rSELF # pass Thread::Current
337 la $t9, artThrowArrayBoundsFromCode
338 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
339 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700340END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800341
Ian Rogers57b86d42012-03-27 16:05:41 -0700342 /*
343 * Called by managed code to create and deliver a StackOverflowError.
344 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800345 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700346ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800347 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700348 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700349 move $a0, rSELF # pass Thread::Current
350 la $t9, artThrowStackOverflowFromCode
351 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
352 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700353END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800354
Ian Rogers57b86d42012-03-27 16:05:41 -0700355 /*
356 * Called by managed code to create and deliver a NoSuchMethodError.
357 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800358 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700359ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800360 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700361 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700362 move $a1, rSELF # pass Thread::Current
363 la $t9, artThrowNoSuchMethodFromCode
364 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
365 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700366END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800367
buzbee5bc5a7b2012-03-07 15:52:59 -0800368 /*
369 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700370 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800371 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
372 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700373 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800374 *
jeffhao7fbee072012-08-24 17:56:54 -0700375 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
376 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800377 *
jeffhaofa147e22012-10-12 17:03:32 -0700378 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800379 * thread and we branch to another stub to deliver it.
380 *
381 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
382 * pointing back to the original caller.
383 */
384.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800385 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800386ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800387 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700388 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700389 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700390 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700391 addiu $sp, $sp, -32 # make space for extra args
392 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700393 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800394 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700395 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700396 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700397 addiu $sp, $sp, 32 # release out args
398 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700399 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700400 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800401 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700402 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800403 nop
jeffhao30a33172012-10-22 18:16:22 -0700404 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800405 nop
4061:
407 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800408END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800409.endm
410
Logan Chien8dbb7082013-01-25 20:31:17 +0800411INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
412INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800413
Logan Chien8dbb7082013-01-25 20:31:17 +0800414INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
415INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
416INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
417INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800418
Jeff Hao79fe5392013-04-24 18:41:58 -0700419 /*
Jeff Hao6474d192013-03-26 14:08:09 -0700420 * Common invocation stub for portable and quick.
Jeff Hao5d917302013-02-27 17:57:33 -0800421 * On entry:
422 * a0 = method pointer
423 * a1 = argument array or NULL for no argument methods
424 * a2 = size of argument array in bytes
425 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700426 * [sp + 16] = JValue* result
427 * [sp + 20] = result type char
Jeff Hao5d917302013-02-27 17:57:33 -0800428 */
Jeff Hao79fe5392013-04-24 18:41:58 -0700429 .type art_portable_invoke_stub, %function
430 .global art_portable_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700431art_portable_invoke_stub:
Jeff Hao5d917302013-02-27 17:57:33 -0800432ENTRY art_quick_invoke_stub
433 GENERATE_GLOBAL_POINTER
434 sw $a0, 0($sp) # save out a0
435 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
436 .cfi_adjust_cfa_offset 16
437 sw $ra, 12($sp)
438 .cfi_rel_offset 31, 12
439 sw $fp, 8($sp)
440 .cfi_rel_offset 30, 8
441 sw $s1, 4($sp)
442 .cfi_rel_offset 17, 4
443 sw $s0, 0($sp)
444 .cfi_rel_offset 16, 0
445 move $fp, $sp # save sp in fp
446 .cfi_def_cfa_register 30
447 move $s1, $a3 # move managed thread pointer into s1
448 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
449 addiu $t0, $a2, 16 # create space for method pointer in frame
450 srl $t0, $t0, 3 # shift the frame size right 3
451 sll $t0, $t0, 3 # shift the frame size left 3 to align to 16 bytes
452 subu $sp, $sp, $t0 # reserve stack space for argument array
453 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
454 jal memcpy # (dest, src, bytes)
455 addiu $sp, $sp, -16 # make space for argument slots for memcpy
456 addiu $sp, $sp, 16 # restore stack after memcpy
457 lw $a0, 16($fp) # restore method*
458 lw $a1, 4($sp) # copy arg value for a1
459 lw $a2, 8($sp) # copy arg value for a2
460 lw $a3, 12($sp) # copy arg value for a3
461 lw $t9, METHOD_CODE_OFFSET($a0) # get pointer to the code
462 jalr $t9 # call the method
463 sw $zero, 0($sp) # store NULL for method* at bottom of frame
464 move $sp, $fp # restore the stack
465 lw $s0, 0($sp)
466 lw $s1, 4($sp)
467 lw $fp, 8($sp)
468 lw $ra, 12($sp)
469 addiu $sp, $sp, 16
470 .cfi_adjust_cfa_offset -16
471 lw $t0, 16($sp) # get result pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700472 lw $t1, 20($sp) # get result type char
473 li $t2, 68 # put char 'D' into t2
474 beq $t1, $t2, 1f # branch if result type char == 'D'
475 li $t3, 70 # put char 'F' into t3
476 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800477 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700478 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800479 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07004801:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700481 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800482 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700483 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800484END art_quick_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700485 .size art_portable_invoke_stub, .-art_portable_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800486
487 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800488 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
489 * failure.
490 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800491 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700492ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800493 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700494 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
495 move $a2, rSELF # pass Thread::Current
496 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
497 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700498 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700499END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800500
buzbee5bc5a7b2012-03-07 15:52:59 -0800501 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700502 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800503 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800504 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700505ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800506 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700507 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
508 nop
jeffhao7fbee072012-08-24 17:56:54 -0700509 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
510 move $a1, rSELF # pass Thread::Current
511 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
512 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700513 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700514END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800515
buzbee5bc5a7b2012-03-07 15:52:59 -0800516 /*
517 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
518 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800519 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700520ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800521 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700522 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
523 nop
jeffhao7fbee072012-08-24 17:56:54 -0700524 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
525 move $a1, rSELF # pass Thread::Current
526 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
527 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800528 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700529END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800530
buzbee5bc5a7b2012-03-07 15:52:59 -0800531 /*
532 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
533 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700534 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700535ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800536 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700537 addiu $sp, $sp, -16
538 .cfi_adjust_cfa_offset 16
539 sw $ra, 12($sp)
540 .cfi_rel_offset 31, 12
541 sw $t9, 8($sp)
542 sw $a1, 4($sp)
543 sw $a0, 0($sp)
544 jal artIsAssignableFromCode
545 nop
546 beqz $v0, throw_class_cast_exception
547 lw $ra, 12($sp)
548 jr $ra
549 addiu $sp, $sp, 16
550 .cfi_adjust_cfa_offset -16
551throw_class_cast_exception:
552 lw $t9, 8($sp)
553 lw $a1, 4($sp)
554 lw $a0, 0($sp)
555 addiu $sp, $sp, 16
556 .cfi_adjust_cfa_offset -16
557 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
558 move $a2, rSELF # pass Thread::Current
559 la $t9, artThrowClassCastException
560 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
561 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700562END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800563
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700565 * Entry from managed code for array put operations of objects where the value being stored
566 * needs to be checked for compatibility.
567 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800568 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700569ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800570 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700571 bnez $a0, art_quick_aput_obj_with_bound_check_gp_set
572 nop
573 b art_quick_throw_null_pointer_exception_gp_set
574 nop
575END art_quick_aput_obj_with_null_and_bound_check
576
577ENTRY art_quick_aput_obj_with_bound_check
578 GENERATE_GLOBAL_POINTER
579art_quick_aput_obj_with_bound_check_gp_set:
580 lw $t0, ARRAY_LENGTH_OFFSET($a0)
581 sltu $t1, $a1, $t0
582 bnez $t1, art_quick_aput_obj_gp_set
583 nop
584 move $a0, $a1
585 b art_quick_throw_array_bounds_gp_set
586 move $a1, $t0
587END art_quick_aput_obj_with_bound_check
588
589ENTRY art_quick_aput_obj
590 GENERATE_GLOBAL_POINTER
591art_quick_aput_obj_gp_set:
592 beqz $a2, do_aput_null
593 nop
594 lw $t0, CLASS_OFFSET($a0)
595 lw $t1, CLASS_OFFSET($a2)
596 lw $t0, CLASS_COMPONENT_TYPE_OFFSET($t0)
597 bne $t1, $t0, check_assignability # value's type == array's component type - trivial assignability
598 nop
599do_aput:
600 sll $a1, $a1, 2
601 add $t0, $a0, $a1
602 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
603 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
604 srl $t1, $a0, 7
605 add $t1, $t1, $t0
606 sb $t0, ($t1)
607 jr $ra
608 nop
609do_aput_null:
610 sll $a1, $a1, 2
611 add $t0, $a0, $a1
612 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
613 jr $ra
614 nop
615check_assignability:
616 addiu $sp, $sp, -32
617 .cfi_adjust_cfa_offset 32
618 sw $ra, 28($sp)
619 .cfi_rel_offset 31, 28
620 sw $t9, 12($sp)
621 sw $a2, 8($sp)
622 sw $a1, 4($sp)
623 sw $a0, 0($sp)
624 move $a1, $t1
625 move $a0, $t0
626 jal artIsAssignableFromCode # (Class*, Class*)
627 nop
628 lw $ra, 28($sp)
629 lw $t9, 12($sp)
630 lw $a2, 8($sp)
631 lw $a1, 4($sp)
632 lw $a0, 0($sp)
633 add $sp, 32
634 .cfi_adjust_cfa_offset -32
635 bnez $v0, do_aput
636 nop
637 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
638 move $a1, $a2
639 move $a2, rSELF # pass Thread::Current
640 la $t9, artThrowArrayStoreException
641 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
642 move $a3, $sp # pass $sp
643END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800644
buzbee5bc5a7b2012-03-07 15:52:59 -0800645 /*
646 * Entry from managed code when uninitialized static storage, this stub will run the class
647 * initializer and deliver the exception on error. On success the static storage base is
648 * returned.
649 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800650 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700651ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800652 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700653 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
654 move $a2, rSELF # pass Thread::Current
655 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800656 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700657 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800658 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700659END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800660
buzbee5bc5a7b2012-03-07 15:52:59 -0800661 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700662 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800663 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800664 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700665ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800666 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700667 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
668 move $a2, rSELF # pass Thread::Current
669 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800670 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700671 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800672 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700673END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800674
buzbee5bc5a7b2012-03-07 15:52:59 -0800675 /*
676 * 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 -0700677 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800678 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800679 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700680ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800681 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700682 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
683 move $a2, rSELF # pass Thread::Current
684 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800685 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700686 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800687 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700688END art_quick_initialize_type_and_verify_access
buzbee5bc5a7b2012-03-07 15:52:59 -0800689
buzbee5bc5a7b2012-03-07 15:52:59 -0800690 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700691 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800692 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800693 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700694ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800695 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700696 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700697 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700698 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700699 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700700 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800701 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700702END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800703
buzbee5bc5a7b2012-03-07 15:52:59 -0800704 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700705 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800706 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800707 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700708ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800709 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700710 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700711 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700712 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700713 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700714 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800715 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700716END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800717
buzbee5bc5a7b2012-03-07 15:52:59 -0800718 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700719 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800720 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800721 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700722ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800723 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700724 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700725 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700726 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700727 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700728 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700730END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800731
buzbee5bc5a7b2012-03-07 15:52:59 -0800732 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700733 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800734 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800735 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700736ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800737 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700738 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700739 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700740 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700741 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700742 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800743 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700744END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800745
buzbee5bc5a7b2012-03-07 15:52:59 -0800746 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700747 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800748 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800749 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700750ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800751 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700752 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700753 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700754 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700755 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700756 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800757 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700758END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800759
buzbee5bc5a7b2012-03-07 15:52:59 -0800760 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700761 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800762 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800763 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700764ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800765 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700766 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700767 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700768 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700769 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700770 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800771 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700772END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800773
buzbee5bc5a7b2012-03-07 15:52:59 -0800774 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700775 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800776 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800777 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700778ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800779 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700780 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700781 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700782 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700783 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700784 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800785 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700786END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800787
buzbee5bc5a7b2012-03-07 15:52:59 -0800788 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700789 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800790 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800791 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700792ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800793 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700794 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700795 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700796 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700797 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700798 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800799 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700800END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800801
buzbee5bc5a7b2012-03-07 15:52:59 -0800802 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700803 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800804 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800805 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700806ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800807 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700808 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700809 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700810 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700811 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700812 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800813 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700814END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800815
buzbee5bc5a7b2012-03-07 15:52:59 -0800816 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700817 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800819 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700820ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800821 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700822 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700823 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700824 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700825 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700826 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800827 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700828END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800829
buzbee5bc5a7b2012-03-07 15:52:59 -0800830 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700831 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800832 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800833 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700834ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800835 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700836 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700837 sw rSELF, 16($sp) # pass Thread::Current
838 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700839 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800840 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700841END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800842
buzbee5bc5a7b2012-03-07 15:52:59 -0800843 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700844 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800845 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800846 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700847ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800848 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700849 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700850 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700851 sw rSELF, 16($sp) # pass Thread::Current
852 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700853 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800854 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700855END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800856
buzbee5bc5a7b2012-03-07 15:52:59 -0800857 /*
858 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
859 * exception on error. On success the String is returned. R0 holds the referring method,
860 * R1 holds the string index. The fast path check for hit in strings cache has already been
861 * performed.
862 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800863 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700864ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -0800865 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700866 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
867 move $a2, rSELF # pass Thread::Current
868 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800869 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700870 move $a3, $sp # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700871 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700872END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -0800873
buzbee5bc5a7b2012-03-07 15:52:59 -0800874 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700875 * Called by managed code to allocate an object.
buzbee5bc5a7b2012-03-07 15:52:59 -0800876 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800877 .extern artAllocObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700878ENTRY art_quick_alloc_object
jeffhao12051ea2013-01-10 11:24:31 -0800879 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700880 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
881 move $a2, rSELF # pass Thread::Current
882 jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp)
883 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800884 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700885END art_quick_alloc_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800886
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700887 .extern artAllocObjectFromCodeInstrumented
888ENTRY art_quick_alloc_object_instrumented
889 GENERATE_GLOBAL_POINTER
890 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
891 move $a2, rSELF # pass Thread::Current
892 jal artAllocObjectFromCodeInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
893 move $a3, $sp # pass $sp
894 RETURN_IF_NONZERO
895END art_quick_alloc_object_instrumented
896
buzbee5bc5a7b2012-03-07 15:52:59 -0800897 /*
898 * Called by managed code to allocate an object when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700899 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800900 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800901 .extern artAllocObjectFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700902ENTRY art_quick_alloc_object_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800903 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700904 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
905 move $a2, rSELF # pass Thread::Current
906 jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp)
907 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800908 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700909END art_quick_alloc_object_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800910
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700911 .extern artAllocObjectFromCodeWithAccessCheckInstrumented
912ENTRY art_quick_alloc_object_with_access_check_instrumented
913 GENERATE_GLOBAL_POINTER
914 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
915 move $a2, rSELF # pass Thread::Current
916 jal artAllocObjectFromCodeWithAccessCheckInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
917 move $a3, $sp # pass $sp
918 RETURN_IF_NONZERO
919END art_quick_alloc_object_with_access_check_instrumented
920
buzbee5bc5a7b2012-03-07 15:52:59 -0800921 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700922 * Called by managed code to allocate an array.
buzbee5bc5a7b2012-03-07 15:52:59 -0800923 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800924 .extern artAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700925ENTRY art_quick_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800926 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700927 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
928 move $a3, rSELF # pass Thread::Current
929 # artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800930 jal artAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700931 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800932 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700933END art_quick_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800934
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700935 .extern artAllocArrayFromCodeInstrumented
936ENTRY art_quick_alloc_array_instrumented
937 GENERATE_GLOBAL_POINTER
938 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
939 move $a3, rSELF # pass Thread::Current
940 # artAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
941 jal artAllocArrayFromCodeInstrumented
942 sw $sp, 16($sp) # pass $sp
943 RETURN_IF_NONZERO
944END art_quick_alloc_array_instrumented
945
buzbee5bc5a7b2012-03-07 15:52:59 -0800946 /*
947 * Called by managed code to allocate an array when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700948 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800949 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800950 .extern artAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700951ENTRY art_quick_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800952 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700953 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
954 move $a3, rSELF # pass Thread::Current
955 # artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800956 jal artAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700957 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800958 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700959END art_quick_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800960
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700961 .extern artAllocArrayFromCodeWithAccessCheckInstrumented
962ENTRY art_quick_alloc_array_with_access_check_instrumented
963 GENERATE_GLOBAL_POINTER
964 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
965 move $a3, rSELF # pass Thread::Current
966 # artAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, component_count, Thread*, $sp)
967 jal artAllocArrayFromCodeWithAccessCheckInstrumented
968 sw $sp, 16($sp) # pass $sp
969 RETURN_IF_NONZERO
970END art_quick_alloc_array_with_access_check_instrumented
971
buzbee5bc5a7b2012-03-07 15:52:59 -0800972 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700973 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800974 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800975 .extern artCheckAndAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700976ENTRY art_quick_check_and_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800977 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700978 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
979 move $a3, rSELF # pass Thread::Current
980 # artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800981 jal artCheckAndAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700982 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800983 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700984END art_quick_check_and_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800985
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700986 .extern artCheckAndAllocArrayFromCodeInstrumented
987ENTRY art_quick_check_and_alloc_array_instrumented
988 GENERATE_GLOBAL_POINTER
989 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
990 move $a3, rSELF # pass Thread::Current
991 # artCheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
992 jal artCheckAndAllocArrayFromCodeInstrumented
993 sw $sp, 16($sp) # pass $sp
994 RETURN_IF_NONZERO
995END art_quick_check_and_alloc_array_instrumented
996
buzbee5bc5a7b2012-03-07 15:52:59 -0800997 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700998 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800999 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001000 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -07001001ENTRY art_quick_check_and_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -08001002 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -07001003 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -07001004 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -07001005 # artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -08001006 jal artCheckAndAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -07001007 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001008 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001009END art_quick_check_and_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -08001010
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001011 .extern artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
1012ENTRY art_quick_check_and_alloc_array_with_access_check_instrumented
1013 GENERATE_GLOBAL_POINTER
1014 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1015 move $a3, rSELF # pass Thread::Current
1016 # artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, count, Thread* , $sp)
1017 jal artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
1018 sw $sp, 16($sp) # pass $sp
1019 RETURN_IF_NONZERO
1020END art_quick_check_and_alloc_array_with_access_check_instrumented
1021
buzbee5bc5a7b2012-03-07 15:52:59 -08001022 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001023 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001024 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001025 .extern artTestSuspendFromCode
1026ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -08001027 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -07001028 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001029 bnez $a0, 1f
1030 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1031 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001032 nop
10331:
jeffhao7fbee072012-08-24 17:56:54 -07001034 move $a0, rSELF
1035 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1036 jal artTestSuspendFromCode # (Thread*, $sp)
1037 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001038 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001039END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001040
buzbee5bc5a7b2012-03-07 15:52:59 -08001041 /*
1042 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001043 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001044 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001045 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001046ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -08001047 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -08001048 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001049 sw $a0, 0($sp) # place proxy method at bottom of frame
1050 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001051 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001052 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001053 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001054 lw $gp, 52($sp) # restore $gp
1055 lw $ra, 60($sp) # restore $ra
jeffhao7fbee072012-08-24 17:56:54 -07001056 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001057 addiu $sp, $sp, 64 # pop frame
1058 .cfi_adjust_cfa_offset -64
jeffhao7fbee072012-08-24 17:56:54 -07001059 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001060 nop
10611:
1062 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001063END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001064
Ian Rogers468532e2013-08-05 10:56:33 -07001065 .extern artQuickResolutionTrampoline
1066ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001067 GENERATE_GLOBAL_POINTER
1068 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001069 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001070 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001071 move $a3, $sp # pass $sp
1072 lw $gp, 52($sp) # restore $gp
1073 lw $ra, 60($sp) # restore $ra
1074 beqz $v0, 1f
1075 lw $a0, 0($sp) # load resolved method to $a0
1076 lw $a1, 4($sp) # restore non-callee save $a1
1077 lw $a2, 8($sp) # restore non-callee save $a2
1078 lw $a3, 12($sp) # restore non-callee save $a3
Ian Rogers65d1b222013-09-27 10:59:41 -07001079 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001080 jr $v0 # tail call to method
10811:
1082 addiu $sp, $sp, 64 # pop frame
1083 .cfi_adjust_cfa_offset -64
1084 DELIVER_PENDING_EXCEPTION
1085END art_quick_resolution_trampoline
1086
1087 .extern artQuickToInterpreterBridge
1088ENTRY art_quick_to_interpreter_bridge
1089 GENERATE_GLOBAL_POINTER
1090 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001091 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001092 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001093 move $a2, $sp # pass $sp
1094 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001095 lw $gp, 52($sp) # restore $gp
1096 lw $ra, 60($sp) # restore $ra
Ian Rogers7db619b2013-01-16 18:35:48 -08001097 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001098 addiu $sp, $sp, 64 # pop frame
1099 .cfi_adjust_cfa_offset -64
Ian Rogers7db619b2013-01-16 18:35:48 -08001100 jr $ra
1101 nop
11021:
1103 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001104END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001105
buzbee5bc5a7b2012-03-07 15:52:59 -08001106 /*
jeffhao725a9572012-11-13 18:20:12 -08001107 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001108 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001109 .extern artInstrumentationMethodEntryFromCode
1110 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001111ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001112 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001113 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001114 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001115 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1116 .cfi_adjust_cfa_offset 32
1117 sw $a0, 28($sp) # save arg0
1118 sw $ra, 16($sp) # pass $ra
1119 move $a3, $t0 # pass $sp
1120 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1121 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001122 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001123 lw $a0, 28($sp) # restore arg0
1124 addiu $sp, $sp, 32 # remove args
1125 .cfi_adjust_cfa_offset -32
1126 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001127 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001128 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001129END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001130 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001131 .global art_quick_instrumentation_exit
1132art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001133 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001134 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1135 GENERATE_GLOBAL_POINTER
1136 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001137 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
1138 addiu $sp, $sp, -48 # save return values and set up args
1139 .cfi_adjust_cfa_offset 48
1140 sw $v0, 32($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001141 .cfi_rel_offset 2, 0
Ian Rogers62d6c772013-02-27 08:32:07 -08001142 sw $v1, 36($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001143 .cfi_rel_offset 3, 4
Ian Rogers62d6c772013-02-27 08:32:07 -08001144 s.s $f0, 40($sp)
1145 s.s $f1, 44($sp)
1146 s.s $f0, 16($sp) # pass fpr result
1147 s.s $f1, 20($sp)
1148 move $a2, $v0 # pass gpr result
1149 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001150 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001151 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001152 move $a0, rSELF # pass Thread::Current
1153 move $t0, $v0 # set aside returned link register
1154 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001155 lw $v0, 32($sp) # restore return values
1156 lw $v1, 36($sp)
1157 l.s $f0, 40($sp)
1158 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001159 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001160 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1161 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001162END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001163
jeffhao12051ea2013-01-10 11:24:31 -08001164 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001165 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1166 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001167 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001168 .extern artDeoptimize
1169 .extern artEnterInterpreterFromDeoptimize
1170ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001171 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001172 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001173 move $a0, rSELF # pass Thread::current
1174 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001175 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001176 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001177END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001178
buzbee5bc5a7b2012-03-07 15:52:59 -08001179 /*
1180 * Long integer shift. This is different from the generic 32/64-bit
1181 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1182 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1183 * 6 bits.
1184 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001185 * $a0: low word
1186 * $a1: high word
1187 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001188 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001189ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001190 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001191 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1192 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1193 srl $a0, 1
1194 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1195 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1196 or $v1, $a0 # rhi<- rhi | alo
1197 andi $a2, 0x20 # shift< shift & 0x20
1198 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1199 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001200 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001201END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001202
buzbee5bc5a7b2012-03-07 15:52:59 -08001203 /*
1204 * Long integer shift. This is different from the generic 32/64-bit
1205 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1206 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1207 * 6 bits.
1208 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001209 * $a0: low word
1210 * $a1: high word
1211 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001212 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001213 .global art_quick_shr_long
1214ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001215 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1216 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1217 sra $a3, $a1, 31 # $a3<- sign(ah)
1218 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1219 sll $a1, 1
1220 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1221 or $v0, $a1 # rlo<- rlo | ahi
1222 andi $a2, 0x20 # shift & 0x20
1223 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1224 jr $ra
1225 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001226END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001227
buzbee5bc5a7b2012-03-07 15:52:59 -08001228 /*
1229 * Long integer shift. This is different from the generic 32/64-bit
1230 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1231 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1232 * 6 bits.
1233 * On entry:
1234 * r0: low word
1235 * r1: high word
1236 * r2: shift count
1237 */
1238 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001239 .global art_quick_ushr_long
1240ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001241 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001242 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001243 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1244 sll $a1, 1
1245 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1246 or $v0, $a1 # rlo<- rlo | ahi
1247 andi $a2, 0x20 # shift & 0x20
1248 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1249 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001250 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001251END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001252
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001253ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001254 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001255 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001256END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001257
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001258ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001259 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001260 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001261END art_quick_string_compareto