blob: b49d5a54a6a718e65bb69ee3640bf90a7ea08cb1 [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
buzbee5bc5a7b2012-03-07 15:52:59 -080017#include "asm_support.h"
18
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
Ian Rogers57b86d42012-03-27 16:05:41 -070027 /* Cache alignment for function entry */
28.macro ALIGN_FUNCTION_ENTRY
29 .balign 16
30.endm
31
jeffhao12051ea2013-01-10 11:24:31 -080032 /* Generates $gp for function calls */
33.macro GENERATE_GLOBAL_POINTER
34 .cpload $t9
35.endm
36
buzbee5bc5a7b2012-03-07 15:52:59 -080037 /*
38 * Macro that sets up the callee save frame to conform with
39 * Runtime::CreateCalleeSaveMethod(kSaveAll)
jeffhaofa147e22012-10-12 17:03:32 -070040 * callee-save: $s0-$s8 + $ra, 10 total + 4 words
buzbee5bc5a7b2012-03-07 15:52:59 -080041 */
Ian Rogers57b86d42012-03-27 16:05:41 -070042.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -070043 addiu $sp, $sp, -64
44 sw $ra, 60($sp)
45 sw $s8, 56($sp)
46 sw $s7, 52($sp)
47 sw $s6, 48($sp)
48 sw $s5, 44($sp)
49 sw $s4, 40($sp)
50 sw $s3, 36($sp)
51 sw $s2, 32($sp)
52 sw $s1, 28($sp)
53 sw $s0, 24($sp)
54 # 2 words for alignment, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080055.endm
56
57 /*
58 * Macro that sets up the callee save frame to conform with
59 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
60 * Does not include rSUSPEND or rSELF
jeffhaofc6a30e2012-10-18 18:24:15 -070061 * callee-save: $s2-$s8 + $ra, 8 total + 4 words + extra args + gp
buzbee5bc5a7b2012-03-07 15:52:59 -080062 */
63.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070064 addiu $sp, $sp, -64
65 sw $ra, 60($sp)
66 sw $s8, 56($sp)
67 sw $s7, 52($sp)
68 sw $s6, 48($sp)
69 sw $s5, 44($sp)
70 sw $s4, 40($sp)
71 sw $s3, 36($sp)
72 sw $s2, 32($sp)
jeffhaofc6a30e2012-10-18 18:24:15 -070073 sw $gp, 28($sp)
74 # 3 words for alignment and extra args, 4 open words for args $a0-$a3, bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080075.endm
76
77.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhaofc6a30e2012-10-18 18:24:15 -070078 lw $gp, 28($sp)
jeffhao4eb68ed2012-10-17 16:41:07 -070079 lw $ra, 60($sp)
80 addiu $sp, $sp, 64
buzbee5bc5a7b2012-03-07 15:52:59 -080081.endm
82
83.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -070084 lw $ra, 60($sp)
jeffhao7fbee072012-08-24 17:56:54 -070085 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -070086 addiu $sp, $sp, 64
buzbee5bc5a7b2012-03-07 15:52:59 -080087.endm
88
89 /*
90 * Macro that sets up the callee save frame to conform with
91 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
jeffhaofa147e22012-10-12 17:03:32 -070092 * $a1-$a3, $s2-$s8, $ra, 11 total + Method*
buzbee5bc5a7b2012-03-07 15:52:59 -080093 */
94.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao07030602012-09-26 14:33:14 -070095 addiu $sp, $sp, -48
jeffhao7fbee072012-08-24 17:56:54 -070096 sw $ra, 44($sp)
97 sw $s8, 40($sp)
98 sw $s7, 36($sp)
99 sw $s6, 32($sp)
100 sw $s5, 28($sp)
101 sw $s4, 24($sp)
102 sw $s3, 20($sp)
103 sw $s2, 16($sp)
104 sw $a3, 12($sp)
105 sw $a2, 8($sp)
106 sw $a1, 4($sp)
jeffhaofa147e22012-10-12 17:03:32 -0700107 # bottom will hold Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800108.endm
109
110.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700111 lw $ra, 44($sp) # restore $ra
112 lw $a1, 4($sp) # restore non-callee save $a1
113 lw $a2, 8($sp) # restore non-callee save $a2
114 lw $a3, 12($sp) # restore non-callee save $a3
115 addiu $sp, $sp, 48 # strip frame
buzbee5bc5a7b2012-03-07 15:52:59 -0800116.endm
117
118 /*
119 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
120 * exception is Thread::Current()->exception_
121 */
122.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700123 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
124 move $a0, rSELF # pass Thread::Current
125 la $t9, artDeliverPendingExceptionFromCode
126 jr $t9 # artDeliverPendingExceptionFromCode(Thread*, $sp)
127 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800128.endm
129
130.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700131 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
buzbee5bc5a7b2012-03-07 15:52:59 -0800132 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700133 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800134 nop
jeffhao7fbee072012-08-24 17:56:54 -0700135 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800136 nop
1371:
138 DELIVER_PENDING_EXCEPTION
139.endm
140
141.macro RETURN_IF_ZERO
142 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700143 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800144 nop
jeffhao7fbee072012-08-24 17:56:54 -0700145 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800146 nop
1471:
148 DELIVER_PENDING_EXCEPTION
149.endm
150
151.macro RETURN_IF_NONZERO
152 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700153 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800154 nop
jeffhao7fbee072012-08-24 17:56:54 -0700155 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800156 nop
1571:
158 DELIVER_PENDING_EXCEPTION
159.endm
160
161 .global art_update_debugger
162 .extern artUpdateDebuggerFromCode
163 /*
jeffhao7fbee072012-08-24 17:56:54 -0700164 * On entry, $a0 and $a1 must be preserved, $a2 is dex PC
buzbee5bc5a7b2012-03-07 15:52:59 -0800165 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700166 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800167art_update_debugger:
jeffhao12051ea2013-01-10 11:24:31 -0800168 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700169 move $a3, $a0 # stash away $a0 so that it's saved as if it were an argument
buzbee5bc5a7b2012-03-07 15:52:59 -0800170 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700171 move $a0, $a2 # arg0 is dex PC
172 move $a1, rSELF # arg1 is Thread*
173 move $a2, $sp # arg2 is $sp
174 jal artUpdateDebuggerFromCode # artUpdateDebuggerFromCode(int32_t, Thread*, Method**)
jeffhao12051ea2013-01-10 11:24:31 -0800175 nop
buzbee5bc5a7b2012-03-07 15:52:59 -0800176 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700177 jr $ra
178 move $a0, $a3 # restore original $a0
buzbee5bc5a7b2012-03-07 15:52:59 -0800179
180 .global art_do_long_jump
181 /*
jeffhao7fbee072012-08-24 17:56:54 -0700182 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800183 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
184 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700185 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800186art_do_long_jump:
jeffhao7fbee072012-08-24 17:56:54 -0700187 l.s $f0, 0($a1)
188 l.s $f1, 4($a1)
189 l.s $f2, 8($a1)
190 l.s $f3, 12($a1)
191 l.s $f4, 16($a1)
192 l.s $f5, 20($a1)
193 l.s $f6, 24($a1)
194 l.s $f7, 28($a1)
195 l.s $f8, 32($a1)
196 l.s $f9, 36($a1)
197 l.s $f10, 40($a1)
198 l.s $f11, 44($a1)
199 l.s $f12, 48($a1)
200 l.s $f13, 52($a1)
201 l.s $f14, 56($a1)
202 l.s $f15, 60($a1)
203 l.s $f16, 64($a1)
204 l.s $f17, 68($a1)
205 l.s $f18, 72($a1)
206 l.s $f19, 76($a1)
207 l.s $f20, 80($a1)
208 l.s $f21, 84($a1)
209 l.s $f22, 88($a1)
210 l.s $f23, 92($a1)
211 l.s $f24, 96($a1)
212 l.s $f25, 100($a1)
213 l.s $f26, 104($a1)
214 l.s $f27, 108($a1)
215 l.s $f28, 112($a1)
216 l.s $f29, 116($a1)
217 l.s $f30, 120($a1)
218 l.s $f31, 124($a1)
219 lw $at, 4($a0)
220 lw $v0, 8($a0)
221 lw $v1, 12($a0)
222 lw $a1, 20($a0)
223 lw $a2, 24($a0)
224 lw $a3, 28($a0)
225 lw $t0, 32($a0)
226 lw $t1, 36($a0)
227 lw $t2, 40($a0)
228 lw $t3, 44($a0)
229 lw $t4, 48($a0)
230 lw $t5, 52($a0)
231 lw $t6, 56($a0)
232 lw $t7, 60($a0)
233 lw $s0, 64($a0)
234 lw $s1, 68($a0)
235 lw $s2, 72($a0)
236 lw $s3, 76($a0)
237 lw $s4, 80($a0)
238 lw $s5, 84($a0)
239 lw $s6, 88($a0)
240 lw $s7, 92($a0)
241 lw $t8, 96($a0)
242 lw $t9, 100($a0)
243 lw $k0, 104($a0)
244 lw $k1, 108($a0)
245 lw $gp, 112($a0)
246 lw $sp, 116($a0)
247 lw $fp, 120($a0)
248 lw $ra, 124($a0)
249 lw $a0, 16($a0)
250 move $v0, $zero # clear result registers r0 and r1
251 jr $ra # do long jump
252 move $v1, $zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800253
254 .global art_deliver_exception_from_code
255 /*
256 * Called by managed code, saves most registers (forms basis of long jump context) and passes
257 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
258 * the bottom of the thread. On entry r0 holds Throwable*
259 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700260 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800261art_deliver_exception_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800262 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700263 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700264 move $a1, rSELF # pass Thread::Current
265 la $t9, artDeliverExceptionFromCode
266 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp)
267 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800268
269 .global art_throw_null_pointer_exception_from_code
270 .extern artThrowNullPointerExceptionFromCode
271 /*
272 * Called by managed code to create and deliver a NullPointerException
273 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700274 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800275art_throw_null_pointer_exception_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800276 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700277 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700278 move $a0, rSELF # pass Thread::Current
279 la $t9, artThrowNullPointerExceptionFromCode
280 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp)
281 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800282
283 .global art_throw_div_zero_from_code
284 .extern artThrowDivZeroFromCode
285 /*
286 * Called by managed code to create and deliver an ArithmeticException
287 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700288 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800289art_throw_div_zero_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800290 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700291 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700292 move $a0, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700293 la $t9, artThrowDivZeroFromCode
294 jr $t9 # artThrowDivZeroFromCode(Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700295 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800296
297 .global art_throw_array_bounds_from_code
298 .extern artThrowArrayBoundsFromCode
299 /*
300 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
301 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700302 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800303art_throw_array_bounds_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800304 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700305 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700306 move $a2, rSELF # pass Thread::Current
307 la $t9, artThrowArrayBoundsFromCode
308 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp)
309 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800310
311 .global art_throw_stack_overflow_from_code
312 .extern artThrowStackOverflowFromCode
Ian Rogers57b86d42012-03-27 16:05:41 -0700313 /*
314 * Called by managed code to create and deliver a StackOverflowError.
315 */
316 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800317art_throw_stack_overflow_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800318 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700319 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700320 move $a0, rSELF # pass Thread::Current
321 la $t9, artThrowStackOverflowFromCode
322 jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp)
323 move $a1, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800324
325 .global art_throw_no_such_method_from_code
326 .extern artThrowNoSuchMethodFromCode
Ian Rogers57b86d42012-03-27 16:05:41 -0700327 /*
328 * Called by managed code to create and deliver a NoSuchMethodError.
329 */
330 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800331art_throw_no_such_method_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800332 GENERATE_GLOBAL_POINTER
Ian Rogers57b86d42012-03-27 16:05:41 -0700333 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700334 move $a1, rSELF # pass Thread::Current
335 la $t9, artThrowNoSuchMethodFromCode
336 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp)
337 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800338
buzbee5bc5a7b2012-03-07 15:52:59 -0800339 /*
340 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700341 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800342 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
343 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700344 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800345 *
jeffhao7fbee072012-08-24 17:56:54 -0700346 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
347 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800348 *
jeffhaofa147e22012-10-12 17:03:32 -0700349 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800350 * thread and we branch to another stub to deliver it.
351 *
352 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
353 * pointing back to the original caller.
354 */
355.macro INVOKE_TRAMPOLINE c_name, cxx_name
356 .global \c_name
357 .extern \cxx_name
358\c_name:
jeffhao12051ea2013-01-10 11:24:31 -0800359 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700360 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
361 lw $a2, 48($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700362 move $t0, $sp # save $sp
363 addiu $sp, $sp, -16 # make space for extra args
jeffhao7fbee072012-08-24 17:56:54 -0700364 move $a3, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700365 sw $gp, 12($sp) # save $gp
jeffhao7fbee072012-08-24 17:56:54 -0700366 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700367 sw $t0, 16($sp) # pass $sp
jeffhao8161c032012-10-31 15:50:00 -0700368 lw $gp, 12($sp) # restore $gp
jeffhaofa147e22012-10-12 17:03:32 -0700369 addiu $sp, $sp, 16 # release out args
370 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700371 move $t9, $v1 # save $v0->code_
buzbee5bc5a7b2012-03-07 15:52:59 -0800372 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700373 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800374 nop
jeffhao30a33172012-10-22 18:16:22 -0700375 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800376 nop
3771:
378 DELIVER_PENDING_EXCEPTION
379.endm
380
381INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline
382INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
383
384INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
385INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
386INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
387INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
388
389 .global art_work_around_app_jni_bugs
390 .extern artWorkAroundAppJniBugs
391 /*
392 * Entry point of native methods when JNI bug compatibility is enabled.
393 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700394 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800395art_work_around_app_jni_bugs:
jeffhao12051ea2013-01-10 11:24:31 -0800396 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700397 # save registers that may contain arguments and LR that will be crushed by a call
398 addiu $sp, $sp, -32
jeffhaofa147e22012-10-12 17:03:32 -0700399 sw $ra, 28($sp)
400 sw $a3, 24($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700401 sw $a2, 20($sp)
jeffhaofa147e22012-10-12 17:03:32 -0700402 sw $a1, 16($sp)
403 sw $a0, 12($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700404 move $a0, rSELF # pass Thread::Current
405 jal artWorkAroundAppJniBugs # (Thread*, $sp)
406 move $a1, $sp # pass $sp
jeffhao30a33172012-10-22 18:16:22 -0700407 move $t9, $v0 # save target address
jeffhaofa147e22012-10-12 17:03:32 -0700408 lw $a0, 12($sp)
409 lw $a1, 16($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700410 lw $a2, 20($sp)
jeffhaofa147e22012-10-12 17:03:32 -0700411 lw $a3, 24($sp)
412 lw $ra, 28($sp)
jeffhao30a33172012-10-22 18:16:22 -0700413 jr $t9 # tail call into JNI routine
jeffhao7fbee072012-08-24 17:56:54 -0700414 addiu $sp, $sp, 32
buzbee5bc5a7b2012-03-07 15:52:59 -0800415
416 .global art_handle_fill_data_from_code
417 .extern artHandleFillArrayDataFromCode
418 /*
419 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
420 * failure.
421 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700422 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800423art_handle_fill_data_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800424 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700425 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
426 move $a2, rSELF # pass Thread::Current
427 jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp)
428 move $a3, $sp # pass $sp
jeffhaofc6a30e2012-10-18 18:24:15 -0700429 RETURN_IF_ZERO
buzbee5bc5a7b2012-03-07 15:52:59 -0800430
431 .global art_lock_object_from_code
432 .extern artLockObjectFromCode
433 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700434 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800435 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700436 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800437art_lock_object_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800438 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700439 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
440 move $a1, rSELF # pass Thread::Current
441 jal artLockObjectFromCode # (Object* obj, Thread*, $sp)
442 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800443 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
444
445 .global art_unlock_object_from_code
446 .extern artUnlockObjectFromCode
447 /*
448 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
449 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700450 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800451art_unlock_object_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800452 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700453 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
454 move $a1, rSELF # pass Thread::Current
455 jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp)
456 move $a2, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800457 RETURN_IF_ZERO
458
459 .global art_check_cast_from_code
460 .extern artCheckCastFromCode
461 /*
462 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
463 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700464 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800465art_check_cast_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800466 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700467 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
468 move $a2, rSELF # pass Thread::Current
469 jal artCheckCastFromCode # (Class* a, Class* b, Thread*, $sp)
470 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800471 RETURN_IF_ZERO
472
473 .global art_can_put_array_element_from_code
474 .extern artCanPutArrayElementFromCode
475 /*
476 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
477 * failure.
478 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700479 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800480art_can_put_array_element_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800481 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700482 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
483 move $a2, rSELF # pass Thread::Current
484 jal artCanPutArrayElementFromCode # (Object* element, Class* array_class, Thread*, $sp)
485 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800486 RETURN_IF_ZERO
487
488 .global art_initialize_static_storage_from_code
489 .extern artInitializeStaticStorageFromCode
490 /*
491 * Entry from managed code when uninitialized static storage, this stub will run the class
492 * initializer and deliver the exception on error. On success the static storage base is
493 * returned.
494 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700495 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800496art_initialize_static_storage_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800497 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700498 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
499 move $a2, rSELF # pass Thread::Current
500 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800501 jal artInitializeStaticStorageFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700502 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800503 RETURN_IF_NONZERO
504
505 .global art_initialize_type_from_code
506 .extern artInitializeTypeFromCode
507 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700508 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800509 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700510 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800511art_initialize_type_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800512 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700513 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
514 move $a2, rSELF # pass Thread::Current
515 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800516 jal artInitializeTypeFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700517 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800518 RETURN_IF_NONZERO
519
520 .global art_initialize_type_and_verify_access_from_code
521 .extern artInitializeTypeAndVerifyAccessFromCode
522 /*
523 * 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 -0700524 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800525 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700526 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800527art_initialize_type_and_verify_access_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800528 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700529 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
530 move $a2, rSELF # pass Thread::Current
531 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800532 jal artInitializeTypeAndVerifyAccessFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700533 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800534 RETURN_IF_NONZERO
535
536 .global art_get32_static_from_code
537 .extern artGet32StaticFromCode
538 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700539 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800540 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700541 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800542art_get32_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800543 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700544 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700545 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700546 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700547 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700548 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800549 RETURN_IF_NO_EXCEPTION
550
551 .global art_get64_static_from_code
552 .extern artGet64StaticFromCode
553 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700554 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800555 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700556 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800557art_get64_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800558 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700559 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700560 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700561 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700562 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700563 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 RETURN_IF_NO_EXCEPTION
565
566 .global art_get_obj_static_from_code
567 .extern artGetObjStaticFromCode
568 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700569 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800570 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700571 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800572art_get_obj_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800573 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700574 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700575 lw $a1, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700576 move $a2, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700577 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp)
jeffhao7fbee072012-08-24 17:56:54 -0700578 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800579 RETURN_IF_NO_EXCEPTION
580
581 .global art_get32_instance_from_code
582 .extern artGet32InstanceFromCode
583 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700584 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800585 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700586 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800587art_get32_instance_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800588 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700589 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700590 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700591 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700592 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700593 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800594 RETURN_IF_NO_EXCEPTION
595
596 .global art_get64_instance_from_code
597 .extern artGet64InstanceFromCode
598 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700599 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800600 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700601 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800602art_get64_instance_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800603 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700604 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700605 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700606 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700607 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700608 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800609 RETURN_IF_NO_EXCEPTION
610
611 .global art_get_obj_instance_from_code
612 .extern artGetObjInstanceFromCode
613 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700614 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800615 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700616 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800617art_get_obj_instance_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800618 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700619 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700620 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700621 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700622 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700623 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800624 RETURN_IF_NO_EXCEPTION
625
626 .global art_set32_static_from_code
627 .extern artSet32StaticFromCode
628 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700629 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800630 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700631 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800632art_set32_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800633 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700634 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700635 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700636 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700637 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700638 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800639 RETURN_IF_ZERO
640
641 .global art_set64_static_from_code
642 .extern artSet32StaticFromCode
643 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700644 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800645 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700646 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800647art_set64_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800648 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700649 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700650 lw $a1, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700651 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700652 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700653 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800654 RETURN_IF_ZERO
655
656 .global art_set_obj_static_from_code
657 .extern artSetObjStaticFromCode
658 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700659 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800660 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700661 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800662art_set_obj_static_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800663 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700664 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700665 lw $a2, 64($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700666 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700667 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700668 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800669 RETURN_IF_ZERO
670
671 .global art_set32_instance_from_code
672 .extern artSet32InstanceFromCode
673 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700674 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800675 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700676 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800677art_set32_instance_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800678 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700679 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao4eb68ed2012-10-17 16:41:07 -0700680 lw $a3, 64($sp) # pass referrer's Method*
jeffhaofa147e22012-10-12 17:03:32 -0700681 sw rSELF, 16($sp) # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700682 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700683 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800684 RETURN_IF_ZERO
685
686 .global art_set64_instance_from_code
687 .extern artSet32InstanceFromCode
688 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700689 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800690 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700691 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800692art_set64_instance_from_code:
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
jeffhaofa147e22012-10-12 17:03:32 -0700695 sw rSELF, 16($sp) # pass Thread::Current
696 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700697 sw $sp, 20($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800698 RETURN_IF_ZERO
699
700 .global art_set_obj_instance_from_code
701 .extern artSetObjInstanceFromCode
702 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700703 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800704 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700705 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800706art_set_obj_instance_from_code:
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
711 jal artSetObjInstanceFromCode # (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
714
715 .global art_resolve_string_from_code
716 .extern artResolveStringFromCode
717 /*
718 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
719 * exception on error. On success the String is returned. R0 holds the referring method,
720 * R1 holds the string index. The fast path check for hit in strings cache has already been
721 * performed.
722 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700723 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800724art_resolve_string_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800725 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700726 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
727 move $a2, rSELF # pass Thread::Current
728 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 jal artResolveStringFromCode
jeffhao7fbee072012-08-24 17:56:54 -0700730 move $a3, $sp # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700731 RETURN_IF_NONZERO
buzbee5bc5a7b2012-03-07 15:52:59 -0800732
733 .global art_alloc_object_from_code
734 .extern artAllocObjectFromCode
735 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700736 * Called by managed code to allocate an object.
buzbee5bc5a7b2012-03-07 15:52:59 -0800737 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700738 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800739art_alloc_object_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800740 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700741 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
742 move $a2, rSELF # pass Thread::Current
743 jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp)
744 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800745 RETURN_IF_NONZERO
746
747 .global art_alloc_object_from_code_with_access_check
748 .extern artAllocObjectFromCodeWithAccessCheck
749 /*
750 * Called by managed code to allocate an object when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700751 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800752 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700753 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800754art_alloc_object_from_code_with_access_check:
jeffhao12051ea2013-01-10 11:24:31 -0800755 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700756 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
757 move $a2, rSELF # pass Thread::Current
758 jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp)
759 move $a3, $sp # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800760 RETURN_IF_NONZERO
761
762 .global art_alloc_array_from_code
763 .extern artAllocArrayFromCode
764 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700765 * Called by managed code to allocate an array.
buzbee5bc5a7b2012-03-07 15:52:59 -0800766 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700767 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800768art_alloc_array_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800769 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700770 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
771 move $a3, rSELF # pass Thread::Current
772 # artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800773 jal artAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700774 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800775 RETURN_IF_NONZERO
776
777 .global art_alloc_array_from_code_with_access_check
778 .extern artAllocArrayFromCodeWithAccessCheck
779 /*
780 * Called by managed code to allocate an array when the caller doesn't know whether it has
Ian Rogers57b86d42012-03-27 16:05:41 -0700781 * access to the created type.
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700783 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800784art_alloc_array_from_code_with_access_check:
jeffhao12051ea2013-01-10 11:24:31 -0800785 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700786 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
787 move $a3, rSELF # pass Thread::Current
788 # artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800789 jal artAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700790 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800791 RETURN_IF_NONZERO
792
793 .global art_check_and_alloc_array_from_code
794 .extern artCheckAndAllocArrayFromCode
795 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700796 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800797 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700798 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800799art_check_and_alloc_array_from_code:
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
802 move $a3, rSELF # pass Thread::Current
803 # artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800804 jal artCheckAndAllocArrayFromCode
jeffhao4eb68ed2012-10-17 16:41:07 -0700805 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800806 RETURN_IF_NONZERO
807
808 .global art_check_and_alloc_array_from_code_with_access_check
809 .extern artCheckAndAllocArrayFromCodeWithAccessCheck
810 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700811 * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
buzbee5bc5a7b2012-03-07 15:52:59 -0800812 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700813 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800814art_check_and_alloc_array_from_code_with_access_check:
jeffhao12051ea2013-01-10 11:24:31 -0800815 GENERATE_GLOBAL_POINTER
jeffhao7fbee072012-08-24 17:56:54 -0700816 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhaofa147e22012-10-12 17:03:32 -0700817 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700818 # artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , $sp)
buzbee5bc5a7b2012-03-07 15:52:59 -0800819 jal artCheckAndAllocArrayFromCodeWithAccessCheck
jeffhao4eb68ed2012-10-17 16:41:07 -0700820 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800821 RETURN_IF_NONZERO
822
823 .global art_test_suspend
824 .extern artTestSuspendFromCode
825 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700826 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -0800827 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700828 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800829art_test_suspend:
jeffhao12051ea2013-01-10 11:24:31 -0800830 GENERATE_GLOBAL_POINTER
Ian Rogers474b6da2012-09-25 00:20:38 -0700831 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -0700832 bnez $a0, 1f
833 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
834 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800835 nop
8361:
jeffhao7fbee072012-08-24 17:56:54 -0700837 move $a0, rSELF
838 SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
839 jal artTestSuspendFromCode # (Thread*, $sp)
840 move $a1, $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800841 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
842
843 .global art_proxy_invoke_handler
844 .extern artProxyInvokeHandler
845 /*
846 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -0700847 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -0800848 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700849 ALIGN_FUNCTION_ENTRY
buzbee5bc5a7b2012-03-07 15:52:59 -0800850art_proxy_invoke_handler:
jeffhao12051ea2013-01-10 11:24:31 -0800851 GENERATE_GLOBAL_POINTER
buzbee5bc5a7b2012-03-07 15:52:59 -0800852 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700853 sw $a0, 0($sp) # place proxy method at bottom of frame
854 move $a2, rSELF # pass Thread::Current
Ian Rogers7db619b2013-01-16 18:35:48 -0800855 jal artProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800856 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -0700857 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
jeffhao7fbee072012-08-24 17:56:54 -0700858 lw $ra, 44($sp) # restore $ra
jeffhao7fbee072012-08-24 17:56:54 -0700859 bnez $t0, 1f
860 addiu $sp, $sp, 48 # pop frame
861 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800862 nop
8631:
864 DELIVER_PENDING_EXCEPTION
865
Ian Rogers7db619b2013-01-16 18:35:48 -0800866 .global art_interpreter_entry
867 .extern artInterpreterEntry
868 ALIGN_FUNCTION_ENTRY
869art_interpreter_entry:
870 GENERATE_GLOBAL_POINTER
871 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
872 sw $a0, 0($sp) # place proxy method at bottom of frame
873 move $a1, rSELF # pass Thread::Current
874 jal artInterpreterEntry # (Method* method, Thread*, SP)
875 move $a2, $sp # pass $sp
876 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
877 lw $ra, 44($sp) # restore $ra
878 bnez $t0, 1f
879 addiu $sp, $sp, 48 # pop frame
880 jr $ra
881 nop
8821:
883 DELIVER_PENDING_EXCEPTION
884
jeffhao725a9572012-11-13 18:20:12 -0800885 .global art_instrumentation_entry_from_code
886 .global art_instrumentation_exit_from_code
887 .extern artInstrumentationMethodEntryFromCode
888 .extern artInstrumentationMethodExitFromCode
buzbee5bc5a7b2012-03-07 15:52:59 -0800889 /*
jeffhao725a9572012-11-13 18:20:12 -0800890 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -0800891 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700892 ALIGN_FUNCTION_ENTRY
jeffhao725a9572012-11-13 18:20:12 -0800893art_instrumentation_entry_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800894 GENERATE_GLOBAL_POINTER
895 move $t0, $sp # remember bottom of caller's frame
896 addiu $sp, $sp, -16 # save arguments (4 words)
jeffhao7fbee072012-08-24 17:56:54 -0700897 sw $a0, 0($sp)
898 sw $a1, 4($sp)
899 sw $a2, 8($sp)
900 sw $a3, 12($sp)
jeffhao12051ea2013-01-10 11:24:31 -0800901 move $a3, $ra # pass $ra
902 move $a2, $t0 # pass $sp
903 jal artInstrumentationMethodEntryFromCode # (Method*, Thread*, SP, LR)
jeffhao7fbee072012-08-24 17:56:54 -0700904 move $a1, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -0700905 move $t9, $v0 # $t9 holds reference to code
jeffhao7fbee072012-08-24 17:56:54 -0700906 lw $a0, 0($sp)
907 lw $a1, 4($sp)
908 lw $a2, 8($sp)
909 lw $a3, 12($sp)
jeffhao8161c032012-10-31 15:50:00 -0700910 jalr $t9 # call method
jeffhao7fbee072012-08-24 17:56:54 -0700911 addiu $sp, $sp, 16
buzbee5bc5a7b2012-03-07 15:52:59 -0800912 /* intentional fallthrough */
jeffhao725a9572012-11-13 18:20:12 -0800913art_instrumentation_exit_from_code:
jeffhao12051ea2013-01-10 11:24:31 -0800914 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
915 GENERATE_GLOBAL_POINTER
916 move $t0, $sp # remember bottom of caller's frame
917 addiu $sp, $sp, -16 # save return values
jeffhao7fbee072012-08-24 17:56:54 -0700918 sw $v0, 0($sp)
jeffhao7fbee072012-08-24 17:56:54 -0700919 sw $v1, 4($sp)
jeffhao12051ea2013-01-10 11:24:31 -0800920 move $a1, $t0 # pass $sp
921 jal artInstrumentationMethodExitFromCode # (Thread*, SP)
922 move $a0, rSELF # pass Thread::Current
923 move $t0, $v0 # set aside returned link register
924 move $ra, $v1 # set link register for deoptimization
jeffhao7fbee072012-08-24 17:56:54 -0700925 lw $v0, 0($sp)
926 lw $v1, 4($sp)
jeffhao12051ea2013-01-10 11:24:31 -0800927 jr $t0 # return
jeffhao7fbee072012-08-24 17:56:54 -0700928 addiu $sp, $sp, 16
buzbee5bc5a7b2012-03-07 15:52:59 -0800929
jeffhao12051ea2013-01-10 11:24:31 -0800930 .global art_deoptimize
931 .extern artDeoptimize
932 .extern artEnterInterpreterFromDeoptimize
933 /*
934 * The thread's enter interpreter flag is set and so we should transition to the interpreter
935 * rather than allow execution to continue in the frame below. There may be live results in
936 * registers depending on how complete the operation is when we safepoint - for example, a
937 * set operation may have completed while a get operation needs writing back into the vregs.
938 */
939 ALIGN_FUNCTION_ENTRY
940art_deoptimize:
941 GENERATE_GLOBAL_POINTER
942 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
943 move $a0, $v0 # pass first half of return value
944 move $a1, $v1 # pass second half of return value
945 move $a2, rSELF # pass Thread::current
946 jal artDeoptimize # artDeoptimize(return value, Thread*, SP)
947 # Returns caller method's frame size.
948 move $a3, $sp # pass $sp
949 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
950 beqz $v0, 1f # Return if caller was upcall.
951 add $t9, $sp, $v0 # $t9 == bottom of caller's frame.
952 lw $ra, -4($t9) # Restore $ra.
953 move $sp, $t9 # Remove frame.
954 SETUP_REF_ONLY_CALLEE_SAVE_FRAME
955 jal artEnterInterpreterFromDeoptimize # Enter interpreter, callee-save ends stack fragment.
956 nop
957 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
9581:
959 jr $ra # Return to caller.
960 nop
961
buzbee5bc5a7b2012-03-07 15:52:59 -0800962 .global art_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -0800963 /*
964 * Long integer shift. This is different from the generic 32/64-bit
965 * binary operations because vAA/vBB are 64-bit but vCC (the shift
966 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
967 * 6 bits.
968 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -0700969 * $a0: low word
970 * $a1: high word
971 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -0800972 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700973 ALIGN_FUNCTION_ENTRY
974art_shl_long:
buzbee5bc5a7b2012-03-07 15:52:59 -0800975 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -0700976 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
977 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
978 srl $a0, 1
979 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
980 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
981 or $v1, $a0 # rhi<- rhi | alo
982 andi $a2, 0x20 # shift< shift & 0x20
983 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
984 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -0700985 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
buzbee5bc5a7b2012-03-07 15:52:59 -0800986
buzbee5bc5a7b2012-03-07 15:52:59 -0800987 .global art_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -0800988 /*
989 * Long integer shift. This is different from the generic 32/64-bit
990 * binary operations because vAA/vBB are 64-bit but vCC (the shift
991 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
992 * 6 bits.
993 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -0700994 * $a0: low word
995 * $a1: high word
996 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -0800997 */
Ian Rogers57b86d42012-03-27 16:05:41 -0700998 ALIGN_FUNCTION_ENTRY
999art_shr_long:
jeffhao7fbee072012-08-24 17:56:54 -07001000 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1001 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1002 sra $a3, $a1, 31 # $a3<- sign(ah)
1003 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1004 sll $a1, 1
1005 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1006 or $v0, $a1 # rlo<- rlo | ahi
1007 andi $a2, 0x20 # shift & 0x20
1008 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1009 jr $ra
1010 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
buzbee5bc5a7b2012-03-07 15:52:59 -08001011
buzbee5bc5a7b2012-03-07 15:52:59 -08001012 .global art_ushr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001013 /*
1014 * Long integer shift. This is different from the generic 32/64-bit
1015 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1016 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1017 * 6 bits.
1018 * On entry:
1019 * r0: low word
1020 * r1: high word
1021 * r2: shift count
1022 */
1023 /* ushr-long vAA, vBB, vCC */
Ian Rogers57b86d42012-03-27 16:05:41 -07001024 ALIGN_FUNCTION_ENTRY
1025art_ushr_long:
jeffhaofc6a30e2012-10-18 18:24:15 -07001026 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001027 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001028 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1029 sll $a1, 1
1030 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1031 or $v0, $a1 # rlo<- rlo | ahi
1032 andi $a2, 0x20 # shift & 0x20
1033 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1034 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001035 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
jeffhao7fbee072012-08-24 17:56:54 -07001036
1037 .global art_indexof
1038 ALIGN_FUNCTION_ENTRY
1039art_indexof:
1040 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001041 nop
jeffhao7fbee072012-08-24 17:56:54 -07001042
1043 .global art_string_compareto
1044 ALIGN_FUNCTION_ENTRY
1045art_string_compareto:
1046 jr $ra
jeffhao07030602012-09-26 14:33:14 -07001047 nop