blob: a4452261204efcde5a2abe105d4049261d23e639 [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
Douglas Leung735b8552014-10-31 12:21:40 -070029#define ARG_SLOT_SIZE 32 // space for a0-a3 plus 4 more words
30
buzbee5bc5a7b2012-03-07 15:52:59 -080031 /*
32 * Macro that sets up the callee save frame to conform with
33 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Douglas Leung735b8552014-10-31 12:21:40 -070034 * Callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word for Method*
35 * Clobbers $t0 and $sp
36 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
37 * Reserves FRAME_SIZE_SAVE_ALL_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080038 */
Ian Rogers57b86d42012-03-27 16:05:41 -070039.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -070040 addiu $sp, $sp, -48
41 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -070042
43 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -070044#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -070045#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
46#endif
47
Douglas Leung735b8552014-10-31 12:21:40 -070048 sw $ra, 44($sp)
49 .cfi_rel_offset 31, 44
50 sw $s8, 40($sp)
51 .cfi_rel_offset 30, 40
52 sw $gp, 36($sp)
53 .cfi_rel_offset 28, 36
54 sw $s7, 32($sp)
55 .cfi_rel_offset 23, 32
56 sw $s6, 28($sp)
57 .cfi_rel_offset 22, 28
58 sw $s5, 24($sp)
59 .cfi_rel_offset 21, 24
60 sw $s4, 20($sp)
61 .cfi_rel_offset 20, 20
62 sw $s3, 16($sp)
63 .cfi_rel_offset 19, 16
64 sw $s2, 12($sp)
65 .cfi_rel_offset 18, 12
66 sw $s1, 8($sp)
67 .cfi_rel_offset 17, 8
68 sw $s0, 4($sp)
69 .cfi_rel_offset 16, 4
70 # 1 word for holding Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070071
Douglas Leung4af77b72014-10-22 16:32:28 -070072 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
73 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070074 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -070075 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070076 sw $t0, 0($sp) # Place Method* at bottom of stack.
77 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -070078 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
79 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -080080.endm
81
82 /*
83 * Macro that sets up the callee save frame to conform with
84 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
85 * Does not include rSUSPEND or rSELF
Douglas Leung735b8552014-10-31 12:21:40 -070086 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
87 * Clobbers $t0 and $sp
88 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
89 * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080090 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070091.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -070092 addiu $sp, $sp, -48
93 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -070094
95 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -070096#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -070097#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
98#endif
99
Douglas Leung735b8552014-10-31 12:21:40 -0700100 sw $ra, 44($sp)
101 .cfi_rel_offset 31, 44
102 sw $s8, 40($sp)
103 .cfi_rel_offset 30, 40
104 sw $gp, 36($sp)
105 .cfi_rel_offset 28, 36
106 sw $s7, 32($sp)
107 .cfi_rel_offset 23, 32
108 sw $s6, 28($sp)
109 .cfi_rel_offset 22, 28
110 sw $s5, 24($sp)
111 .cfi_rel_offset 21, 24
112 sw $s4, 20($sp)
113 .cfi_rel_offset 20, 20
114 sw $s3, 16($sp)
115 .cfi_rel_offset 19, 16
116 sw $s2, 12($sp)
117 .cfi_rel_offset 18, 12
118 # 2 words for alignment and bottom word will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700119
Douglas Leung4af77b72014-10-22 16:32:28 -0700120 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
121 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700122 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700123 lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700124 sw $t0, 0($sp) # Place Method* at bottom of stack.
125 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700126 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
127 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800128.endm
129
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700130.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700131 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
132 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
133 lw $ra, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800134 .cfi_restore 31
Douglas Leung735b8552014-10-31 12:21:40 -0700135 lw $s8, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800136 .cfi_restore 30
Douglas Leung735b8552014-10-31 12:21:40 -0700137 lw $gp, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800138 .cfi_restore 28
Douglas Leung735b8552014-10-31 12:21:40 -0700139 lw $s7, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800140 .cfi_restore 23
Douglas Leung735b8552014-10-31 12:21:40 -0700141 lw $s6, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800142 .cfi_restore 22
Douglas Leung735b8552014-10-31 12:21:40 -0700143 lw $s5, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800144 .cfi_restore 21
Douglas Leung735b8552014-10-31 12:21:40 -0700145 lw $s4, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800146 .cfi_restore 20
Douglas Leung735b8552014-10-31 12:21:40 -0700147 lw $s3, 16($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800148 .cfi_restore 19
Douglas Leung735b8552014-10-31 12:21:40 -0700149 lw $s2, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800150 .cfi_restore 18
Douglas Leung735b8552014-10-31 12:21:40 -0700151 addiu $sp, $sp, 48
152 .cfi_adjust_cfa_offset -48
buzbee5bc5a7b2012-03-07 15:52:59 -0800153.endm
154
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700155.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Douglas Leung735b8552014-10-31 12:21:40 -0700156 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700157 jr $ra
Douglas Leung735b8552014-10-31 12:21:40 -0700158 nop
buzbee5bc5a7b2012-03-07 15:52:59 -0800159.endm
160
161 /*
162 * Macro that sets up the callee save frame to conform with
Douglas Leung735b8552014-10-31 12:21:40 -0700163 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700164 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800165 */
Douglas Leung735b8552014-10-31 12:21:40 -0700166.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700167 addiu $sp, $sp, -64
168 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700169
170 // Ugly compile-time check, but we only have the preprocessor.
171#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
172#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
173#endif
174
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700175 sw $ra, 60($sp)
176 .cfi_rel_offset 31, 60
177 sw $s8, 56($sp)
178 .cfi_rel_offset 30, 56
179 sw $gp, 52($sp)
180 .cfi_rel_offset 28, 52
181 sw $s7, 48($sp)
182 .cfi_rel_offset 23, 48
183 sw $s6, 44($sp)
184 .cfi_rel_offset 22, 44
185 sw $s5, 40($sp)
186 .cfi_rel_offset 21, 40
187 sw $s4, 36($sp)
188 .cfi_rel_offset 20, 36
189 sw $s3, 32($sp)
190 .cfi_rel_offset 19, 32
191 sw $s2, 28($sp)
192 .cfi_rel_offset 18, 28
jeffhao7fbee072012-08-24 17:56:54 -0700193 sw $a3, 12($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800194 .cfi_rel_offset 7, 12
jeffhao7fbee072012-08-24 17:56:54 -0700195 sw $a2, 8($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800196 .cfi_rel_offset 6, 8
jeffhao7fbee072012-08-24 17:56:54 -0700197 sw $a1, 4($sp)
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800198 .cfi_rel_offset 5, 4
jeffhaofa147e22012-10-12 17:03:32 -0700199 # bottom will hold Method*
Douglas Leung735b8552014-10-31 12:21:40 -0700200.endm
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700201
Douglas Leung735b8552014-10-31 12:21:40 -0700202 /*
203 * Macro that sets up the callee save frame to conform with
204 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
205 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
206 * Clobbers $t0 and $sp
207 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
208 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
209 */
210.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
211 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Douglas Leung4af77b72014-10-22 16:32:28 -0700212 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
213 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700214 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700215 lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700216 sw $t0, 0($sp) # Place Method* at bottom of stack.
217 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700218 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
219 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
220.endm
221
222 /*
223 * Macro that sets up the callee save frame to conform with
224 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
225 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
226 * Clobbers $sp
227 * Use $a0 as the Method* and loads it into bottom of stack.
228 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
229 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
230 */
231.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
232 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
233 sw $a0, 0($sp) # Place Method* at bottom of stack.
234 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
235 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
236 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800237.endm
238
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700239.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700240 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
241 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700242 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800243 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700244 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800245 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700246 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800247 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700248 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800249 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700250 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800251 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700252 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800253 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700254 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800255 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700256 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800257 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700258 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800259 .cfi_restore 18
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700260 lw $a3, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800261 .cfi_restore 7
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700262 lw $a2, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800263 .cfi_restore 6
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700264 lw $a1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800265 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700266 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700267 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800268.endm
269
270 /*
271 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
272 * exception is Thread::Current()->exception_
273 */
274.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700275 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700276 la $t9, artDeliverPendingExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700277 jr $t9 # artDeliverPendingExceptionFromCode(Thread*)
278 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800279.endm
280
281.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700282 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700283 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700284 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800285 nop
jeffhao7fbee072012-08-24 17:56:54 -0700286 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800287 nop
2881:
289 DELIVER_PENDING_EXCEPTION
290.endm
291
292.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700293 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700294 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800295 nop
jeffhao7fbee072012-08-24 17:56:54 -0700296 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800297 nop
2981:
299 DELIVER_PENDING_EXCEPTION
300.endm
301
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800302.macro RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700303 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700304 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800305 nop
jeffhao7fbee072012-08-24 17:56:54 -0700306 jr $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800307 nop
3081:
309 DELIVER_PENDING_EXCEPTION
310.endm
311
buzbee5bc5a7b2012-03-07 15:52:59 -0800312 /*
jeffhao7fbee072012-08-24 17:56:54 -0700313 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800314 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
315 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800316ENTRY art_quick_do_long_jump
jeffhao7fbee072012-08-24 17:56:54 -0700317 l.s $f0, 0($a1)
318 l.s $f1, 4($a1)
319 l.s $f2, 8($a1)
320 l.s $f3, 12($a1)
321 l.s $f4, 16($a1)
322 l.s $f5, 20($a1)
323 l.s $f6, 24($a1)
324 l.s $f7, 28($a1)
325 l.s $f8, 32($a1)
326 l.s $f9, 36($a1)
327 l.s $f10, 40($a1)
328 l.s $f11, 44($a1)
329 l.s $f12, 48($a1)
330 l.s $f13, 52($a1)
331 l.s $f14, 56($a1)
332 l.s $f15, 60($a1)
333 l.s $f16, 64($a1)
334 l.s $f17, 68($a1)
335 l.s $f18, 72($a1)
336 l.s $f19, 76($a1)
337 l.s $f20, 80($a1)
338 l.s $f21, 84($a1)
339 l.s $f22, 88($a1)
340 l.s $f23, 92($a1)
341 l.s $f24, 96($a1)
342 l.s $f25, 100($a1)
343 l.s $f26, 104($a1)
344 l.s $f27, 108($a1)
345 l.s $f28, 112($a1)
346 l.s $f29, 116($a1)
347 l.s $f30, 120($a1)
348 l.s $f31, 124($a1)
Chris Dearman748dd952014-05-23 10:47:01 -0700349 .set push
350 .set nomacro
351 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700352 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700353 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700354 lw $v0, 8($a0)
355 lw $v1, 12($a0)
356 lw $a1, 20($a0)
357 lw $a2, 24($a0)
358 lw $a3, 28($a0)
359 lw $t0, 32($a0)
360 lw $t1, 36($a0)
361 lw $t2, 40($a0)
362 lw $t3, 44($a0)
363 lw $t4, 48($a0)
364 lw $t5, 52($a0)
365 lw $t6, 56($a0)
366 lw $t7, 60($a0)
367 lw $s0, 64($a0)
368 lw $s1, 68($a0)
369 lw $s2, 72($a0)
370 lw $s3, 76($a0)
371 lw $s4, 80($a0)
372 lw $s5, 84($a0)
373 lw $s6, 88($a0)
374 lw $s7, 92($a0)
375 lw $t8, 96($a0)
376 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700377 lw $gp, 112($a0)
378 lw $sp, 116($a0)
379 lw $fp, 120($a0)
380 lw $ra, 124($a0)
381 lw $a0, 16($a0)
382 move $v0, $zero # clear result registers r0 and r1
383 jr $ra # do long jump
384 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800385END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800386
buzbee5bc5a7b2012-03-07 15:52:59 -0800387 /*
388 * Called by managed code, saves most registers (forms basis of long jump context) and passes
389 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
390 * the bottom of the thread. On entry r0 holds Throwable*
391 */
Ian Rogers468532e2013-08-05 10:56:33 -0700392ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700393 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700394 la $t9, artDeliverExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700395 jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
396 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700397END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800398
buzbee5bc5a7b2012-03-07 15:52:59 -0800399 /*
400 * Called by managed code to create and deliver a NullPointerException
401 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800402 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700403ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700404 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700405 la $t9, artThrowNullPointerExceptionFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700406 jr $t9 # artThrowNullPointerExceptionFromCode(Thread*)
407 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700408END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800409
buzbee5bc5a7b2012-03-07 15:52:59 -0800410 /*
411 * Called by managed code to create and deliver an ArithmeticException
412 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800413 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700414ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700415 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700416 la $t9, artThrowDivZeroFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700417 jr $t9 # artThrowDivZeroFromCode(Thread*)
418 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700419END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800420
buzbee5bc5a7b2012-03-07 15:52:59 -0800421 /*
422 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
423 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800424 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700425ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700426 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700427 la $t9, artThrowArrayBoundsFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700428 jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
429 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700430END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800431
Ian Rogers57b86d42012-03-27 16:05:41 -0700432 /*
433 * Called by managed code to create and deliver a StackOverflowError.
434 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800435 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700436ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700437 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700438 la $t9, artThrowStackOverflowFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700439 jr $t9 # artThrowStackOverflowFromCode(Thread*)
440 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700441END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800442
Ian Rogers57b86d42012-03-27 16:05:41 -0700443 /*
444 * Called by managed code to create and deliver a NoSuchMethodError.
445 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800446 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700447ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700448 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700449 la $t9, artThrowNoSuchMethodFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700450 jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
451 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700452END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800453
buzbee5bc5a7b2012-03-07 15:52:59 -0800454 /*
455 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700456 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800457 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
458 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700459 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800460 *
jeffhao7fbee072012-08-24 17:56:54 -0700461 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
462 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800463 *
jeffhaofa147e22012-10-12 17:03:32 -0700464 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800465 * thread and we branch to another stub to deliver it.
466 *
467 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
468 * pointing back to the original caller.
469 */
470.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800471 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800472ENTRY \c_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700473 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Douglas Leung735b8552014-10-31 12:21:40 -0700474 lw $a2, FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE+ARG_SLOT_SIZE($sp) # pass caller Method*
475 addiu $t0, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -0700476 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700477 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700478 sw $t0, 16($sp) # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700479 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700480 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700481 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -0700482 move $t9, $v1 # save $v0->code_
jeffhao30a33172012-10-22 18:16:22 -0700483 jr $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800484 nop
4851:
486 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800487END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800488.endm
489
Logan Chien8dbb7082013-01-25 20:31:17 +0800490INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
491INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800492
Logan Chien8dbb7082013-01-25 20:31:17 +0800493INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
494INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
495INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
496INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800497
Jeff Hao79fe5392013-04-24 18:41:58 -0700498 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800499 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800500 * On entry:
501 * a0 = method pointer
502 * a1 = argument array or NULL for no argument methods
503 * a2 = size of argument array in bytes
504 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700505 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800506 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800507 */
508ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800509 sw $a0, 0($sp) # save out a0
510 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
511 .cfi_adjust_cfa_offset 16
512 sw $ra, 12($sp)
513 .cfi_rel_offset 31, 12
514 sw $fp, 8($sp)
515 .cfi_rel_offset 30, 8
516 sw $s1, 4($sp)
517 .cfi_rel_offset 17, 4
518 sw $s0, 0($sp)
519 .cfi_rel_offset 16, 0
520 move $fp, $sp # save sp in fp
521 .cfi_def_cfa_register 30
522 move $s1, $a3 # move managed thread pointer into s1
523 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Douglas Leung735b8552014-10-31 12:21:40 -0700524 addiu $t0, $a2, 4 # create space for method pointer in frame.
525 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
526 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
527 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
Jeff Hao5d917302013-02-27 17:57:33 -0800528 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
529 jal memcpy # (dest, src, bytes)
530 addiu $sp, $sp, -16 # make space for argument slots for memcpy
531 addiu $sp, $sp, 16 # restore stack after memcpy
532 lw $a0, 16($fp) # restore method*
533 lw $a1, 4($sp) # copy arg value for a1
534 lw $a2, 8($sp) # copy arg value for a2
535 lw $a3, 12($sp) # copy arg value for a3
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700536 lw $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800537 jalr $t9 # call the method
538 sw $zero, 0($sp) # store NULL for method* at bottom of frame
539 move $sp, $fp # restore the stack
540 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800541 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800542 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800543 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800544 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800545 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800546 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800547 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800548 addiu $sp, $sp, 16
549 .cfi_adjust_cfa_offset -16
550 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800551 lw $t1, 20($sp) # get shorty
552 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700553 li $t2, 68 # put char 'D' into t2
554 beq $t1, $t2, 1f # branch if result type char == 'D'
555 li $t3, 70 # put char 'F' into t3
556 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800557 sw $v0, 0($t0) # store the result
Jeff Hao6474d192013-03-26 14:08:09 -0700558 jr $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800559 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005601:
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700561 s.s $f0, 0($t0) # store floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800562 jr $ra
Jeff Hao19ca8cf2013-03-15 18:16:51 -0700563 s.s $f1, 4($t0) # store other half of floating point result
Jeff Hao5d917302013-02-27 17:57:33 -0800564END art_quick_invoke_stub
565
566 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800567 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
568 * failure.
569 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800570 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700571ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -0700572 lw $a2, 0($sp) # pass referrer's Method*
573 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700574 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700575 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700576 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700577END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800578
buzbee5bc5a7b2012-03-07 15:52:59 -0800579 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700580 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800581 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800582 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700583ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800584 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700585 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700586 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700587 jal artLockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700588 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700589 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700590END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800591
buzbee5bc5a7b2012-03-07 15:52:59 -0800592 /*
593 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
594 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800595 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700596ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800597 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700598 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700599 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700600 jal artUnlockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700601 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800602 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700603END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800604
buzbee5bc5a7b2012-03-07 15:52:59 -0800605 /*
606 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
607 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700608 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700609ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700610 addiu $sp, $sp, -16
611 .cfi_adjust_cfa_offset 16
612 sw $ra, 12($sp)
613 .cfi_rel_offset 31, 12
614 sw $t9, 8($sp)
615 sw $a1, 4($sp)
616 sw $a0, 0($sp)
617 jal artIsAssignableFromCode
Douglas Leung735b8552014-10-31 12:21:40 -0700618 addiu $sp, $sp, -16 # reserve argument slots on the stack
619 addiu $sp, $sp, 16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800620 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700621 lw $ra, 12($sp)
622 jr $ra
623 addiu $sp, $sp, 16
624 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800625.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700626 lw $t9, 8($sp)
627 lw $a1, 4($sp)
628 lw $a0, 0($sp)
629 addiu $sp, $sp, 16
630 .cfi_adjust_cfa_offset -16
631 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700632 la $t9, artThrowClassCastException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700633 jr $t9 # artThrowClassCastException (Class*, Class*, Thread*)
634 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700635END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800636
buzbee5bc5a7b2012-03-07 15:52:59 -0800637 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700638 * Entry from managed code for array put operations of objects where the value being stored
639 * needs to be checked for compatibility.
640 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800641 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700642ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800643 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700644 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800645 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700646 nop
647END art_quick_aput_obj_with_null_and_bound_check
648
649ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700650 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700651 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800652 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700653 nop
654 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800655 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700656 move $a1, $t0
657END art_quick_aput_obj_with_bound_check
658
659ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800660 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700661 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700662 lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
663 lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
664 lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800665 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700666 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800667.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700668 sll $a1, $a1, 2
669 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700670 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700671 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
672 srl $t1, $a0, 7
673 add $t1, $t1, $t0
674 sb $t0, ($t1)
675 jr $ra
676 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800677.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700678 sll $a1, $a1, 2
679 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700680 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700681 jr $ra
682 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800683.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700684 addiu $sp, $sp, -32
685 .cfi_adjust_cfa_offset 32
686 sw $ra, 28($sp)
687 .cfi_rel_offset 31, 28
688 sw $t9, 12($sp)
689 sw $a2, 8($sp)
690 sw $a1, 4($sp)
691 sw $a0, 0($sp)
692 move $a1, $t1
693 move $a0, $t0
694 jal artIsAssignableFromCode # (Class*, Class*)
Douglas Leung735b8552014-10-31 12:21:40 -0700695 addiu $sp, $sp, -16 # reserve argument slots on the stack
696 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -0700697 lw $ra, 28($sp)
698 lw $t9, 12($sp)
699 lw $a2, 8($sp)
700 lw $a1, 4($sp)
701 lw $a0, 0($sp)
702 add $sp, 32
703 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800704 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700705 nop
706 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
707 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -0700708 la $t9, artThrowArrayStoreException
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700709 jr $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
710 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -0700711END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800712
buzbee5bc5a7b2012-03-07 15:52:59 -0800713 /*
714 * Entry from managed code when uninitialized static storage, this stub will run the class
715 * initializer and deliver the exception on error. On success the static storage base is
716 * returned.
717 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800718 .extern artInitializeStaticStorageFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700719ENTRY art_quick_initialize_static_storage
Douglas Leung735b8552014-10-31 12:21:40 -0700720 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700721 # artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800722 jal artInitializeStaticStorageFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700723 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800724 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700725END art_quick_initialize_static_storage
buzbee5bc5a7b2012-03-07 15:52:59 -0800726
buzbee5bc5a7b2012-03-07 15:52:59 -0800727 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700728 * Entry from managed code when dex cache misses for a type_idx.
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800730 .extern artInitializeTypeFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700731ENTRY art_quick_initialize_type
Douglas Leung735b8552014-10-31 12:21:40 -0700732 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700733 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800734 jal artInitializeTypeFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700735 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800736 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700737END art_quick_initialize_type
buzbee5bc5a7b2012-03-07 15:52:59 -0800738
buzbee5bc5a7b2012-03-07 15:52:59 -0800739 /*
740 * 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 -0700741 * miss.
buzbee5bc5a7b2012-03-07 15:52:59 -0800742 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800743 .extern artInitializeTypeAndVerifyAccessFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700744ENTRY art_quick_initialize_type_and_verify_access
Douglas Leung735b8552014-10-31 12:21:40 -0700745 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700746 # artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800747 jal artInitializeTypeAndVerifyAccessFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700748 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800749 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700750END art_quick_initialize_type_and_verify_access
Fred Shih37f05ef2014-07-16 18:38:08 -0700751 /*
752 * Called by managed code to resolve a static field and load a boolean primitive value.
753 */
754 .extern artGetBooleanStaticFromCode
755ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -0700756 lw $a1, 0($sp) # pass referrer's Method*
757 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700758 jal artGetBooleanStaticFromCode # (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_boolean_static
762 /*
763 * Called by managed code to resolve a static field and load a byte primitive value.
764 */
765 .extern artGetByteStaticFromCode
766ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -0700767 lw $a1, 0($sp) # pass referrer's Method*
768 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700769 jal artGetByteStaticFromCode # (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_byte_static
773
774 /*
775 * Called by managed code to resolve a static field and load a char primitive value.
776 */
777 .extern artGetCharStaticFromCode
778ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -0700779 lw $a1, 0($sp) # pass referrer's Method*
780 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700781 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700782 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700783 RETURN_IF_NO_EXCEPTION
784END art_quick_get_char_static
785 /*
786 * Called by managed code to resolve a static field and load a short primitive value.
787 */
788 .extern artGetShortStaticFromCode
789ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -0700790 lw $a1, 0($sp) # pass referrer's Method*
791 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700792 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700793 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700794 RETURN_IF_NO_EXCEPTION
795END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800796
buzbee5bc5a7b2012-03-07 15:52:59 -0800797 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700798 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800799 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800800 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700801ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700802 lw $a1, 0($sp) # pass referrer's Method*
803 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700804 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700805 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800806 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700807END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800808
buzbee5bc5a7b2012-03-07 15:52:59 -0800809 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700810 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800811 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800812 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700813ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700814 lw $a1, 0($sp) # pass referrer's Method*
815 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700816 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700817 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700819END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800820
buzbee5bc5a7b2012-03-07 15:52:59 -0800821 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700822 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800823 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800824 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700825ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700826 lw $a1, 0($sp) # pass referrer's Method*
827 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700828 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700829 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800830 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700831END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800832
buzbee5bc5a7b2012-03-07 15:52:59 -0800833 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700834 * Called by managed code to resolve an instance field and load a boolean primitive value.
835 */
836 .extern artGetBooleanInstanceFromCode
837ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700838 lw $a2, 0($sp) # pass referrer's Method*
839 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700840 jal artGetBooleanInstanceFromCode # (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_boolean_instance
844 /*
845 * Called by managed code to resolve an instance field and load a byte primitive value.
846 */
847 .extern artGetByteInstanceFromCode
848ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700849 lw $a2, 0($sp) # pass referrer's Method*
850 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700851 jal artGetByteInstanceFromCode # (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_byte_instance
855
856 /*
857 * Called by managed code to resolve an instance field and load a char primitive value.
858 */
859 .extern artGetCharInstanceFromCode
860ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700861 lw $a2, 0($sp) # pass referrer's Method*
862 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700863 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700864 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700865 RETURN_IF_NO_EXCEPTION
866END art_quick_get_char_instance
867 /*
868 * Called by managed code to resolve an instance field and load a short primitive value.
869 */
870 .extern artGetShortInstanceFromCode
871ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700872 lw $a2, 0($sp) # pass referrer's Method*
873 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
874 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700875 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700876 RETURN_IF_NO_EXCEPTION
877END art_quick_get_short_instance
878
879 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700880 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800881 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800882 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700883ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700884 lw $a2, 0($sp) # pass referrer's Method*
885 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
886 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700887 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800888 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700889END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800890
buzbee5bc5a7b2012-03-07 15:52:59 -0800891 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700892 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800893 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800894 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700895ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700896 lw $a2, 0($sp) # pass referrer's Method*
897 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
898 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700899 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800900 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700901END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800902
buzbee5bc5a7b2012-03-07 15:52:59 -0800903 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700904 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800905 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800906 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700907ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700908 lw $a2, 0($sp) # pass referrer's Method*
909 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700910 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700911 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800912 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700913END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800914
buzbee5bc5a7b2012-03-07 15:52:59 -0800915 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700916 * Called by managed code to resolve a static field and store a 8-bit primitive value.
917 */
918 .extern artSet8StaticFromCode
919ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -0700920 lw $a2, 0($sp) # pass referrer's Method*
921 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700922 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700923 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700924 RETURN_IF_ZERO
925END art_quick_set8_static
926
927 /*
928 * Called by managed code to resolve a static field and store a 16-bit primitive value.
929 */
930 .extern artSet16StaticFromCode
931ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -0700932 lw $a2, 0($sp) # pass referrer's Method*
933 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Fred Shih37f05ef2014-07-16 18:38:08 -0700934 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700935 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700936 RETURN_IF_ZERO
937END art_quick_set16_static
938
939 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700940 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800941 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800942 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700943ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700944 lw $a2, 0($sp) # pass referrer's Method*
945 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700946 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700947 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800948 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700949END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800950
buzbee5bc5a7b2012-03-07 15:52:59 -0800951 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700952 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800953 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700954 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700955ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700956 lw $a1, 0($sp) # pass referrer's Method*
957 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700958 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700959 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800960 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700961END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800962
buzbee5bc5a7b2012-03-07 15:52:59 -0800963 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700964 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800965 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800966 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700967ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700968 lw $a2, 0($sp) # pass referrer's Method*
969 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao7fbee072012-08-24 17:56:54 -0700970 move $a3, rSELF # pass Thread::Current
Douglas Leung735b8552014-10-31 12:21:40 -0700971 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800972 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700973END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800974
buzbee5bc5a7b2012-03-07 15:52:59 -0800975 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700976 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
977 */
978 .extern artSet8InstanceFromCode
979ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700980 lw $a3, 0($sp) # pass referrer's Method*
981 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
982 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700983 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700984 RETURN_IF_ZERO
985END art_quick_set8_instance
986
987 /*
988 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
989 */
990 .extern artSet16InstanceFromCode
991ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700992 lw $a3, 0($sp) # pass referrer's Method*
993 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700994 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700995 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700996 RETURN_IF_ZERO
997END art_quick_set16_instance
998
999 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001000 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001001 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001002 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001003ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001004 lw $a3, 0($sp) # pass referrer's Method*
1005 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001006 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001007 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001008 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001009END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001010
buzbee5bc5a7b2012-03-07 15:52:59 -08001011 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001012 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001013 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001014 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001015ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001016 lw $t1, 0($sp) # load referrer's Method*
1017 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001018 sw rSELF, 20($sp) # pass Thread::Current
1019 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001020 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001021 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001022END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001023
buzbee5bc5a7b2012-03-07 15:52:59 -08001024 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001025 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001026 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001027 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001028ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001029 lw $a3, 0($sp) # pass referrer's Method*
1030 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001031 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001032 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001033 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001034END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001035
buzbee5bc5a7b2012-03-07 15:52:59 -08001036 /*
1037 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1038 * exception on error. On success the String is returned. R0 holds the referring method,
1039 * R1 holds the string index. The fast path check for hit in strings cache has already been
1040 * performed.
1041 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001042 .extern artResolveStringFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001043ENTRY art_quick_resolve_string
Douglas Leung735b8552014-10-31 12:21:40 -07001044 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001045 # artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -08001046 jal artResolveStringFromCode
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001047 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001048 RETURN_IF_RESULT_IS_NON_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001049END art_quick_resolve_string
buzbee5bc5a7b2012-03-07 15:52:59 -08001050
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001051
1052// Macro to facilitate adding new allocation entrypoints.
1053.macro TWO_ARG_DOWNCALL name, entrypoint, return
1054 .extern \entrypoint
1055ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001056 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001057 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001058 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001059 \return
1060END \name
1061.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001062
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001063.macro THREE_ARG_DOWNCALL name, entrypoint, return
1064 .extern \entrypoint
1065ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001066 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001067 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001068 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001069 \return
1070END \name
1071.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001072
Mathieu Chartier7410f292013-11-24 13:17:35 -08001073// Generate the allocation entrypoints for each allocator.
1074GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001075
buzbee5bc5a7b2012-03-07 15:52:59 -08001076 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001077 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001078 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001079 .extern artTestSuspendFromCode
1080ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001081 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001082 bnez $a0, 1f
1083 addi rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1084 jr $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001085 nop
10861:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001087 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1088 jal artTestSuspendFromCode # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001089 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001090 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001091END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001092
buzbee5bc5a7b2012-03-07 15:52:59 -08001093 /*
1094 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001095 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001096 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001097 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001098ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001099 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1100 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001101 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001102 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001103 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001104 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001105 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001106 mtc1 $v0, $f0 # place return value to FP return value
jeffhao7fbee072012-08-24 17:56:54 -07001107 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001108 mtc1 $v1, $f1 # place return value to FP return value
buzbee5bc5a7b2012-03-07 15:52:59 -080011091:
1110 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001111END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001112
Jeff Hao88474b42013-10-23 16:24:40 -07001113 /*
1114 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1115 * dex method index.
1116 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001117ENTRY art_quick_imt_conflict_trampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001118 lw $a0, 0($sp) # load caller Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001119 lw $a0, MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
Jeff Hao88474b42013-10-23 16:24:40 -07001120 sll $t0, 2 # convert target method offset to bytes
1121 add $a0, $t0 # get address of target method
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001122 lw $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
Jeff Hao88474b42013-10-23 16:24:40 -07001123 la $t9, art_quick_invoke_interface_trampoline
1124 jr $t9
1125END art_quick_imt_conflict_trampoline
1126
Ian Rogers468532e2013-08-05 10:56:33 -07001127 .extern artQuickResolutionTrampoline
1128ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001129 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001130 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001131 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001132 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001133 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001134 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001135 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001136 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Ian Rogers468532e2013-08-05 10:56:33 -07001137 jr $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001138 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011391:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001140 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001141 DELIVER_PENDING_EXCEPTION
1142END art_quick_resolution_trampoline
1143
Douglas Leung735b8552014-10-31 12:21:40 -07001144 .extern artQuickGenericJniTrampoline
1145 .extern artQuickGenericJniEndTrampoline
1146ENTRY art_quick_generic_jni_trampoline
1147 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1148 move $s8, $sp # save $sp to $s8
1149 move $s3, $gp # save $gp to $s3
1150
1151 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1152 move $a0, rSELF # pass Thread::Current
1153 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
1154 jal artQuickGenericJniTrampoline # (Thread*, SP)
1155 addiu $sp, $sp, -5120 # reserve space on the stack
1156
1157 # The C call will have registered the complete save-frame on success.
1158 # The result of the call is:
1159 # v0: ptr to native code, 0 on error.
1160 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1161 beq $v0, $zero, 1f # check entry error
1162 move $t9, $v0 # save the code ptr
1163 move $sp, $v1 # release part of the alloca
1164
1165 # Load parameters from stack into registers
1166 lw $a0, 0($sp)
1167 lw $a1, 4($sp)
1168 lw $a2, 8($sp)
1169
1170 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1171 jalr $t9 # native call
1172 lw $a3, 12($sp)
1173 addiu $sp, $sp, 16 # remove arg slots
1174
1175 move $gp, $s3 # restore $gp from $s3
1176
1177 # result sign extension is handled in C code
1178 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1179 move $a0, rSELF # pass Thread::Current
1180 move $a2, $v0 # pass result
1181 move $a3, $v1
1182 addiu $sp, $sp, -24 # reserve arg slots
1183 jal artQuickGenericJniEndTrampoline
1184 s.d $f0, 16($sp) # pass result_f
1185 addiu $sp, $sp, 24 # remove arg slots
1186
1187 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1188 bne $t0, $zero, 2f # check for pending exceptions
1189 move $sp, $s8 # tear down the alloca
1190
1191 # tear dpown the callee-save frame
1192 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1193
1194 mtc1 $v0, $f0 # place return value to FP return value
1195 jr $ra
1196 mtc1 $v1, $f1 # place return value to FP return value
1197
11981:
1199 move $sp, $s8 # tear down the alloca
12002:
1201 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1202 DELIVER_PENDING_EXCEPTION
1203END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001204
Ian Rogers468532e2013-08-05 10:56:33 -07001205 .extern artQuickToInterpreterBridge
1206ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001207 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001208 move $a1, rSELF # pass Thread::Current
1209 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
1210 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08001211 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001212 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001213 bnez $t0, 1f
Douglas Leungb2649372014-06-02 17:45:54 -07001214 mtc1 $v0, $f0 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -08001215 jr $ra
Douglas Leungb2649372014-06-02 17:45:54 -07001216 mtc1 $v1, $f1 # place return value to FP return value
Ian Rogers7db619b2013-01-16 18:35:48 -080012171:
1218 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001219END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001220
buzbee5bc5a7b2012-03-07 15:52:59 -08001221 /*
jeffhao725a9572012-11-13 18:20:12 -08001222 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001223 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001224 .extern artInstrumentationMethodEntryFromCode
1225 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001226ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001227 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001228 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001229 move $a3, $ra # pass $ra
1230 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001231 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001232 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07001233 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001234 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001235 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001236 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001237END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001238 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001239 .global art_quick_instrumentation_exit
1240art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001241 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001242 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001243 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001244 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07001245
1246 addiu $sp, $sp, -16 # allocate temp storage on the stack
1247 .cfi_adjust_cfa_offset 16
1248 sw $v0, 12($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001249 .cfi_rel_offset 2, 32
Douglas Leung735b8552014-10-31 12:21:40 -07001250 sw $v1, 8($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001251 .cfi_rel_offset 3, 36
Douglas Leung735b8552014-10-31 12:21:40 -07001252 s.s $f0, 4($sp)
1253 s.s $f1, 0($sp)
1254 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Ian Rogers62d6c772013-02-27 08:32:07 -08001255 s.s $f0, 16($sp) # pass fpr result
1256 s.s $f1, 20($sp)
1257 move $a2, $v0 # pass gpr result
1258 move $a3, $v1
Douglas Leung735b8552014-10-31 12:21:40 -07001259 addiu $a1, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers62d6c772013-02-27 08:32:07 -08001260 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001261 move $a0, rSELF # pass Thread::Current
1262 move $t0, $v0 # set aside returned link register
1263 move $ra, $v1 # set link register for deoptimization
Douglas Leung735b8552014-10-31 12:21:40 -07001264 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE # args slot + refs_only callee save frame
1265 lw $v0, 12($sp) # restore return values
1266 lw $v1, 8($sp)
1267 l.s $f0, 4($sp)
1268 l.s $f1, 0($sp)
jeffhao12051ea2013-01-10 11:24:31 -08001269 jr $t0 # return
Douglas Leung735b8552014-10-31 12:21:40 -07001270 addiu $sp, $sp, 16 # remove temp storage from stack
1271 .cfi_adjust_cfa_offset -16
Ian Rogers468532e2013-08-05 10:56:33 -07001272END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001273
jeffhao12051ea2013-01-10 11:24:31 -08001274 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001275 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1276 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001277 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001278 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001279ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001280 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001281 jal artDeoptimize # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001282 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001283 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001284END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001285
buzbee5bc5a7b2012-03-07 15:52:59 -08001286 /*
1287 * Long integer shift. This is different from the generic 32/64-bit
1288 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1289 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1290 * 6 bits.
1291 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001292 * $a0: low word
1293 * $a1: high word
1294 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001295 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001296ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001297 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001298 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1299 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1300 srl $a0, 1
1301 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1302 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
1303 or $v1, $a0 # rhi<- rhi | alo
1304 andi $a2, 0x20 # shift< shift & 0x20
1305 movn $v1, $v0, $a2 # rhi<- rlo (if shift&0x20)
1306 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001307 movn $v0, $zero, $a2 # rlo<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001308END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001309
buzbee5bc5a7b2012-03-07 15:52:59 -08001310 /*
1311 * Long integer shift. This is different from the generic 32/64-bit
1312 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1313 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1314 * 6 bits.
1315 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001316 * $a0: low word
1317 * $a1: high word
1318 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001319 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001320ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001321 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1322 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1323 sra $a3, $a1, 31 # $a3<- sign(ah)
1324 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1325 sll $a1, 1
1326 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1327 or $v0, $a1 # rlo<- rlo | ahi
1328 andi $a2, 0x20 # shift & 0x20
1329 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1330 jr $ra
1331 movn $v1, $a3, $a2 # rhi<- sign(ahi) (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001332END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001333
buzbee5bc5a7b2012-03-07 15:52:59 -08001334 /*
1335 * Long integer shift. This is different from the generic 32/64-bit
1336 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1337 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1338 * 6 bits.
1339 * On entry:
1340 * r0: low word
1341 * r1: high word
1342 * r2: shift count
1343 */
1344 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001345ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001346 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001347 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001348 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1349 sll $a1, 1
1350 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
1351 or $v0, $a1 # rlo<- rlo | ahi
1352 andi $a2, 0x20 # shift & 0x20
1353 movn $v0, $v1, $a2 # rlo<- rhi (if shift&0x20)
1354 jr $ra
jeffhaofc6a30e2012-10-18 18:24:15 -07001355 movn $v1, $zero, $a2 # rhi<- 0 (if shift&0x20)
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001356END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001357
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001358UNIMPLEMENTED art_quick_indexof
1359UNIMPLEMENTED art_quick_string_compareto