blob: 004fda60f1c52ac629539a5772be52ca69d2a326 [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
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070091 lw $gp, 52($sp)
jeffhao4eb68ed2012-10-17 16:41:07 -070092 lw $ra, 60($sp)
93 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080094 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -080095.endm
96
97.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070098 lw $gp, 52($sp)
jeffhao4eb68ed2012-10-17 16:41:07 -070099 lw $ra, 60($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700100 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700101 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800102 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800103.endm
104
105 /*
106 * Macro that sets up the callee save frame to conform with
107 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700108 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800109 */
110.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700111 addiu $sp, $sp, -64
112 .cfi_adjust_cfa_offset 64
113 sw $ra, 60($sp)
114 .cfi_rel_offset 31, 60
115 sw $s8, 56($sp)
116 .cfi_rel_offset 30, 56
117 sw $gp, 52($sp)
118 .cfi_rel_offset 28, 52
119 sw $s7, 48($sp)
120 .cfi_rel_offset 23, 48
121 sw $s6, 44($sp)
122 .cfi_rel_offset 22, 44
123 sw $s5, 40($sp)
124 .cfi_rel_offset 21, 40
125 sw $s4, 36($sp)
126 .cfi_rel_offset 20, 36
127 sw $s3, 32($sp)
128 .cfi_rel_offset 19, 32
129 sw $s2, 28($sp)
130 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700131 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800132 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700133 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800134 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700135 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800136 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700137 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800138.endm
139
140.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700141 lw $ra, 60($sp) # restore $ra
142 lw $gp, 52($sp) # restore $gp
jeffhao7fbee072012-08-24 17:56:54 -0700143 lw $a1, 4($sp) # restore non-callee save $a1
144 lw $a2, 8($sp) # restore non-callee save $a2
145 lw $a3, 12($sp) # restore non-callee save $a3
Ian Rogers468532e2013-08-05 10:56:33 -0700146 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700147 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800148.endm
149
150 /*
151 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
152 * exception is Thread::Current()->exception_
153 */
154.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700155 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
156 move $a0, rSELF # pass Thread::Current
157 la $t9, artDeliverPendingExceptionFromCode
158 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
159 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800160.endm
161
162.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700163 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800164 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700165 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800166 nop
jeffhao7fbee072012-08-24 17:56:54 -0700167 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800168 nop
1691:
170 DELIVER_PENDING_EXCEPTION
171.endm
172
173.macro RETURN_IF_ZERO
174 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700175 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800176 nop
jeffhao7fbee072012-08-24 17:56:54 -0700177 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800178 nop
1791:
180 DELIVER_PENDING_EXCEPTION
181.endm
182
183.macro RETURN_IF_NONZERO
184 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700185 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800186 nop
jeffhao7fbee072012-08-24 17:56:54 -0700187 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800188 nop
1891:
190 DELIVER_PENDING_EXCEPTION
191.endm
192
buzbee5bc5a7b2012-03-07 15:52:59 -0800193 /*
jeffhao7fbee072012-08-24 17:56:54 -0700194 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800195 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
196 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800197ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700198 l.s $f0, 0($a1)
199 l.s $f1, 4($a1)
200 l.s $f2, 8($a1)
201 l.s $f3, 12($a1)
202 l.s $f4, 16($a1)
203 l.s $f5, 20($a1)
204 l.s $f6, 24($a1)
205 l.s $f7, 28($a1)
206 l.s $f8, 32($a1)
207 l.s $f9, 36($a1)
208 l.s $f10, 40($a1)
209 l.s $f11, 44($a1)
210 l.s $f12, 48($a1)
211 l.s $f13, 52($a1)
212 l.s $f14, 56($a1)
213 l.s $f15, 60($a1)
214 l.s $f16, 64($a1)
215 l.s $f17, 68($a1)
216 l.s $f18, 72($a1)
217 l.s $f19, 76($a1)
218 l.s $f20, 80($a1)
219 l.s $f21, 84($a1)
220 l.s $f22, 88($a1)
221 l.s $f23, 92($a1)
222 l.s $f24, 96($a1)
223 l.s $f25, 100($a1)
224 l.s $f26, 104($a1)
225 l.s $f27, 108($a1)
226 l.s $f28, 112($a1)
227 l.s $f29, 116($a1)
228 l.s $f30, 120($a1)
229 l.s $f31, 124($a1)
230 lw $at, 4($a0)
231 lw $v0, 8($a0)
232 lw $v1, 12($a0)
233 lw $a1, 20($a0)
234 lw $a2, 24($a0)
235 lw $a3, 28($a0)
236 lw $t0, 32($a0)
237 lw $t1, 36($a0)
238 lw $t2, 40($a0)
239 lw $t3, 44($a0)
240 lw $t4, 48($a0)
241 lw $t5, 52($a0)
242 lw $t6, 56($a0)
243 lw $t7, 60($a0)
244 lw $s0, 64($a0)
245 lw $s1, 68($a0)
246 lw $s2, 72($a0)
247 lw $s3, 76($a0)
248 lw $s4, 80($a0)
249 lw $s5, 84($a0)
250 lw $s6, 88($a0)
251 lw $s7, 92($a0)
252 lw $t8, 96($a0)
253 lw $t9, 100($a0)
254 lw $k0, 104($a0)
255 lw $k1, 108($a0)
256 lw $gp, 112($a0)
257 lw $sp, 116($a0)
258 lw $fp, 120($a0)
259 lw $ra, 124($a0)
260 lw $a0, 16($a0)
261 move $v0, $zero # clear result registers r0 and r1
262 jr $ra # do long jump
263 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800264END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800265
buzbee5bc5a7b2012-03-07 15:52:59 -0800266 /*
267 * Called by managed code, saves most registers (forms basis of long jump context) and passes
268 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
269 * the bottom of the thread. On entry r0 holds Throwable*
270 */
Ian Rogers468532e2013-08-05 10:56:33 -0700271ENTRY art_quick_deliver_exception
jeffhao12051ea2013-01-10 11:24:31 -0800272 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700273 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700274 move $a1, rSELF # pass Thread::Current
275 la $t9, artDeliverExceptionFromCode
276 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
277 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700278END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800279
buzbee5bc5a7b2012-03-07 15:52:59 -0800280 /*
281 * Called by managed code to create and deliver a NullPointerException
282 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800283 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700284ENTRY art_quick_throw_null_pointer_exception
jeffhao12051ea2013-01-10 11:24:31 -0800285 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700286 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700287 move $a0, rSELF # pass Thread::Current
288 la $t9, artThrowNullPointerExceptionFromCode
289 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
290 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700291END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800292
buzbee5bc5a7b2012-03-07 15:52:59 -0800293 /*
294 * Called by managed code to create and deliver an ArithmeticException
295 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800296 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700297ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800298 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700299 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700300 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700301 la $t9, artThrowDivZeroFromCode
302 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700303 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700304END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800305
buzbee5bc5a7b2012-03-07 15:52:59 -0800306 /*
307 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
308 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800309 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700310ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800311 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700312 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700313 move $a2, rSELF # pass Thread::Current
314 la $t9, artThrowArrayBoundsFromCode
315 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
316 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700317END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800318
Ian Rogers57b86d42012-03-27 16:05:41 -0700319 /*
320 * Called by managed code to create and deliver a StackOverflowError.
321 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800322 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700323ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800324 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700325 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700326 move $a0, rSELF # pass Thread::Current
327 la $t9, artThrowStackOverflowFromCode
328 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
329 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700330END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800331
Ian Rogers57b86d42012-03-27 16:05:41 -0700332 /*
333 * Called by managed code to create and deliver a NoSuchMethodError.
334 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800335 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700336ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800337 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700338 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700339 move $a1, rSELF # pass Thread::Current
340 la $t9, artThrowNoSuchMethodFromCode
341 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
342 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700343END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800344
buzbee5bc5a7b2012-03-07 15:52:59 -0800345 /*
346 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700347 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800348 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
349 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700350 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800351 *
jeffhao7fbee072012-08-24 17:56:54 -0700352 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
353 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800354 *
jeffhaofa147e22012-10-12 17:03:32 -0700355 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800356 * thread and we branch to another stub to deliver it.
357 *
358 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
359 * pointing back to the original caller.
360 */
361.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800362 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800363ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800364 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700365 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700366 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700367 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700368 addiu $sp, $sp, -32 # make space for extra args
369 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700370 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800371 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700372 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700373 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700374 addiu $sp, $sp, 32 # release out args
375 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700376 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700377 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800378 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700379 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800380 nop
jeffhao30a33172012-10-22 18:16:22 -0700381 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800382 nop
3831:
384 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800385END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800386.endm
387
Logan Chien8dbb7082013-01-25 20:31:17 +0800388INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
389INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800390
Logan Chien8dbb7082013-01-25 20:31:17 +0800391INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
392INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
393INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
394INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800395
Jeff Hao79fe5392013-04-24 18:41:58 -0700396 /*
Jeff Hao6474d192013-03-26 14:08:09 -0700397 * Common invocation stub for portable and quick.
Jeff Hao5d917302013-02-27 17:57:33 -0800398 * On entry:
399 * a0 = method pointer
400 * a1 = argument array or NULL for no argument methods
401 * a2 = size of argument array in bytes
402 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700403 * [sp + 16] = JValue* result
404 * [sp + 20] = result type char
Jeff Hao5d917302013-02-27 17:57:33 -0800405 */
Jeff Hao79fe5392013-04-24 18:41:58 -0700406 .type art_portable_invoke_stub, %function
407 .global art_portable_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700408art_portable_invoke_stub:
Jeff Hao5d917302013-02-27 17:57:33 -0800409ENTRY art_quick_invoke_stub
410 GENERATE_GLOBAL_POINTER
411 sw $a0, 0($sp) # save out a0
412 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
413 .cfi_adjust_cfa_offset 16
414 sw $ra, 12($sp)
415 .cfi_rel_offset 31, 12
416 sw $fp, 8($sp)
417 .cfi_rel_offset 30, 8
418 sw $s1, 4($sp)
419 .cfi_rel_offset 17, 4
420 sw $s0, 0($sp)
421 .cfi_rel_offset 16, 0
422 move $fp, $sp # save sp in fp
423 .cfi_def_cfa_register 30
424 move $s1, $a3 # move managed thread pointer into s1
425 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
426 addiu $t0, $a2, 16 # create space for method pointer in frame
427 srl $t0, $t0, 3 # shift the frame size right 3
428 sll $t0, $t0, 3 # shift the frame size left 3 to align to 16 bytes
429 subu $sp, $sp, $t0 # reserve stack space for argument array
430 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
431 jal memcpy # (dest, src, bytes)
432 addiu $sp, $sp, -16 # make space for argument slots for memcpy
433 addiu $sp, $sp, 16 # restore stack after memcpy
434 lw $a0, 16($fp) # restore method*
435 lw $a1, 4($sp) # copy arg value for a1
436 lw $a2, 8($sp) # copy arg value for a2
437 lw $a3, 12($sp) # copy arg value for a3
438 lw $t9, METHOD_CODE_OFFSET($a0) # get pointer to the code
439 jalr $t9 # call the method
440 sw $zero, 0($sp) # store NULL for method* at bottom of frame
441 move $sp, $fp # restore the stack
442 lw $s0, 0($sp)
443 lw $s1, 4($sp)
444 lw $fp, 8($sp)
445 lw $ra, 12($sp)
446 addiu $sp, $sp, 16
447 .cfi_adjust_cfa_offset -16
448 lw $t0, 16($sp) # get result pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700449 lw $t1, 20($sp) # get result type char
450 li $t2, 68 # put char 'D' into t2
451 beq $t1, $t2, 1f # branch if result type char == 'D'
452 li $t3, 70 # put char 'F' into t3
453 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800454 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700455 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800456 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07004571:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700458 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800459 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700460 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800461END art_quick_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700462 .size art_portable_invoke_stub, .-art_portable_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800463
464 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800465 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
466 * failure.
467 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800468 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700469ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800470 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700471 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
472 move $a2, rSELF # pass Thread::Current
473 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
474 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700475 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700476END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800477
buzbee5bc5a7b2012-03-07 15:52:59 -0800478 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700479 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800480 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800481 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700482ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800483 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700484 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
485 move $a1, rSELF # pass Thread::Current
486 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
487 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800488 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogers468532e2013-08-05 10:56:33 -0700489END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800490
buzbee5bc5a7b2012-03-07 15:52:59 -0800491 /*
492 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
493 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800494 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700495ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800496 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700497 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
498 move $a1, rSELF # pass Thread::Current
499 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
500 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800501 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700502END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800503
buzbee5bc5a7b2012-03-07 15:52:59 -0800504 /*
505 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
506 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800507 .extern artCheckCastFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700508ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800509 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700510 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
511 move $a2, rSELF # pass Thread::Current
512 jal artCheckCastFromCode # (Class* a, Class* b, Thread*, $sp)
513 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800514 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700515END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800516
buzbee5bc5a7b2012-03-07 15:52:59 -0800517 /*
518 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
519 * failure.
520 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800521 .extern artCanPutArrayElementFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700522ENTRY art_quick_can_put_array_element
jeffhao12051ea2013-01-10 11:24:31 -0800523 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700524 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
525 move $a2, rSELF # pass Thread::Current
526 jal artCanPutArrayElementFromCode # (Object* element, Class* array_class, Thread*, $sp)
527 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800528 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700529END art_quick_can_put_array_element
buzbee5bc5a7b2012-03-07 15:52:59 -0800530
buzbee5bc5a7b2012-03-07 15:52:59 -0800531 /*
532 * Entry from managed code when uninitialized static storage, this stub will run the class
533 * initializer and deliver the exception on error. On success the static storage base is
534 * returned.
535 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800536 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700537ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800538 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700539 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
540 move $a2, rSELF # pass Thread::Current
541 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800542 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700543 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800544 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700545END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800546
buzbee5bc5a7b2012-03-07 15:52:59 -0800547 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700548 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800549 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800550 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700551ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800552 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700553 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
554 move $a2, rSELF # pass Thread::Current
555 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800556 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700557 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800558 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700559END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800560
buzbee5bc5a7b2012-03-07 15:52:59 -0800561 /*
562 * 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 -0700563 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800565 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700566ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800567 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700568 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
569 move $a2, rSELF # pass Thread::Current
570 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800571 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700572 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800573 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700574END art_quick_initialize_type_and_verify_access
buzbee5bc5a7b2012-03-07 15:52:59 -0800575
buzbee5bc5a7b2012-03-07 15:52:59 -0800576 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700577 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800578 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800579 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700580ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800581 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700582 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700583 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700584 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700585 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700586 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800587 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700588END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800589
buzbee5bc5a7b2012-03-07 15:52:59 -0800590 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700591 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800592 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800593 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700594ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800595 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700596 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700597 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700598 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700599 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700600 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800601 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700602END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800603
buzbee5bc5a7b2012-03-07 15:52:59 -0800604 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700605 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800606 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800607 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700608ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800609 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700610 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700611 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700612 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700613 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700614 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800615 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700616END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800617
buzbee5bc5a7b2012-03-07 15:52:59 -0800618 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700619 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800620 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800621 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700622ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800623 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700624 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700625 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700626 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700627 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700628 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800629 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700630END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800631
buzbee5bc5a7b2012-03-07 15:52:59 -0800632 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700633 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800634 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800635 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700636ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800637 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700638 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700639 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700640 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700641 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700642 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800643 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700644END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800645
buzbee5bc5a7b2012-03-07 15:52:59 -0800646 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700647 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800648 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800649 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700650ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800651 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700652 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700653 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700654 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700655 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700656 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800657 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700658END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800659
buzbee5bc5a7b2012-03-07 15:52:59 -0800660 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700661 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800662 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800663 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700664ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800665 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700666 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700667 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700668 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700669 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700670 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800671 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700672END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800673
buzbee5bc5a7b2012-03-07 15:52:59 -0800674 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700675 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800676 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800677 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700678ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800679 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700680 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700681 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700682 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700683 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700684 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800685 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700686END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800687
buzbee5bc5a7b2012-03-07 15:52:59 -0800688 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700689 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800690 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800691 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700692ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800693 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700694 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700695 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700696 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700697 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700698 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800699 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700700END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800701
buzbee5bc5a7b2012-03-07 15:52:59 -0800702 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700703 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800704 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800705 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700706ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800707 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700708 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700709 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700710 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700711 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700712 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800713 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700714END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800715
buzbee5bc5a7b2012-03-07 15:52:59 -0800716 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700717 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800718 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800719 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700720ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800721 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700722 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700723 sw rSELF, 16($sp) # pass Thread::Current
724 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700725 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800726 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700727END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800728
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700730 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800731 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800732 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700733ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800734 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700735 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700736 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700737 sw rSELF, 16($sp) # pass Thread::Current
738 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700739 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800740 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700741END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800742
buzbee5bc5a7b2012-03-07 15:52:59 -0800743 /*
744 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
745 * exception on error. On success the String is returned. R0 holds the referring method,
746 * R1 holds the string index. The fast path check for hit in strings cache has already been
747 * performed.
748 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800749 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700750ENTRY art_quick_resolve_string
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
753 move $a2, rSELF # pass Thread::Current
754 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800755 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700756 move $a3, $sp # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700757 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700758END art_quick_resolve_string
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 allocate an object.
buzbee5bc5a7b2012-03-07 15:52:59 -0800762 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800763 .extern artAllocObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700764ENTRY art_quick_alloc_object
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
767 move $a2, rSELF # pass Thread::Current
768 jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp)
769 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800770 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700771END art_quick_alloc_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800772
buzbee5bc5a7b2012-03-07 15:52:59 -0800773 /*
774 * Called by managed code to allocate an object when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700775 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800776 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800777 .extern artAllocObjectFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700778ENTRY art_quick_alloc_object_with_access_check
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
781 move $a2, rSELF # pass Thread::Current
782 jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp)
783 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800784 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700785END art_quick_alloc_object_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800786
buzbee5bc5a7b2012-03-07 15:52:59 -0800787 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700788 * Called by managed code to allocate an array.
buzbee5bc5a7b2012-03-07 15:52:59 -0800789 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800790 .extern artAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700791ENTRY art_quick_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800792 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700793 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
794 move $a3, rSELF # pass Thread::Current
795 # artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800796 jal artAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700797 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800798 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700799END art_quick_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800800
buzbee5bc5a7b2012-03-07 15:52:59 -0800801 /*
802 * Called by managed code to allocate an array when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700803 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800804 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800805 .extern artAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700806ENTRY art_quick_alloc_array_with_access_check
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
809 move $a3, rSELF # pass Thread::Current
810 # artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800811 jal artAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700812 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800813 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700814END art_quick_alloc_array_with_access_check
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 allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800819 .extern artCheckAndAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700820ENTRY art_quick_check_and_alloc_array
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
823 move $a3, rSELF # pass Thread::Current
824 # artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800825 jal artCheckAndAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700826 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800827 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700828END art_quick_check_and_alloc_array
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 allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800832 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800833 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700834ENTRY art_quick_check_and_alloc_array_with_access_check
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 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700838 # artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800839 jal artCheckAndAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700840 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800841 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700842END art_quick_check_and_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800843
buzbee5bc5a7b2012-03-07 15:52:59 -0800844 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700845 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -0800846 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800847 .extern artTestSuspendFromCode
848ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -0800849 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -0700850 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -0700851 bnez $a0, 1f
852 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
853 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800854 nop
8551:
jeffhao7fbee072012-08-24 17:56:54 -0700856 move $a0, rSELF
857 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
858 jal artTestSuspendFromCode # (Thread*, $sp)
859 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800860 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800861END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -0800862
buzbee5bc5a7b2012-03-07 15:52:59 -0800863 /*
864 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -0700865 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 */
Jeff Hao5fa60c32013-04-04 17:57:01 -0700867 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800868ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -0800869 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -0800870 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700871 sw $a0, 0($sp) # place proxy method at bottom of frame
872 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -0700873 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800874 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -0700875 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700876 lw $gp, 52($sp) # restore $gp
877 lw $ra, 60($sp) # restore $ra
jeffhao7fbee072012-08-24 17:56:54 -0700878 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700879 addiu $sp, $sp, 64 # pop frame
880 .cfi_adjust_cfa_offset -64
jeffhao7fbee072012-08-24 17:56:54 -0700881 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800882 nop
8831:
884 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800885END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -0800886
Ian Rogers468532e2013-08-05 10:56:33 -0700887 .extern artQuickResolutionTrampoline
888ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -0800889 GENERATE_GLOBAL_POINTER
890 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -0700891 move $a2, rSELF # pass Thread::Current
892 jal artQuickProxyInvokeHandler # (Method* called, receiver, Thread*, SP)
893 move $a3, $sp # pass $sp
894 lw $gp, 52($sp) # restore $gp
895 lw $ra, 60($sp) # restore $ra
896 beqz $v0, 1f
897 lw $a0, 0($sp) # load resolved method to $a0
898 lw $a1, 4($sp) # restore non-callee save $a1
899 lw $a2, 8($sp) # restore non-callee save $a2
900 lw $a3, 12($sp) # restore non-callee save $a3
901 jr $v0 # tail call to method
9021:
903 addiu $sp, $sp, 64 # pop frame
904 .cfi_adjust_cfa_offset -64
905 DELIVER_PENDING_EXCEPTION
906END art_quick_resolution_trampoline
907
908 .extern artQuickToInterpreterBridge
909ENTRY art_quick_to_interpreter_bridge
910 GENERATE_GLOBAL_POINTER
911 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -0800912 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700913 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -0800914 move $a2, $sp # pass $sp
915 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700916 lw $gp, 52($sp) # restore $gp
917 lw $ra, 60($sp) # restore $ra
Ian Rogers7db619b2013-01-16 18:35:48 -0800918 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700919 addiu $sp, $sp, 64 # pop frame
920 .cfi_adjust_cfa_offset -64
Ian Rogers7db619b2013-01-16 18:35:48 -0800921 jr $ra
922 nop
9231:
924 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700925END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -0800926
buzbee5bc5a7b2012-03-07 15:52:59 -0800927 /*
jeffhao725a9572012-11-13 18:20:12 -0800928 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -0800929 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800930 .extern artInstrumentationMethodEntryFromCode
931 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700932ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -0800933 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -0800934 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -0800935 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -0800936 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
937 .cfi_adjust_cfa_offset 32
938 sw $a0, 28($sp) # save arg0
939 sw $ra, 16($sp) # pass $ra
940 move $a3, $t0 # pass $sp
941 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
942 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700943 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -0800944 lw $a0, 28($sp) # restore arg0
945 addiu $sp, $sp, 32 # remove args
946 .cfi_adjust_cfa_offset -32
947 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700948 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -0800949 nop
Ian Rogers468532e2013-08-05 10:56:33 -0700950END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -0800951 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -0700952 .global art_quick_instrumentation_exit
953art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800954 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -0800955 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
956 GENERATE_GLOBAL_POINTER
957 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -0800958 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
959 addiu $sp, $sp, -48 # save return values and set up args
960 .cfi_adjust_cfa_offset 48
961 sw $v0, 32($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800962 .cfi_rel_offset 2, 0
Ian Rogers62d6c772013-02-27 08:32:07 -0800963 sw $v1, 36($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800964 .cfi_rel_offset 3, 4
Ian Rogers62d6c772013-02-27 08:32:07 -0800965 s.s $f0, 40($sp)
966 s.s $f1, 44($sp)
967 s.s $f0, 16($sp) # pass fpr result
968 s.s $f1, 20($sp)
969 move $a2, $v0 # pass gpr result
970 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -0800971 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -0800972 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -0800973 move $a0, rSELF # pass Thread::Current
974 move $t0, $v0 # set aside returned link register
975 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -0800976 lw $v0, 32($sp) # restore return values
977 lw $v1, 36($sp)
978 l.s $f0, 40($sp)
979 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -0800980 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -0800981 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
982 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -0700983END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -0800984
jeffhao12051ea2013-01-10 11:24:31 -0800985 /*
Ian Rogers62d6c772013-02-27 08:32:07 -0800986 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
987 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -0800988 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800989 .extern artDeoptimize
990 .extern artEnterInterpreterFromDeoptimize
991ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -0800992 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -0700993 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -0800994 move $a0, rSELF # pass Thread::current
995 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -0800996 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -0800997 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800998END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -0800999
buzbee5bc5a7b2012-03-07 15:52:59 -08001000 /*
1001 * Long integer shift. This is different from the generic 32/64-bit
1002 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1003 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1004 * 6 bits.
1005 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001006 * $a0: low word
1007 * $a1: high word
1008 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001009 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001010ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001011 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001012 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1013 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1014 srl $a0, 1
1015 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1016 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1017 or $v1, $a0 # rhi<- rhi | alo
1018 andi $a2, 0x20 # shift< shift & 0x20
1019 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1020 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001021 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001022END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001023
buzbee5bc5a7b2012-03-07 15:52:59 -08001024 /*
1025 * Long integer shift. This is different from the generic 32/64-bit
1026 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1027 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1028 * 6 bits.
1029 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001030 * $a0: low word
1031 * $a1: high word
1032 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001033 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001034 .global art_quick_shr_long
1035ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001036 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1037 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1038 sra $a3, $a1, 31 # $a3<- sign(ah)
1039 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1040 sll $a1, 1
1041 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1042 or $v0, $a1 # rlo<- rlo | ahi
1043 andi $a2, 0x20 # shift & 0x20
1044 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1045 jr $ra
1046 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001047END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001048
buzbee5bc5a7b2012-03-07 15:52:59 -08001049 /*
1050 * Long integer shift. This is different from the generic 32/64-bit
1051 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1052 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1053 * 6 bits.
1054 * On entry:
1055 * r0: low word
1056 * r1: high word
1057 * r2: shift count
1058 */
1059 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001060 .global art_quick_ushr_long
1061ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001062 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001063 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001064 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1065 sll $a1, 1
1066 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1067 or $v0, $a1 # rlo<- rlo | ahi
1068 andi $a2, 0x20 # shift & 0x20
1069 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1070 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001071 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001072END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001073
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001074ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001075 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001076 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001077END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001078
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001079ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001080 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001081 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001082END art_quick_string_compareto