blob: aff2da755c8d3407cdd2ad1add9eac96bb1896af [file] [log] [blame]
Elliott Hughes0f3c5532012-03-30 14:51:51 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ian Rogers7655f292013-07-29 11:07:13 -070017#include "asm_support_mips.S"
buzbee5bc5a7b2012-03-07 15:52:59 -080018
Mathieu Chartier7410f292013-11-24 13:17:35 -080019#include "arch/quick_alloc_entrypoints.S"
20
jeffhao07030602012-09-26 14:33:14 -070021 .set noreorder
buzbee5bc5a7b2012-03-07 15:52:59 -080022 .balign 4
23
24 /* Deliver the given exception */
25 .extern artDeliverExceptionFromCode
26 /* Deliver an exception pending on a thread */
jeffhao8161c032012-10-31 15:50:00 -070027 .extern artDeliverPendingExceptionFromCode
buzbee5bc5a7b2012-03-07 15:52:59 -080028
29 /*
30 * Macro that sets up the callee save frame to conform with
31 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070032 * Callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word padding + 4 open words for args
33 * Clobbers $t0 and $gp
buzbee5bc5a7b2012-03-07 15:52:59 -080034 */
Ian Rogers57b86d42012-03-27 16:05:41 -070035.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -070036 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080037 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -070038
39 // Ugly compile-time check, but we only have the preprocessor.
40#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 64)
41#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
42#endif
43
jeffhaofa147e22012-10-12 17:03:32 -070044 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080045 .cfi_rel_offset 31, 60
jeffhaofa147e22012-10-12 17:03:32 -070046 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080047 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070048 sw $gp, 52($sp)
49 .cfi_rel_offset 28, 52
50 sw $s7, 48($sp)
51 .cfi_rel_offset 23, 48
52 sw $s6, 44($sp)
53 .cfi_rel_offset 22, 44
54 sw $s5, 40($sp)
55 .cfi_rel_offset 21, 40
56 sw $s4, 36($sp)
57 .cfi_rel_offset 20, 36
58 sw $s3, 32($sp)
59 .cfi_rel_offset 19, 32
60 sw $s2, 28($sp)
61 .cfi_rel_offset 18, 28
62 sw $s1, 24($sp)
63 .cfi_rel_offset 17, 24
64 sw $s0, 20($sp)
65 .cfi_rel_offset 16, 20
66 # 1 word for alignment, 4 open words for args $a0-$a3, bottom will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070067
Douglas Leung4af77b72014-10-22 16:32:28 -070068 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
69 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070070 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -070071 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070072 sw $t0, 0($sp) # Place Method* at bottom of stack.
73 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
buzbee5bc5a7b2012-03-07 15:52:59 -080074.endm
75
76 /*
77 * Macro that sets up the callee save frame to conform with
78 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
79 * Does not include rSUSPEND or rSELF
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070080 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 3 words padding + 4 open words for args
buzbee5bc5a7b2012-03-07 15:52:59 -080081 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070082.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -070083 addiu $sp, $sp, -64
Jeff Haod4c3f7d2013-02-14 14:14:44 -080084 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -070085
86 // Ugly compile-time check, but we only have the preprocessor.
87#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 64)
88#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
89#endif
90
jeffhao4eb68ed2012-10-17 16:41:07 -070091 sw $ra, 60($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080092 .cfi_rel_offset 31, 60
jeffhao4eb68ed2012-10-17 16:41:07 -070093 sw $s8, 56($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -080094 .cfi_rel_offset 30, 56
Jeff Hao1f3bc2f2013-04-30 15:17:19 -070095 sw $gp, 52($sp)
96 .cfi_rel_offset 28, 52
97 sw $s7, 48($sp)
98 .cfi_rel_offset 23, 48
99 sw $s6, 44($sp)
100 .cfi_rel_offset 22, 44
101 sw $s5, 40($sp)
102 .cfi_rel_offset 21, 40
103 sw $s4, 36($sp)
104 .cfi_rel_offset 20, 36
105 sw $s3, 32($sp)
106 .cfi_rel_offset 19, 32
107 sw $s2, 28($sp)
108 .cfi_rel_offset 18, 28
jeffhaofc6a30e2012-10-18 18:24:15 -0700109 # 3 words for alignment and extra args, 4 open words for args $a0-$a3, bottom will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700110
Douglas Leung4af77b72014-10-22 16:32:28 -0700111 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
112 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700113 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700114 lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700115 sw $t0, 0($sp) # Place Method* at bottom of stack.
116 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
buzbee5bc5a7b2012-03-07 15:52:59 -0800117.endm
118
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700119.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao4eb68ed2012-10-17 16:41:07 -0700120 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800121 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700122 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800123 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700124 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800125 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700126 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800127 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700128 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800129 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700130 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800131 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700132 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800133 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700134 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800135 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700136 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800137 .cfi_restore 18
jeffhao4eb68ed2012-10-17 16:41:07 -0700138 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800139 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800140.endm
141
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700142.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
jeffhao4eb68ed2012-10-17 16:41:07 -0700143 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800144 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700145 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800146 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700147 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800148 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700149 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800150 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700151 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800152 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700153 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800154 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700155 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800156 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700157 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800158 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700159 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800160 .cfi_restore 18
jeffhao7fbee072012-08-24 17:56:54 -0700161 jr $ra
jeffhao4eb68ed2012-10-17 16:41:07 -0700162 addiu $sp, $sp, 64
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800163 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800164.endm
165
166 /*
167 * Macro that sets up the callee save frame to conform with
168 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700169 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800170 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700171.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700172 addiu $sp, $sp, -64
173 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700174
175 // Ugly compile-time check, but we only have the preprocessor.
176#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
177#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
178#endif
179
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700180 sw $ra, 60($sp)
181 .cfi_rel_offset 31, 60
182 sw $s8, 56($sp)
183 .cfi_rel_offset 30, 56
184 sw $gp, 52($sp)
185 .cfi_rel_offset 28, 52
186 sw $s7, 48($sp)
187 .cfi_rel_offset 23, 48
188 sw $s6, 44($sp)
189 .cfi_rel_offset 22, 44
190 sw $s5, 40($sp)
191 .cfi_rel_offset 21, 40
192 sw $s4, 36($sp)
193 .cfi_rel_offset 20, 36
194 sw $s3, 32($sp)
195 .cfi_rel_offset 19, 32
196 sw $s2, 28($sp)
197 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700198 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800199 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700200 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800201 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700202 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800203 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700204 # bottom will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700205
Douglas Leung4af77b72014-10-22 16:32:28 -0700206 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
207 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700208 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700209 lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700210 sw $t0, 0($sp) # Place Method* at bottom of stack.
211 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
buzbee5bc5a7b2012-03-07 15:52:59 -0800212.endm
213
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700214.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700215 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800216 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700217 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800218 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700219 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800220 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700221 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800222 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700223 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800224 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700225 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800226 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700227 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800228 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700229 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800230 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700231 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800232 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700233 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800234 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700235 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800236 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700237 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800238 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700239 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700240 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800241.endm
242
243 /*
244 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
245 * exception is Thread::Current()->exception_
246 */
247.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700248 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700249 la $t9, artDeliverPendingExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700250 jr $t9 # artDeliverPendingExceptionFromCode(Thread*)
251 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800252.endm
253
254.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700255 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700256 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700257 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800258 nop
jeffhao7fbee072012-08-24 17:56:54 -0700259 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800260 nop
2611:
262 DELIVER_PENDING_EXCEPTION
263.endm
264
265.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700266 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700267 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800268 nop
jeffhao7fbee072012-08-24 17:56:54 -0700269 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800270 nop
2711:
272 DELIVER_PENDING_EXCEPTION
273.endm
274
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800275.macro RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700276 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700277 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800278 nop
jeffhao7fbee072012-08-24 17:56:54 -0700279 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800280 nop
2811:
282 DELIVER_PENDING_EXCEPTION
283.endm
284
buzbee5bc5a7b2012-03-07 15:52:59 -0800285 /*
jeffhao7fbee072012-08-24 17:56:54 -0700286 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800287 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
288 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800289ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700290 l.s $f0, 0($a1)
291 l.s $f1, 4($a1)
292 l.s $f2, 8($a1)
293 l.s $f3, 12($a1)
294 l.s $f4, 16($a1)
295 l.s $f5, 20($a1)
296 l.s $f6, 24($a1)
297 l.s $f7, 28($a1)
298 l.s $f8, 32($a1)
299 l.s $f9, 36($a1)
300 l.s $f10, 40($a1)
301 l.s $f11, 44($a1)
302 l.s $f12, 48($a1)
303 l.s $f13, 52($a1)
304 l.s $f14, 56($a1)
305 l.s $f15, 60($a1)
306 l.s $f16, 64($a1)
307 l.s $f17, 68($a1)
308 l.s $f18, 72($a1)
309 l.s $f19, 76($a1)
310 l.s $f20, 80($a1)
311 l.s $f21, 84($a1)
312 l.s $f22, 88($a1)
313 l.s $f23, 92($a1)
314 l.s $f24, 96($a1)
315 l.s $f25, 100($a1)
316 l.s $f26, 104($a1)
317 l.s $f27, 108($a1)
318 l.s $f28, 112($a1)
319 l.s $f29, 116($a1)
320 l.s $f30, 120($a1)
321 l.s $f31, 124($a1)
Chris Dearman748dd952014-05-23 10:47:01 -0700322 .set push
323 .set nomacro
324 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700325 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700326 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700327 lw $v0, 8($a0)
328 lw $v1, 12($a0)
329 lw $a1, 20($a0)
330 lw $a2, 24($a0)
331 lw $a3, 28($a0)
332 lw $t0, 32($a0)
333 lw $t1, 36($a0)
334 lw $t2, 40($a0)
335 lw $t3, 44($a0)
336 lw $t4, 48($a0)
337 lw $t5, 52($a0)
338 lw $t6, 56($a0)
339 lw $t7, 60($a0)
340 lw $s0, 64($a0)
341 lw $s1, 68($a0)
342 lw $s2, 72($a0)
343 lw $s3, 76($a0)
344 lw $s4, 80($a0)
345 lw $s5, 84($a0)
346 lw $s6, 88($a0)
347 lw $s7, 92($a0)
348 lw $t8, 96($a0)
349 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700350 lw $gp, 112($a0)
351 lw $sp, 116($a0)
352 lw $fp, 120($a0)
353 lw $ra, 124($a0)
354 lw $a0, 16($a0)
355 move $v0, $zero # clear result registers r0 and r1
356 jr $ra # do long jump
357 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800358END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800359
buzbee5bc5a7b2012-03-07 15:52:59 -0800360 /*
361 * Called by managed code, saves most registers (forms basis of long jump context) and passes
362 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
363 * the bottom of the thread. On entry r0 holds Throwable*
364 */
Ian Rogers468532e2013-08-05 10:56:33 -0700365ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700366 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700367 la $t9, artDeliverExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700368 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
369 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700370END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800371
buzbee5bc5a7b2012-03-07 15:52:59 -0800372 /*
373 * Called by managed code to create and deliver a NullPointerException
374 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800375 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700376ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700377 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700378 la $t9, artThrowNullPointerExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700379 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*)
380 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700381END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800382
buzbee5bc5a7b2012-03-07 15:52:59 -0800383 /*
384 * Called by managed code to create and deliver an ArithmeticException
385 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800386 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700387ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700388 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700389 la $t9, artThrowDivZeroFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700390 jr $t9 # artThrowDivZeroFromCode(Thread*)
391 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700392END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800393
buzbee5bc5a7b2012-03-07 15:52:59 -0800394 /*
395 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
396 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800397 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700398ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700399 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700400 la $t9, artThrowArrayBoundsFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700401 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
402 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700403END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800404
Ian Rogers57b86d42012-03-27 16:05:41 -0700405 /*
406 * Called by managed code to create and deliver a StackOverflowError.
407 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800408 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700409ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700410 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700411 la $t9, artThrowStackOverflowFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700412 jr $t9 # artThrowStackOverflowFromCode(Thread*)
413 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700414END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800415
Ian Rogers57b86d42012-03-27 16:05:41 -0700416 /*
417 * Called by managed code to create and deliver a NoSuchMethodError.
418 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800419 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700420ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700421 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700422 la $t9, artThrowNoSuchMethodFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700423 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
424 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700425END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800426
buzbee5bc5a7b2012-03-07 15:52:59 -0800427 /*
428 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700429 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800430 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
431 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700432 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800433 *
jeffhao7fbee072012-08-24 17:56:54 -0700434 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
435 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800436 *
jeffhaofa147e22012-10-12 17:03:32 -0700437 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800438 * thread and we branch to another stub to deliver it.
439 *
440 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
441 * pointing back to the original caller.
442 */
443.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800444 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800445ENTRY \c_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700446 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
447 lw $a2, FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE($sp) # pass caller Method*
jeffhaofa147e22012-10-12 17:03:32 -0700448 move $t0, $sp # save $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700449 addiu $sp, $sp, -32 # make space for extra args
450 .cfi_adjust_cfa_offset 32
jeffhao7fbee072012-08-24 17:56:54 -0700451 move $a3, rSELF # pass Thread::Current
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800452 .cfi_rel_offset 28, 12
jeffhao7fbee072012-08-24 17:56:54 -0700453 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700454 sw $t0, 16($sp) # pass $sp
Jeff Hao58df3272013-04-22 15:28:53 -0700455 addiu $sp, $sp, 32 # release out args
456 .cfi_adjust_cfa_offset -32
jeffhaofa147e22012-10-12 17:03:32 -0700457 move $a0, $v0 # save target Method*
jeffhao30a33172012-10-22 18:16:22 -0700458 move $t9, $v1 # save $v0->code_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700459 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700460 beqz $v0, 1f
buzbee5bc5a7b2012-03-07 15:52:59 -0800461 nop
jeffhao30a33172012-10-22 18:16:22 -0700462 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800463 nop
4641:
465 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800466END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800467.endm
468
Logan Chien8dbb7082013-01-25 20:31:17 +0800469INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
470INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800471
Logan Chien8dbb7082013-01-25 20:31:17 +0800472INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
473INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
474INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
475INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800476
Jeff Hao79fe5392013-04-24 18:41:58 -0700477 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800478 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800479 * On entry:
480 * a0 = method pointer
481 * a1 = argument array or NULL for no argument methods
482 * a2 = size of argument array in bytes
483 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700484 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800485 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800486 */
487ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800488 sw $a0, 0($sp) # save out a0
489 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
490 .cfi_adjust_cfa_offset 16
491 sw $ra, 12($sp)
492 .cfi_rel_offset 31, 12
493 sw $fp, 8($sp)
494 .cfi_rel_offset 30, 8
495 sw $s1, 4($sp)
496 .cfi_rel_offset 17, 4
497 sw $s0, 0($sp)
498 .cfi_rel_offset 16, 0
499 move $fp, $sp # save sp in fp
500 .cfi_def_cfa_register 30
501 move $s1, $a3 # move managed thread pointer into s1
502 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
503 addiu $t0, $a2, 16 # create space for method pointer in frame
Douglas Leungb2649372014-06-02 17:45:54 -0700504 srl $t0, $t0, 4 # shift the frame size right 4
505 sll $t0, $t0, 4 # shift the frame size left 4 to align to 16 bytes
Jeff Hao5d917302013-02-27 17:57:33 -0800506 subu $sp, $sp, $t0 # reserve stack space for argument array
507 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
508 jal memcpy # (dest, src, bytes)
509 addiu $sp, $sp, -16 # make space for argument slots for memcpy
510 addiu $sp, $sp, 16 # restore stack after memcpy
511 lw $a0, 16($fp) # restore method*
512 lw $a1, 4($sp) # copy arg value for a1
513 lw $a2, 8($sp) # copy arg value for a2
514 lw $a3, 12($sp) # copy arg value for a3
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700515 lw $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800516 jalr $t9 # call the method
517 sw $zero, 0($sp) # store NULL for method* at bottom of frame
518 move $sp, $fp # restore the stack
519 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800520 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800521 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800522 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800523 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800524 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800525 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800526 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800527 addiu $sp, $sp, 16
528 .cfi_adjust_cfa_offset -16
529 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800530 lw $t1, 20($sp) # get shorty
531 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700532 li $t2, 68 # put char 'D' into t2
533 beq $t1, $t2, 1f # branch if result type char == 'D'
534 li $t3, 70 # put char 'F' into t3
535 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800536 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700537 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800538 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005391:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700540 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800541 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700542 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800543END art_quick_invoke_stub
544
545 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800546 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
547 * failure.
548 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800549 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700550ENTRY art_quick_handle_fill_data
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700551 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
552 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
553 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700554 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700555 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700556END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800557
buzbee5bc5a7b2012-03-07 15:52:59 -0800558 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700559 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800560 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800561 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700562ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800563 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700564 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700565 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
566 jal artLockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700567 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700568 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700569END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800570
buzbee5bc5a7b2012-03-07 15:52:59 -0800571 /*
572 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
573 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800574 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700575ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800576 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700577 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700578 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
579 jal artUnlockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700580 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800581 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700582END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800583
buzbee5bc5a7b2012-03-07 15:52:59 -0800584 /*
585 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
586 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700587 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700588ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700589 addiu $sp, $sp, -16
590 .cfi_adjust_cfa_offset 16
591 sw $ra, 12($sp)
592 .cfi_rel_offset 31, 12
593 sw $t9, 8($sp)
594 sw $a1, 4($sp)
595 sw $a0, 0($sp)
596 jal artIsAssignableFromCode
597 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800598 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700599 lw $ra, 12($sp)
600 jr $ra
601 addiu $sp, $sp, 16
602 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800603.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700604 lw $t9, 8($sp)
605 lw $a1, 4($sp)
606 lw $a0, 0($sp)
607 addiu $sp, $sp, 16
608 .cfi_adjust_cfa_offset -16
609 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700610 la $t9, artThrowClassCastException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700611 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*)
612 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700613END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800614
buzbee5bc5a7b2012-03-07 15:52:59 -0800615 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700616 * Entry from managed code for array put operations of objects where the value being stored
617 * needs to be checked for compatibility.
618 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800619 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700620ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800621 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700622 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800623 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700624 nop
625END art_quick_aput_obj_with_null_and_bound_check
626
627ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700628 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700629 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800630 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700631 nop
632 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800633 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700634 move $a1, $t0
635END art_quick_aput_obj_with_bound_check
636
637ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800638 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700639 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700640 lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
641 lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
642 lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800643 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700644 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800645.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700646 sll $a1, $a1, 2
647 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700648 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700649 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
650 srl $t1, $a0, 7
651 add $t1, $t1, $t0
652 sb $t0, ($t1)
653 jr $ra
654 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800655.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700656 sll $a1, $a1, 2
657 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700658 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700659 jr $ra
660 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800661.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700662 addiu $sp, $sp, -32
663 .cfi_adjust_cfa_offset 32
664 sw $ra, 28($sp)
665 .cfi_rel_offset 31, 28
666 sw $t9, 12($sp)
667 sw $a2, 8($sp)
668 sw $a1, 4($sp)
669 sw $a0, 0($sp)
670 move $a1, $t1
671 move $a0, $t0
672 jal artIsAssignableFromCode # (Class*, Class*)
673 nop
674 lw $ra, 28($sp)
675 lw $t9, 12($sp)
676 lw $a2, 8($sp)
677 lw $a1, 4($sp)
678 lw $a0, 0($sp)
679 add $sp, 32
680 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800681 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700682 nop
683 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
684 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -0700685 la $t9, artThrowArrayStoreException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700686 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
687 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -0700688END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800689
buzbee5bc5a7b2012-03-07 15:52:59 -0800690 /*
691 * Entry from managed code when uninitialized static storage, this stub will run the class
692 * initializer and deliver the exception on error. On success the static storage base is
693 * returned.
694 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800695 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700696ENTRY art_quick_initialize_static_storage
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700697 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
698 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800699 jal artInitializeStaticStorageFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700700 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800701 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700702END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800703
buzbee5bc5a7b2012-03-07 15:52:59 -0800704 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700705 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800706 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800707 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700708ENTRY art_quick_initialize_type
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700709 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
710 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800711 jal artInitializeTypeFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700712 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800713 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700714END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800715
buzbee5bc5a7b2012-03-07 15:52:59 -0800716 /*
717 * 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 -0700718 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800719 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800720 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700721ENTRY art_quick_initialize_type_and_verify_access
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700722 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
723 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800724 jal artInitializeTypeAndVerifyAccessFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700725 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800726 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700727END art_quick_initialize_type_and_verify_access
Fred Shih37f05ef2014-07-16 18:38:08 -0700728 /*
729 * Called by managed code to resolve a static field and load a boolean primitive value.
730 */
731 .extern artGetBooleanStaticFromCode
732ENTRY art_quick_get_boolean_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700733 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
734 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
735 jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700736 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700737 RETURN_IF_NO_EXCEPTION
738END art_quick_get_boolean_static
739 /*
740 * Called by managed code to resolve a static field and load a byte primitive value.
741 */
742 .extern artGetByteStaticFromCode
743ENTRY art_quick_get_byte_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700744 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
745 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
746 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700747 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700748 RETURN_IF_NO_EXCEPTION
749END art_quick_get_byte_static
750
751 /*
752 * Called by managed code to resolve a static field and load a char primitive value.
753 */
754 .extern artGetCharStaticFromCode
755ENTRY art_quick_get_char_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700756 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
757 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
758 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700759 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700760 RETURN_IF_NO_EXCEPTION
761END art_quick_get_char_static
762 /*
763 * Called by managed code to resolve a static field and load a short primitive value.
764 */
765 .extern artGetShortStaticFromCode
766ENTRY art_quick_get_short_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700767 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
768 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
769 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700770 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700771 RETURN_IF_NO_EXCEPTION
772END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800773
buzbee5bc5a7b2012-03-07 15:52:59 -0800774 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700775 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800776 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800777 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700778ENTRY art_quick_get32_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700779 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
780 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
781 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700782 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800783 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700784END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800785
buzbee5bc5a7b2012-03-07 15:52:59 -0800786 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700787 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800788 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800789 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700790ENTRY art_quick_get64_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700791 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
792 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
793 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700794 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800795 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700796END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800797
buzbee5bc5a7b2012-03-07 15:52:59 -0800798 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700799 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800800 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800801 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700802ENTRY art_quick_get_obj_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700803 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
804 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
805 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700806 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800807 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700808END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800809
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700811 * Called by managed code to resolve an instance field and load a boolean primitive value.
812 */
813 .extern artGetBooleanInstanceFromCode
814ENTRY art_quick_get_boolean_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700815 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
816 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
817 jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700818 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700819 RETURN_IF_NO_EXCEPTION
820END art_quick_get_boolean_instance
821 /*
822 * Called by managed code to resolve an instance field and load a byte primitive value.
823 */
824 .extern artGetByteInstanceFromCode
825ENTRY art_quick_get_byte_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700826 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
827 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
828 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700829 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700830 RETURN_IF_NO_EXCEPTION
831END art_quick_get_byte_instance
832
833 /*
834 * Called by managed code to resolve an instance field and load a char primitive value.
835 */
836 .extern artGetCharInstanceFromCode
837ENTRY art_quick_get_char_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700838 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
839 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
840 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700841 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700842 RETURN_IF_NO_EXCEPTION
843END art_quick_get_char_instance
844 /*
845 * Called by managed code to resolve an instance field and load a short primitive value.
846 */
847 .extern artGetShortInstanceFromCode
848ENTRY art_quick_get_short_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700849 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
850 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
851 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700852 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700853 RETURN_IF_NO_EXCEPTION
854END art_quick_get_short_instance
855
856 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700857 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800858 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800859 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700860ENTRY art_quick_get32_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700861 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
862 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700863 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700864 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700865 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800866 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700867END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800868
buzbee5bc5a7b2012-03-07 15:52:59 -0800869 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700870 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800871 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800872 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700873ENTRY art_quick_get64_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700874 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
875 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
jeffhao7fbee072012-08-24 17:56:54 -0700876 move $a3, rSELF # pass Thread::Current
jeffhaofa147e22012-10-12 17:03:32 -0700877 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp)
jeffhao4eb68ed2012-10-17 16:41:07 -0700878 sw $sp, 16($sp) # pass $sp
buzbee5bc5a7b2012-03-07 15:52:59 -0800879 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700880END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800881
buzbee5bc5a7b2012-03-07 15:52:59 -0800882 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700883 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800884 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800885 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700886ENTRY art_quick_get_obj_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700887 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
888 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
889 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700890 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800891 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700892END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800893
buzbee5bc5a7b2012-03-07 15:52:59 -0800894 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700895 * Called by managed code to resolve a static field and store a 8-bit primitive value.
896 */
897 .extern artSet8StaticFromCode
898ENTRY art_quick_set8_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700899 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
900 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
901 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700902 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700903 RETURN_IF_ZERO
904END art_quick_set8_static
905
906 /*
907 * Called by managed code to resolve a static field and store a 16-bit primitive value.
908 */
909 .extern artSet16StaticFromCode
910ENTRY art_quick_set16_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700911 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
912 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
Fred Shih37f05ef2014-07-16 18:38:08 -0700913 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700914 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700915 RETURN_IF_ZERO
916END art_quick_set16_static
917
918 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700919 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800920 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800921 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700922ENTRY art_quick_set32_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700923 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
924 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
925 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700926 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800927 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700928END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800929
buzbee5bc5a7b2012-03-07 15:52:59 -0800930 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700931 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800932 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700933 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700934ENTRY art_quick_set64_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700935 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
936 lw $a1, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
937 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700938 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800939 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700940END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800941
buzbee5bc5a7b2012-03-07 15:52:59 -0800942 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700943 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800944 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800945 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700946ENTRY art_quick_set_obj_static
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700947 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
948 lw $a2, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
949 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700950 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800951 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700952END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800953
buzbee5bc5a7b2012-03-07 15:52:59 -0800954 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700955 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
956 */
957 .extern artSet8InstanceFromCode
958ENTRY art_quick_set8_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700959 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
960 lw $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
961 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700962 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700963 RETURN_IF_ZERO
964END art_quick_set8_instance
965
966 /*
967 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
968 */
969 .extern artSet16InstanceFromCode
970ENTRY art_quick_set16_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700971 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
972 lw $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
973 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700974 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700975 RETURN_IF_ZERO
976END art_quick_set16_instance
977
978 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700979 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800980 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800981 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700982ENTRY art_quick_set32_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700983 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
984 lw $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
985 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700986 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800987 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700988END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800989
buzbee5bc5a7b2012-03-07 15:52:59 -0800990 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700991 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800992 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700993 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700994ENTRY art_quick_set64_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700995 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
996 lw $t0, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # load referrer's Method*
997 sw rSELF, 20($sp) # pass Thread::Current
998 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
999 sw $t0, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001000 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001001END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001002
buzbee5bc5a7b2012-03-07 15:52:59 -08001003 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001004 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001005 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001006 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001007ENTRY art_quick_set_obj_instance
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001008 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1009 lw $a3, FRAME_SIZE_REFS_ONLY_CALLEE_SAVE($sp) # pass referrer's Method*
1010 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001011 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001012 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001013END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001014
buzbee5bc5a7b2012-03-07 15:52:59 -08001015 /*
1016 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1017 * exception on error. On success the String is returned. R0 holds the referring method,
1018 * R1 holds the string index. The fast path check for hit in strings cache has already been
1019 * performed.
1020 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001021 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001022ENTRY art_quick_resolve_string
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001023 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1024 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -08001025 jal artResolveStringFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001026 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001027 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001028END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -08001029
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001030
1031// Macro to facilitate adding new allocation entrypoints.
1032.macro TWO_ARG_DOWNCALL name, entrypoint, return
1033 .extern \entrypoint
1034ENTRY \name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001035 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001036 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001037 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001038 \return
1039END \name
1040.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001041
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001042.macro THREE_ARG_DOWNCALL name, entrypoint, return
1043 .extern \entrypoint
1044ENTRY \name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001045 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001046 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001047 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001048 \return
1049END \name
1050.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001051
Mathieu Chartier7410f292013-11-24 13:17:35 -08001052// Generate the allocation entrypoints for each allocator.
1053GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001054
buzbee5bc5a7b2012-03-07 15:52:59 -08001055 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001056 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001057 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001058 .extern artTestSuspendFromCode
1059ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001060 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001061 bnez $a0, 1f
1062 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1063 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001064 nop
10651:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001066 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1067 jal artTestSuspendFromCode # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001068 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001069 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001070END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001071
buzbee5bc5a7b2012-03-07 15:52:59 -08001072 /*
1073 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001074 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001075 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001076 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001077ENTRY art_quick_proxy_invoke_handler
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001078 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001079 sw $a0, 0($sp) # place proxy method at bottom of frame
1080 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001081 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Ian Rogersaf6e67a2013-01-16 08:38:37 -08001082 move $a3, $sp # pass $sp
jeffhao7fbee072012-08-24 17:56:54 -07001083 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001084 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001085 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001086 mtc1 $v0, $f0 # place return value to FP return value
jeffhao7fbee072012-08-24 17:56:54 -07001087 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001088 mtc1 $v1, $f1 # place return value to FP return value
buzbee5bc5a7b2012-03-07 15:52:59 -080010891:
1090 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001091END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001092
Jeff Hao88474b42013-10-23 16:24:40 -07001093 /*
1094 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1095 * dex method index.
1096 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001097ENTRY_NO_GP art_quick_imt_conflict_trampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001098 lw $a0, 0($sp) # load caller Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001099 lw $a0, MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
Jeff Hao88474b42013-10-23 16:24:40 -07001100 sll $t0, 2 # convert target method offset to bytes
1101 add $a0, $t0 # get address of target method
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001102 lw $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
Jeff Hao88474b42013-10-23 16:24:40 -07001103 la $t9, art_quick_invoke_interface_trampoline
1104 jr $t9
1105END art_quick_imt_conflict_trampoline
1106
Ian Rogers468532e2013-08-05 10:56:33 -07001107 .extern artQuickResolutionTrampoline
1108ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001109 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001110 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001111 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Ian Rogers468532e2013-08-05 10:56:33 -07001112 move $a3, $sp # pass $sp
Ian Rogers468532e2013-08-05 10:56:33 -07001113 beqz $v0, 1f
1114 lw $a0, 0($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001115 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001116 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001117 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001118 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011191:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001120 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001121 DELIVER_PENDING_EXCEPTION
1122END art_quick_resolution_trampoline
1123
Andreas Gampe2da88232014-02-27 12:26:20 -08001124UNIMPLEMENTED art_quick_generic_jni_trampoline
1125
Ian Rogers468532e2013-08-05 10:56:33 -07001126 .extern artQuickToInterpreterBridge
1127ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001128 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001129 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001130 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
Ian Rogers7db619b2013-01-16 18:35:48 -08001131 move $a2, $sp # pass $sp
1132 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001133 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001134 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001135 mtc1 $v0, $f0 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001136 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001137 mtc1 $v1, $f1 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -080011381:
1139 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001140END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001141
buzbee5bc5a7b2012-03-07 15:52:59 -08001142 /*
jeffhao725a9572012-11-13 18:20:12 -08001143 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001144 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001145 .extern artInstrumentationMethodEntryFromCode
1146 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001147ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001148 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao12051ea2013-01-10 11:24:31 -08001149 move $t0, $sp # remember bottom of caller's frame
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001150 addiu $sp, $sp, -32 # space for saved a0, pad (2 words), arguments (4 words)
Ian Rogers62d6c772013-02-27 08:32:07 -08001151 .cfi_adjust_cfa_offset 32
1152 sw $a0, 28($sp) # save arg0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001153 move $a3, $ra # pass $ra
1154 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001155 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001156 move $t9, $v0 # $t9 holds reference to code
Ian Rogers62d6c772013-02-27 08:32:07 -08001157 lw $a0, 28($sp) # restore arg0
1158 addiu $sp, $sp, 32 # remove args
1159 .cfi_adjust_cfa_offset -32
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001160 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001161 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001162 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001163END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001164 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001165 .global art_quick_instrumentation_exit
1166art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001167 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001168 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001169 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001170 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001171 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leungc3d131e2014-07-16 17:32:41 -07001172 move $t0, $sp # remember bottom of caller's frame
Ian Rogers62d6c772013-02-27 08:32:07 -08001173 addiu $sp, $sp, -48 # save return values and set up args
1174 .cfi_adjust_cfa_offset 48
1175 sw $v0, 32($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001176 .cfi_rel_offset 2, 32
Ian Rogers62d6c772013-02-27 08:32:07 -08001177 sw $v1, 36($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001178 .cfi_rel_offset 3, 36
Ian Rogers62d6c772013-02-27 08:32:07 -08001179 s.s $f0, 40($sp)
1180 s.s $f1, 44($sp)
1181 s.s $f0, 16($sp) # pass fpr result
1182 s.s $f1, 20($sp)
1183 move $a2, $v0 # pass gpr result
1184 move $a3, $v1
jeffhao12051ea2013-01-10 11:24:31 -08001185 move $a1, $t0 # pass $sp
Ian Rogers62d6c772013-02-27 08:32:07 -08001186 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001187 move $a0, rSELF # pass Thread::Current
1188 move $t0, $v0 # set aside returned link register
1189 move $ra, $v1 # set link register for deoptimization
Ian Rogers62d6c772013-02-27 08:32:07 -08001190 lw $v0, 32($sp) # restore return values
1191 lw $v1, 36($sp)
1192 l.s $f0, 40($sp)
1193 l.s $f1, 44($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001194 jr $t0 # return
Ian Rogers62d6c772013-02-27 08:32:07 -08001195 addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame
1196 .cfi_adjust_cfa_offset -112
Ian Rogers468532e2013-08-05 10:56:33 -07001197END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001198
jeffhao12051ea2013-01-10 11:24:31 -08001199 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001200 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1201 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001202 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001203 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001204ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001205 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001206 jal artDeoptimize # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001207 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001208 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001209END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001210
buzbee5bc5a7b2012-03-07 15:52:59 -08001211 /*
1212 * Long integer shift. This is different from the generic 32/64-bit
1213 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1214 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1215 * 6 bits.
1216 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001217 * $a0: low word
1218 * $a1: high word
1219 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001220 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001221ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001222 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001223 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1224 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1225 srl $a0, 1
1226 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1227 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1228 or $v1, $a0 # rhi<- rhi | alo
1229 andi $a2, 0x20 # shift< shift & 0x20
1230 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1231 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001232 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001233END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001234
buzbee5bc5a7b2012-03-07 15:52:59 -08001235 /*
1236 * Long integer shift. This is different from the generic 32/64-bit
1237 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1238 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1239 * 6 bits.
1240 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001241 * $a0: low word
1242 * $a1: high word
1243 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001244 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001245ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001246 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1247 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1248 sra $a3, $a1, 31 # $a3<- sign(ah)
1249 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1250 sll $a1, 1
1251 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1252 or $v0, $a1 # rlo<- rlo | ahi
1253 andi $a2, 0x20 # shift & 0x20
1254 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1255 jr $ra
1256 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001257END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001258
buzbee5bc5a7b2012-03-07 15:52:59 -08001259 /*
1260 * Long integer shift. This is different from the generic 32/64-bit
1261 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1262 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1263 * 6 bits.
1264 * On entry:
1265 * r0: low word
1266 * r1: high word
1267 * r2: shift count
1268 */
1269 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001270ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001271 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001272 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001273 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1274 sll $a1, 1
1275 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1276 or $v0, $a1 # rlo<- rlo | ahi
1277 andi $a2, 0x20 # shift & 0x20
1278 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1279 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001280 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001281END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001282
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001283UNIMPLEMENTED art_quick_indexof
1284UNIMPLEMENTED art_quick_string_compareto