blob: 7780bb3a25eca3bfb95ec4fc09aabd78a7c23e95 [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 Rogersa9a82542013-10-04 11:17:26 -0700286art_quick_throw_null_pointer_exception_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700287 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700288 move $a0, rSELF # pass Thread::Current
289 la $t9, artThrowNullPointerExceptionFromCode
290 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
291 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700292END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800293
buzbee5bc5a7b2012-03-07 15:52:59 -0800294 /*
295 * Called by managed code to create and deliver an ArithmeticException
296 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800297 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700298ENTRY art_quick_throw_div_zero
jeffhao12051ea2013-01-10 11:24:31 -0800299 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700300 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700301 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700302 la $t9, artThrowDivZeroFromCode
303 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700304 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700305END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800306
buzbee5bc5a7b2012-03-07 15:52:59 -0800307 /*
308 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
309 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800310 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700311ENTRY art_quick_throw_array_bounds
jeffhao12051ea2013-01-10 11:24:31 -0800312 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700313art_quick_throw_array_bounds_gp_set:
Ian Rogers57b86d42012-03-27 16:05:41 -0700314 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700315 move $a2, rSELF # pass Thread::Current
316 la $t9, artThrowArrayBoundsFromCode
317 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
318 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700319END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800320
Ian Rogers57b86d42012-03-27 16:05:41 -0700321 /*
322 * Called by managed code to create and deliver a StackOverflowError.
323 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800324 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700325ENTRY art_quick_throw_stack_overflow
jeffhao12051ea2013-01-10 11:24:31 -0800326 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700327 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700328 move $a0, rSELF # pass Thread::Current
329 la $t9, artThrowStackOverflowFromCode
330 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
331 move $a1, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700332END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800333
Ian Rogers57b86d42012-03-27 16:05:41 -0700334 /*
335 * Called by managed code to create and deliver a NoSuchMethodError.
336 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800337 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700338ENTRY art_quick_throw_no_such_method
jeffhao12051ea2013-01-10 11:24:31 -0800339 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700340 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700341 move $a1, rSELF # pass Thread::Current
342 la $t9, artThrowNoSuchMethodFromCode
343 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
344 move $a2, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700345END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800346
buzbee5bc5a7b2012-03-07 15:52:59 -0800347 /*
348 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700349 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800350 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
351 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700352 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800353 *
jeffhao7fbee072012-08-24 17:56:54 -0700354 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
355 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800356 *
jeffhaofa147e22012-10-12 17:03:32 -0700357 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800358 * thread and we branch to another stub to deliver it.
359 *
360 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
361 * pointing back to the original caller.
362 */
363.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800364 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800365ENTRY \c_name
jeffhao12051ea2013-01-10 11:24:31 -0800366 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700367 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700368 lw $a2, 64($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700369 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700370 addiu $sp, $sp, -32 # make space for extra args
371 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700372 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800373 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700374 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700375 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700376 addiu $sp, $sp, 32 # release out args
377 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700378 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700379 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800380 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700381 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800382 nop
jeffhao30a33172012-10-22 18:16:22 -0700383 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800384 nop
3851:
386 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800387END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800388.endm
389
Logan Chien8dbb7082013-01-25 20:31:17 +0800390INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
391INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800392
Logan Chien8dbb7082013-01-25 20:31:17 +0800393INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
394INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
395INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
396INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800397
Jeff Hao79fe5392013-04-24 18:41:58 -0700398 /*
Jeff Hao6474d192013-03-26 14:08:09 -0700399 * Common invocation stub for portable and quick.
Jeff Hao5d917302013-02-27 17:57:33 -0800400 * On entry:
401 * a0 = method pointer
402 * a1 = argument array or NULL for no argument methods
403 * a2 = size of argument array in bytes
404 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700405 * [sp + 16] = JValue* result
406 * [sp + 20] = result type char
Jeff Hao5d917302013-02-27 17:57:33 -0800407 */
Jeff Hao79fe5392013-04-24 18:41:58 -0700408 .type art_portable_invoke_stub, %function
409 .global art_portable_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700410art_portable_invoke_stub:
Jeff Hao5d917302013-02-27 17:57:33 -0800411ENTRY art_quick_invoke_stub
412 GENERATE_GLOBAL_POINTER
413 sw $a0, 0($sp) # save out a0
414 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
415 .cfi_adjust_cfa_offset 16
416 sw $ra, 12($sp)
417 .cfi_rel_offset 31, 12
418 sw $fp, 8($sp)
419 .cfi_rel_offset 30, 8
420 sw $s1, 4($sp)
421 .cfi_rel_offset 17, 4
422 sw $s0, 0($sp)
423 .cfi_rel_offset 16, 0
424 move $fp, $sp # save sp in fp
425 .cfi_def_cfa_register 30
426 move $s1, $a3 # move managed thread pointer into s1
427 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
428 addiu $t0, $a2, 16 # create space for method pointer in frame
429 srl $t0, $t0, 3 # shift the frame size right 3
430 sll $t0, $t0, 3 # shift the frame size left 3 to align to 16 bytes
431 subu $sp, $sp, $t0 # reserve stack space for argument array
432 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
433 jal memcpy # (dest, src, bytes)
434 addiu $sp, $sp, -16 # make space for argument slots for memcpy
435 addiu $sp, $sp, 16 # restore stack after memcpy
436 lw $a0, 16($fp) # restore method*
437 lw $a1, 4($sp) # copy arg value for a1
438 lw $a2, 8($sp) # copy arg value for a2
439 lw $a3, 12($sp) # copy arg value for a3
440 lw $t9, METHOD_CODE_OFFSET($a0) # get pointer to the code
441 jalr $t9 # call the method
442 sw $zero, 0($sp) # store NULL for method* at bottom of frame
443 move $sp, $fp # restore the stack
444 lw $s0, 0($sp)
445 lw $s1, 4($sp)
446 lw $fp, 8($sp)
447 lw $ra, 12($sp)
448 addiu $sp, $sp, 16
449 .cfi_adjust_cfa_offset -16
450 lw $t0, 16($sp) # get result pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700451 lw $t1, 20($sp) # get result type char
452 li $t2, 68 # put char 'D' into t2
453 beq $t1, $t2, 1f # branch if result type char == 'D'
454 li $t3, 70 # put char 'F' into t3
455 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800456 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700457 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800458 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07004591:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700460 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800461 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700462 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800463END art_quick_invoke_stub
Jeff Hao6474d192013-03-26 14:08:09 -0700464 .size art_portable_invoke_stub, .-art_portable_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800465
466 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800467 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
468 * failure.
469 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800470 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700471ENTRY art_quick_handle_fill_data
jeffhao12051ea2013-01-10 11:24:31 -0800472 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700473 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
474 move $a2, rSELF # pass Thread::Current
475 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
476 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700477 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700478END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800479
buzbee5bc5a7b2012-03-07 15:52:59 -0800480 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700481 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800482 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800483 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700484ENTRY art_quick_lock_object
jeffhao12051ea2013-01-10 11:24:31 -0800485 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700486 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
487 nop
jeffhao7fbee072012-08-24 17:56:54 -0700488 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
489 move $a1, rSELF # pass Thread::Current
490 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
491 move $a2, $sp # pass $sp
Ian Rogers6bcd1632013-10-08 18:50:47 -0700492 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700493END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800494
buzbee5bc5a7b2012-03-07 15:52:59 -0800495 /*
496 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
497 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800498 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700499ENTRY art_quick_unlock_object
jeffhao12051ea2013-01-10 11:24:31 -0800500 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700501 beqz $a0, art_quick_throw_null_pointer_exception_gp_set
502 nop
jeffhao7fbee072012-08-24 17:56:54 -0700503 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
504 move $a1, rSELF # pass Thread::Current
505 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
506 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800507 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700508END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800509
buzbee5bc5a7b2012-03-07 15:52:59 -0800510 /*
511 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
512 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700513 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700514ENTRY art_quick_check_cast
jeffhao12051ea2013-01-10 11:24:31 -0800515 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700516 addiu $sp, $sp, -16
517 .cfi_adjust_cfa_offset 16
518 sw $ra, 12($sp)
519 .cfi_rel_offset 31, 12
520 sw $t9, 8($sp)
521 sw $a1, 4($sp)
522 sw $a0, 0($sp)
523 jal artIsAssignableFromCode
524 nop
525 beqz $v0, throw_class_cast_exception
526 lw $ra, 12($sp)
527 jr $ra
528 addiu $sp, $sp, 16
529 .cfi_adjust_cfa_offset -16
530throw_class_cast_exception:
531 lw $t9, 8($sp)
532 lw $a1, 4($sp)
533 lw $a0, 0($sp)
534 addiu $sp, $sp, 16
535 .cfi_adjust_cfa_offset -16
536 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
537 move $a2, rSELF # pass Thread::Current
538 la $t9, artThrowClassCastException
539 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*, SP)
540 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -0700541END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800542
buzbee5bc5a7b2012-03-07 15:52:59 -0800543 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700544 * Entry from managed code for array put operations of objects where the value being stored
545 * needs to be checked for compatibility.
546 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800547 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700548ENTRY art_quick_aput_obj_with_null_and_bound_check
jeffhao12051ea2013-01-10 11:24:31 -0800549 GENERATE_GLOBAL_POINTER
Ian Rogersa9a82542013-10-04 11:17:26 -0700550 bnez $a0, art_quick_aput_obj_with_bound_check_gp_set
551 nop
552 b art_quick_throw_null_pointer_exception_gp_set
553 nop
554END art_quick_aput_obj_with_null_and_bound_check
555
556ENTRY art_quick_aput_obj_with_bound_check
557 GENERATE_GLOBAL_POINTER
558art_quick_aput_obj_with_bound_check_gp_set:
559 lw $t0, ARRAY_LENGTH_OFFSET($a0)
560 sltu $t1, $a1, $t0
561 bnez $t1, art_quick_aput_obj_gp_set
562 nop
563 move $a0, $a1
564 b art_quick_throw_array_bounds_gp_set
565 move $a1, $t0
566END art_quick_aput_obj_with_bound_check
567
568ENTRY art_quick_aput_obj
569 GENERATE_GLOBAL_POINTER
570art_quick_aput_obj_gp_set:
571 beqz $a2, do_aput_null
572 nop
573 lw $t0, CLASS_OFFSET($a0)
574 lw $t1, CLASS_OFFSET($a2)
575 lw $t0, CLASS_COMPONENT_TYPE_OFFSET($t0)
576 bne $t1, $t0, check_assignability # value's type == array's component type - trivial assignability
577 nop
578do_aput:
579 sll $a1, $a1, 2
580 add $t0, $a0, $a1
581 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
582 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
583 srl $t1, $a0, 7
584 add $t1, $t1, $t0
585 sb $t0, ($t1)
586 jr $ra
587 nop
588do_aput_null:
589 sll $a1, $a1, 2
590 add $t0, $a0, $a1
591 sw $a2, OBJECT_ARRAY_DATA_OFFSET($t0)
592 jr $ra
593 nop
594check_assignability:
595 addiu $sp, $sp, -32
596 .cfi_adjust_cfa_offset 32
597 sw $ra, 28($sp)
598 .cfi_rel_offset 31, 28
599 sw $t9, 12($sp)
600 sw $a2, 8($sp)
601 sw $a1, 4($sp)
602 sw $a0, 0($sp)
603 move $a1, $t1
604 move $a0, $t0
605 jal artIsAssignableFromCode # (Class*, Class*)
606 nop
607 lw $ra, 28($sp)
608 lw $t9, 12($sp)
609 lw $a2, 8($sp)
610 lw $a1, 4($sp)
611 lw $a0, 0($sp)
612 add $sp, 32
613 .cfi_adjust_cfa_offset -32
614 bnez $v0, do_aput
615 nop
616 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
617 move $a1, $a2
618 move $a2, rSELF # pass Thread::Current
619 la $t9, artThrowArrayStoreException
620 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*, SP)
621 move $a3, $sp # pass $sp
622END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800623
buzbee5bc5a7b2012-03-07 15:52:59 -0800624 /*
625 * Entry from managed code when uninitialized static storage, this stub will run the class
626 * initializer and deliver the exception on error. On success the static storage base is
627 * returned.
628 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800629 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700630ENTRY art_quick_initialize_static_storage
jeffhao12051ea2013-01-10 11:24:31 -0800631 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700632 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
633 move $a2, rSELF # pass Thread::Current
634 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800635 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700636 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800637 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700638END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800639
buzbee5bc5a7b2012-03-07 15:52:59 -0800640 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700641 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800642 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800643 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700644ENTRY art_quick_initialize_type
jeffhao12051ea2013-01-10 11:24:31 -0800645 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700646 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
647 move $a2, rSELF # pass Thread::Current
648 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800649 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700650 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800651 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700652END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800653
buzbee5bc5a7b2012-03-07 15:52:59 -0800654 /*
655 * 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 -0700656 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800657 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800658 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700659ENTRY art_quick_initialize_type_and_verify_access
jeffhao12051ea2013-01-10 11:24:31 -0800660 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700661 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
662 move $a2, rSELF # pass Thread::Current
663 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800664 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700665 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800666 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700667END art_quick_initialize_type_and_verify_access
buzbee5bc5a7b2012-03-07 15:52:59 -0800668
buzbee5bc5a7b2012-03-07 15:52:59 -0800669 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700670 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800671 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800672 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700673ENTRY art_quick_get32_static
jeffhao12051ea2013-01-10 11:24:31 -0800674 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700675 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700676 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700677 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700678 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700679 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800680 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700681END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800682
buzbee5bc5a7b2012-03-07 15:52:59 -0800683 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700684 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800685 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800686 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700687ENTRY art_quick_get64_static
jeffhao12051ea2013-01-10 11:24:31 -0800688 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700689 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700690 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700691 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700692 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700693 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800694 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700695END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800696
buzbee5bc5a7b2012-03-07 15:52:59 -0800697 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700698 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800699 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800700 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700701ENTRY art_quick_get_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800702 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700703 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700704 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700705 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700706 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700707 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800708 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700709END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800710
buzbee5bc5a7b2012-03-07 15:52:59 -0800711 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700712 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800713 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800714 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700715ENTRY art_quick_get32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800716 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700717 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700718 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700719 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700720 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700721 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800722 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700723END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800724
buzbee5bc5a7b2012-03-07 15:52:59 -0800725 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700726 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800727 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800728 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700729ENTRY art_quick_get64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800730 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700731 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700732 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700733 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700734 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700735 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800736 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700737END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800738
buzbee5bc5a7b2012-03-07 15:52:59 -0800739 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700740 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800741 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800742 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700743ENTRY art_quick_get_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800744 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700745 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700746 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700747 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700748 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700749 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800750 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700751END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800752
buzbee5bc5a7b2012-03-07 15:52:59 -0800753 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700754 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800755 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800756 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700757ENTRY art_quick_set32_static
jeffhao12051ea2013-01-10 11:24:31 -0800758 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700759 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700760 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700761 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700762 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700763 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800764 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700765END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800766
buzbee5bc5a7b2012-03-07 15:52:59 -0800767 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700768 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800769 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800770 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700771ENTRY art_quick_set64_static
jeffhao12051ea2013-01-10 11:24:31 -0800772 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700773 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700774 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700775 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700776 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700777 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800778 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700779END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800780
buzbee5bc5a7b2012-03-07 15:52:59 -0800781 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700782 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800783 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800784 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700785ENTRY art_quick_set_obj_static
jeffhao12051ea2013-01-10 11:24:31 -0800786 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700787 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700788 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700789 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700790 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700791 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800792 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700793END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800794
buzbee5bc5a7b2012-03-07 15:52:59 -0800795 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700796 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800797 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800798 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700799ENTRY art_quick_set32_instance
jeffhao12051ea2013-01-10 11:24:31 -0800800 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700801 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700802 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700803 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700804 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700805 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800806 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700807END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800808
buzbee5bc5a7b2012-03-07 15:52:59 -0800809 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700810 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800811 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800812 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700813ENTRY art_quick_set64_instance
jeffhao12051ea2013-01-10 11:24:31 -0800814 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700815 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700816 sw rSELF, 16($sp) # pass Thread::Current
817 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700818 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800819 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700820END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800821
buzbee5bc5a7b2012-03-07 15:52:59 -0800822 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700823 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800824 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800825 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700826ENTRY art_quick_set_obj_instance
jeffhao12051ea2013-01-10 11:24:31 -0800827 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700828 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700829 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700830 sw rSELF, 16($sp) # pass Thread::Current
831 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700832 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800833 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700834END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800835
buzbee5bc5a7b2012-03-07 15:52:59 -0800836 /*
837 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
838 * exception on error. On success the String is returned. R0 holds the referring method,
839 * R1 holds the string index. The fast path check for hit in strings cache has already been
840 * performed.
841 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800842 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700843ENTRY art_quick_resolve_string
jeffhao12051ea2013-01-10 11:24:31 -0800844 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700845 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
846 move $a2, rSELF # pass Thread::Current
847 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800848 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700849 move $a3, $sp # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700850 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700851END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -0800852
buzbee5bc5a7b2012-03-07 15:52:59 -0800853 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700854 * Called by managed code to allocate an object.
buzbee5bc5a7b2012-03-07 15:52:59 -0800855 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800856 .extern artAllocObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700857ENTRY art_quick_alloc_object
jeffhao12051ea2013-01-10 11:24:31 -0800858 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700859 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
860 move $a2, rSELF # pass Thread::Current
861 jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp)
862 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800863 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700864END art_quick_alloc_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800865
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700866 .extern artAllocObjectFromCodeInstrumented
867ENTRY art_quick_alloc_object_instrumented
868 GENERATE_GLOBAL_POINTER
869 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
870 move $a2, rSELF # pass Thread::Current
871 jal artAllocObjectFromCodeInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
872 move $a3, $sp # pass $sp
873 RETURN_IF_NONZERO
874END art_quick_alloc_object_instrumented
875
buzbee5bc5a7b2012-03-07 15:52:59 -0800876 /*
877 * Called by managed code to allocate an object when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700878 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800879 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800880 .extern artAllocObjectFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700881ENTRY art_quick_alloc_object_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800882 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700883 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
884 move $a2, rSELF # pass Thread::Current
885 jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp)
886 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800887 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700888END art_quick_alloc_object_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800889
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700890 .extern artAllocObjectFromCodeWithAccessCheckInstrumented
891ENTRY art_quick_alloc_object_with_access_check_instrumented
892 GENERATE_GLOBAL_POINTER
893 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
894 move $a2, rSELF # pass Thread::Current
895 jal artAllocObjectFromCodeWithAccessCheckInstrumented # (uint32_t type_idx, Method* method, Thread*, $sp)
896 move $a3, $sp # pass $sp
897 RETURN_IF_NONZERO
898END art_quick_alloc_object_with_access_check_instrumented
899
buzbee5bc5a7b2012-03-07 15:52:59 -0800900 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700901 * Called by managed code to allocate an array.
buzbee5bc5a7b2012-03-07 15:52:59 -0800902 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800903 .extern artAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700904ENTRY art_quick_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800905 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700906 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
907 move $a3, rSELF # pass Thread::Current
908 # artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800909 jal artAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700910 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800911 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700912END art_quick_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800913
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700914 .extern artAllocArrayFromCodeInstrumented
915ENTRY art_quick_alloc_array_instrumented
916 GENERATE_GLOBAL_POINTER
917 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
918 move $a3, rSELF # pass Thread::Current
919 # artAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
920 jal artAllocArrayFromCodeInstrumented
921 sw $sp, 16($sp) # pass $sp
922 RETURN_IF_NONZERO
923END art_quick_alloc_array_instrumented
924
buzbee5bc5a7b2012-03-07 15:52:59 -0800925 /*
926 * Called by managed code to allocate an array when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700927 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800928 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800929 .extern artAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700930ENTRY art_quick_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800931 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700932 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
933 move $a3, rSELF # pass Thread::Current
934 # artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800935 jal artAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700936 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800937 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700938END art_quick_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800939
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700940 .extern artAllocArrayFromCodeWithAccessCheckInstrumented
941ENTRY art_quick_alloc_array_with_access_check_instrumented
942 GENERATE_GLOBAL_POINTER
943 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
944 move $a3, rSELF # pass Thread::Current
945 # artAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, component_count, Thread*, $sp)
946 jal artAllocArrayFromCodeWithAccessCheckInstrumented
947 sw $sp, 16($sp) # pass $sp
948 RETURN_IF_NONZERO
949END art_quick_alloc_array_with_access_check_instrumented
950
buzbee5bc5a7b2012-03-07 15:52:59 -0800951 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700952 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800953 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800954 .extern artCheckAndAllocArrayFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700955ENTRY art_quick_check_and_alloc_array
jeffhao12051ea2013-01-10 11:24:31 -0800956 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700957 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
958 move $a3, rSELF # pass Thread::Current
959 # artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800960 jal artCheckAndAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700961 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800962 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700963END art_quick_check_and_alloc_array
buzbee5bc5a7b2012-03-07 15:52:59 -0800964
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700965 .extern artCheckAndAllocArrayFromCodeInstrumented
966ENTRY art_quick_check_and_alloc_array_instrumented
967 GENERATE_GLOBAL_POINTER
968 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
969 move $a3, rSELF # pass Thread::Current
970 # artCheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
971 jal artCheckAndAllocArrayFromCodeInstrumented
972 sw $sp, 16($sp) # pass $sp
973 RETURN_IF_NONZERO
974END art_quick_check_and_alloc_array_instrumented
975
buzbee5bc5a7b2012-03-07 15:52:59 -0800976 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700977 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800978 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800979 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
Ian Rogers468532e2013-08-05 10:56:33 -0700980ENTRY art_quick_check_and_alloc_array_with_access_check
jeffhao12051ea2013-01-10 11:24:31 -0800981 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700982 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700983 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700984 # artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800985 jal artCheckAndAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700986 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800987 RETURN_IF_NONZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700988END art_quick_check_and_alloc_array_with_access_check
buzbee5bc5a7b2012-03-07 15:52:59 -0800989
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700990 .extern artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
991ENTRY art_quick_check_and_alloc_array_with_access_check_instrumented
992 GENERATE_GLOBAL_POINTER
993 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
994 move $a3, rSELF # pass Thread::Current
995 # artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, count, Thread* , $sp)
996 jal artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
997 sw $sp, 16($sp) # pass $sp
998 RETURN_IF_NONZERO
999END art_quick_check_and_alloc_array_with_access_check_instrumented
1000
buzbee5bc5a7b2012-03-07 15:52:59 -08001001 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001002 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001003 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001004 .extern artTestSuspendFromCode
1005ENTRY art_quick_test_suspend
jeffhao12051ea2013-01-10 11:24:31 -08001006 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -07001007 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001008 bnez $a0, 1f
1009 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1010 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001011 nop
10121:
jeffhao7fbee072012-08-24 17:56:54 -07001013 move $a0, rSELF
1014 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1015 jal artTestSuspendFromCode # (Thread*, $sp)
1016 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -08001017 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001018END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001019
buzbee5bc5a7b2012-03-07 15:52:59 -08001020 /*
1021 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001022 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001023 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001024 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001025ENTRY art_quick_proxy_invoke_handler
jeffhao12051ea2013-01-10 11:24:31 -08001026 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -08001027 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001028 sw $a0, 0($sp) # place proxy method at bottom of frame
1029 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001030 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001031 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001032 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001033 lw $gp, 52($sp) # restore $gp
1034 lw $ra, 60($sp) # restore $ra
jeffhao7fbee072012-08-24 17:56:54 -07001035 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001036 addiu $sp, $sp, 64 # pop frame
1037 .cfi_adjust_cfa_offset -64
jeffhao7fbee072012-08-24 17:56:54 -07001038 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001039 nop
10401:
1041 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001042END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001043
Ian Rogers468532e2013-08-05 10:56:33 -07001044 .extern artQuickResolutionTrampoline
1045ENTRY art_quick_resolution_trampoline
Ian Rogers7db619b2013-01-16 18:35:48 -08001046 GENERATE_GLOBAL_POINTER
1047 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001048 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001049 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001050 move $a3, $sp # pass $sp
1051 lw $gp, 52($sp) # restore $gp
1052 lw $ra, 60($sp) # restore $ra
1053 beqz $v0, 1f
1054 lw $a0, 0($sp) # load resolved method to $a0
1055 lw $a1, 4($sp) # restore non-callee save $a1
1056 lw $a2, 8($sp) # restore non-callee save $a2
1057 lw $a3, 12($sp) # restore non-callee save $a3
Ian Rogers65d1b222013-09-27 10:59:41 -07001058 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001059 jr $v0 # tail call to method
10601:
1061 addiu $sp, $sp, 64 # pop frame
1062 .cfi_adjust_cfa_offset -64
1063 DELIVER_PENDING_EXCEPTION
1064END art_quick_resolution_trampoline
1065
1066 .extern artQuickToInterpreterBridge
1067ENTRY art_quick_to_interpreter_bridge
1068 GENERATE_GLOBAL_POINTER
1069 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001070 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001071 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001072 move $a2, $sp # pass $sp
1073 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001074 lw $gp, 52($sp) # restore $gp
1075 lw $ra, 60($sp) # restore $ra
Ian Rogers7db619b2013-01-16 18:35:48 -08001076 bnez $t0, 1f
Jeff Hao1f3bc2f2013-04-30 15:17:19 -07001077 addiu $sp, $sp, 64 # pop frame
1078 .cfi_adjust_cfa_offset -64
Ian Rogers7db619b2013-01-16 18:35:48 -08001079 jr $ra
1080 nop
10811:
1082 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001083END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001084
buzbee5bc5a7b2012-03-07 15:52:59 -08001085 /*
jeffhao725a9572012-11-13 18:20:12 -08001086 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001087 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001088 .extern artInstrumentationMethodEntryFromCode
1089 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001090ENTRY art_quick_instrumentation_entry
jeffhao12051ea2013-01-10 11:24:31 -08001091 GENERATE_GLOBAL_POINTER
Ian Rogers62d6c772013-02-27 08:32:07 -08001092 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001093 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001094 addiu $sp, $sp, -32 # space for args, pad (3 words), arguments (5 words)
1095 .cfi_adjust_cfa_offset 32
1096 sw $a0, 28($sp) # save arg0
1097 sw $ra, 16($sp) # pass $ra
1098 move $a3, $t0 # pass $sp
1099 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, SP, LR)
1100 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001101 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001102 lw $a0, 28($sp) # restore arg0
1103 addiu $sp, $sp, 32 # remove args
1104 .cfi_adjust_cfa_offset -32
1105 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001106 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001107 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001108END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001109 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001110 .global art_quick_instrumentation_exit
1111art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001112 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001113 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
1114 GENERATE_GLOBAL_POINTER
1115 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001116 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
1117 addiu $sp, $sp, -48 # save return values and set up args
1118 .cfi_adjust_cfa_offset 48
1119 sw $v0, 32($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001120 .cfi_rel_offset 2, 0
Ian Rogers62d6c772013-02-27 08:32:07 -08001121 sw $v1, 36($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001122 .cfi_rel_offset 3, 4
Ian Rogers62d6c772013-02-27 08:32:07 -08001123 s.s $f0, 40($sp)
1124 s.s $f1, 44($sp)
1125 s.s $f0, 16($sp) # pass fpr result
1126 s.s $f1, 20($sp)
1127 move $a2, $v0 # pass gpr result
1128 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001129 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001130 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001131 move $a0, rSELF # pass Thread::Current
1132 move $t0, $v0 # set aside returned link register
1133 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001134 lw $v0, 32($sp) # restore return values
1135 lw $v1, 36($sp)
1136 l.s $f0, 40($sp)
1137 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001138 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001139 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1140 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001141END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001142
jeffhao12051ea2013-01-10 11:24:31 -08001143 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001144 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1145 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001146 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001147 .extern artDeoptimize
1148 .extern artEnterInterpreterFromDeoptimize
1149ENTRY art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001150 GENERATE_GLOBAL_POINTER
Jeff Hao14dd5a82013-04-11 10:23:36 -07001151 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001152 move $a0, rSELF # pass Thread::current
1153 jal artDeoptimize # artDeoptimize(Thread*, SP)
jeffhao12051ea2013-01-10 11:24:31 -08001154 # Returns caller method's frame size.
Ian Rogers62d6c772013-02-27 08:32:07 -08001155 move $a1, $sp # pass $sp
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001156END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001157
buzbee5bc5a7b2012-03-07 15:52:59 -08001158 /*
1159 * Long integer shift. This is different from the generic 32/64-bit
1160 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1161 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1162 * 6 bits.
1163 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001164 * $a0: low word
1165 * $a1: high word
1166 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001167 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001168ENTRY art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001169 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001170 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1171 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1172 srl $a0, 1
1173 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1174 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1175 or $v1, $a0 # rhi<- rhi | alo
1176 andi $a2, 0x20 # shift< shift & 0x20
1177 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1178 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001179 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001180END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001181
buzbee5bc5a7b2012-03-07 15:52:59 -08001182 /*
1183 * Long integer shift. This is different from the generic 32/64-bit
1184 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1185 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1186 * 6 bits.
1187 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001188 * $a0: low word
1189 * $a1: high word
1190 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001191 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001192 .global art_quick_shr_long
1193ENTRY art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001194 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1195 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1196 sra $a3, $a1, 31 # $a3<- sign(ah)
1197 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1198 sll $a1, 1
1199 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1200 or $v0, $a1 # rlo<- rlo | ahi
1201 andi $a2, 0x20 # shift & 0x20
1202 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1203 jr $ra
1204 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001205END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001206
buzbee5bc5a7b2012-03-07 15:52:59 -08001207 /*
1208 * Long integer shift. This is different from the generic 32/64-bit
1209 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1210 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1211 * 6 bits.
1212 * On entry:
1213 * r0: low word
1214 * r1: high word
1215 * r2: shift count
1216 */
1217 /* ushr-long vAA, vBB, vCC */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001218 .global art_quick_ushr_long
1219ENTRY art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001220 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001221 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001222 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1223 sll $a1, 1
1224 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1225 or $v0, $a1 # rlo<- rlo | ahi
1226 andi $a2, 0x20 # shift & 0x20
1227 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1228 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001229 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001230END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001231
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001232ENTRY art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001233 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001234 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001235END art_quick_indexof
jeffhao7fbee072012-08-24 17:56:54 -07001236
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001237ENTRY art_quick_string_compareto
jeffhao7fbee072012-08-24 17:56:54 -07001238 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001239 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001240END art_quick_string_compareto