blob: 16f0e70999bc71bbc66fcd009e5503e0610e01f3 [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
Andreas Gampe8d365912015-01-13 11:32:32 -0800157 jalr $zero, $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
Douglas Leungc6d86722014-12-10 16:15:17 -0800193 sw $a3, 24($sp)
194 .cfi_rel_offset 7, 24
195 sw $a2, 20($sp)
196 .cfi_rel_offset 6, 20
197 sw $a1, 16($sp)
198 .cfi_rel_offset 5, 16
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
Douglas Leungc6d86722014-12-10 16:15:17 -0800260 lw $a3, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800261 .cfi_restore 7
Douglas Leungc6d86722014-12-10 16:15:17 -0800262 lw $a2, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800263 .cfi_restore 6
Douglas Leungc6d86722014-12-10 16:15:17 -0800264 lw $a1, 16($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
Andreas Gampe8d365912015-01-13 11:32:32 -0800277 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700278 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
Andreas Gampe8d365912015-01-13 11:32:32 -0800286 jalr $zero, $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
Andreas Gampe8d365912015-01-13 11:32:32 -0800296 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800297 nop
2981:
299 DELIVER_PENDING_EXCEPTION
300.endm
301
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800302.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
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
Andreas Gampe8d365912015-01-13 11:32:32 -0800306 jalr $zero, $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
Duane Sande34652f2014-11-04 11:09:36 -0800317 LDu $f0, $f1, 0*8, $a1, $t1
318 LDu $f2, $f3, 1*8, $a1, $t1
319 LDu $f4, $f5, 2*8, $a1, $t1
320 LDu $f6, $f7, 3*8, $a1, $t1
321 LDu $f8, $f9, 4*8, $a1, $t1
322 LDu $f10, $f11, 5*8, $a1, $t1
323 LDu $f12, $f13, 6*8, $a1, $t1
324 LDu $f14, $f15, 7*8, $a1, $t1
325 LDu $f16, $f17, 8*8, $a1, $t1
326 LDu $f18, $f19, 9*8, $a1, $t1
327 LDu $f20, $f21, 10*8, $a1, $t1
328 LDu $f22, $f23, 11*8, $a1, $t1
329 LDu $f24, $f25, 12*8, $a1, $t1
330 LDu $f26, $f27, 13*8, $a1, $t1
331 LDu $f28, $f29, 14*8, $a1, $t1
332 LDu $f30, $f31, 15*8, $a1, $t1
333
Chris Dearman748dd952014-05-23 10:47:01 -0700334 .set push
335 .set nomacro
336 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700337 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700338 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700339 lw $v0, 8($a0)
340 lw $v1, 12($a0)
341 lw $a1, 20($a0)
342 lw $a2, 24($a0)
343 lw $a3, 28($a0)
344 lw $t0, 32($a0)
345 lw $t1, 36($a0)
346 lw $t2, 40($a0)
347 lw $t3, 44($a0)
348 lw $t4, 48($a0)
349 lw $t5, 52($a0)
350 lw $t6, 56($a0)
351 lw $t7, 60($a0)
352 lw $s0, 64($a0)
353 lw $s1, 68($a0)
354 lw $s2, 72($a0)
355 lw $s3, 76($a0)
356 lw $s4, 80($a0)
357 lw $s5, 84($a0)
358 lw $s6, 88($a0)
359 lw $s7, 92($a0)
360 lw $t8, 96($a0)
361 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700362 lw $gp, 112($a0)
363 lw $sp, 116($a0)
364 lw $fp, 120($a0)
365 lw $ra, 124($a0)
366 lw $a0, 16($a0)
367 move $v0, $zero # clear result registers r0 and r1
Andreas Gampe8d365912015-01-13 11:32:32 -0800368 jalr $zero, $ra # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700369 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800370END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800371
buzbee5bc5a7b2012-03-07 15:52:59 -0800372 /*
373 * Called by managed code, saves most registers (forms basis of long jump context) and passes
374 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
375 * the bottom of the thread. On entry r0 holds Throwable*
376 */
Ian Rogers468532e2013-08-05 10:56:33 -0700377ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700378 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700379 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800380 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700381 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700382END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800383
buzbee5bc5a7b2012-03-07 15:52:59 -0800384 /*
385 * Called by managed code to create and deliver a NullPointerException
386 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800387 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700388ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700389 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700390 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800391 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700392 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700393END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800394
buzbee5bc5a7b2012-03-07 15:52:59 -0800395 /*
396 * Called by managed code to create and deliver an ArithmeticException
397 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800398 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700399ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700400 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700401 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800402 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700403 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700404END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800405
buzbee5bc5a7b2012-03-07 15:52:59 -0800406 /*
407 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
408 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800409 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700410ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700411 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700412 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800413 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700414 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700415END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800416
Ian Rogers57b86d42012-03-27 16:05:41 -0700417 /*
418 * Called by managed code to create and deliver a StackOverflowError.
419 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800420 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700421ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700422 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700423 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800424 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700425 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700426END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800427
Ian Rogers57b86d42012-03-27 16:05:41 -0700428 /*
429 * Called by managed code to create and deliver a NoSuchMethodError.
430 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800431 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700432ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700433 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700434 la $t9, artThrowNoSuchMethodFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800435 jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700436 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700437END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800438
buzbee5bc5a7b2012-03-07 15:52:59 -0800439 /*
440 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700441 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
buzbee5bc5a7b2012-03-07 15:52:59 -0800442 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
443 * stack and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700444 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800445 *
jeffhao7fbee072012-08-24 17:56:54 -0700446 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
447 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800448 *
jeffhaofa147e22012-10-12 17:03:32 -0700449 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800450 * thread and we branch to another stub to deliver it.
451 *
452 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
453 * pointing back to the original caller.
454 */
455.macro INVOKE_TRAMPOLINE c_name, cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800456 .extern \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800457ENTRY \c_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700458 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Douglas Leung735b8552014-10-31 12:21:40 -0700459 lw $a2, FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE+ARG_SLOT_SIZE($sp) # pass caller Method*
460 addiu $t0, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -0700461 move $a3, rSELF # pass Thread::Current
jeffhao7fbee072012-08-24 17:56:54 -0700462 jal \cxx_name # (method_idx, this, caller, Thread*, $sp)
jeffhaofa147e22012-10-12 17:03:32 -0700463 sw $t0, 16($sp) # pass $sp
jeffhaofa147e22012-10-12 17:03:32 -0700464 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700465 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700466 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -0700467 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800468 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800469 nop
4701:
471 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800472END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800473.endm
474
Logan Chien8dbb7082013-01-25 20:31:17 +0800475INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
476INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800477
Logan Chien8dbb7082013-01-25 20:31:17 +0800478INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
479INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
480INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
481INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800482
Jeff Hao79fe5392013-04-24 18:41:58 -0700483 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800484 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800485 * On entry:
486 * a0 = method pointer
487 * a1 = argument array or NULL for no argument methods
488 * a2 = size of argument array in bytes
489 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700490 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800491 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800492 */
493ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800494 sw $a0, 0($sp) # save out a0
495 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
496 .cfi_adjust_cfa_offset 16
497 sw $ra, 12($sp)
498 .cfi_rel_offset 31, 12
499 sw $fp, 8($sp)
500 .cfi_rel_offset 30, 8
501 sw $s1, 4($sp)
502 .cfi_rel_offset 17, 4
503 sw $s0, 0($sp)
504 .cfi_rel_offset 16, 0
505 move $fp, $sp # save sp in fp
506 .cfi_def_cfa_register 30
507 move $s1, $a3 # move managed thread pointer into s1
508 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Douglas Leung735b8552014-10-31 12:21:40 -0700509 addiu $t0, $a2, 4 # create space for method pointer in frame.
510 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
511 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
512 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
Jeff Hao5d917302013-02-27 17:57:33 -0800513 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
514 jal memcpy # (dest, src, bytes)
515 addiu $sp, $sp, -16 # make space for argument slots for memcpy
516 addiu $sp, $sp, 16 # restore stack after memcpy
517 lw $a0, 16($fp) # restore method*
518 lw $a1, 4($sp) # copy arg value for a1
519 lw $a2, 8($sp) # copy arg value for a2
520 lw $a3, 12($sp) # copy arg value for a3
Mathieu Chartier2d721012014-11-10 11:08:06 -0800521 lw $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800522 jalr $t9 # call the method
523 sw $zero, 0($sp) # store NULL for method* at bottom of frame
524 move $sp, $fp # restore the stack
525 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800526 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800527 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800528 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800529 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800530 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800531 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800532 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800533 addiu $sp, $sp, 16
534 .cfi_adjust_cfa_offset -16
535 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800536 lw $t1, 20($sp) # get shorty
537 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700538 li $t2, 68 # put char 'D' into t2
539 beq $t1, $t2, 1f # branch if result type char == 'D'
540 li $t3, 70 # put char 'F' into t3
541 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800542 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -0800543 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800544 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005451:
Duane Sande34652f2014-11-04 11:09:36 -0800546 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -0800547 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -0800548 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800549END art_quick_invoke_stub
550
551 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800552 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
553 * failure.
554 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800555 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700556ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -0700557 lw $a2, 0($sp) # pass referrer's Method*
558 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700559 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700560 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700561 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700562END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800563
buzbee5bc5a7b2012-03-07 15:52:59 -0800564 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700565 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800566 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800567 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700568ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800569 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700570 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700571 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700572 jal artLockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700573 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700574 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700575END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800576
buzbee5bc5a7b2012-03-07 15:52:59 -0800577 /*
578 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
579 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800580 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700581ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800582 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700583 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700584 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700585 jal artUnlockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700586 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800587 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700588END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800589
buzbee5bc5a7b2012-03-07 15:52:59 -0800590 /*
591 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
592 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700593 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700594ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700595 addiu $sp, $sp, -16
596 .cfi_adjust_cfa_offset 16
597 sw $ra, 12($sp)
598 .cfi_rel_offset 31, 12
599 sw $t9, 8($sp)
600 sw $a1, 4($sp)
601 sw $a0, 0($sp)
602 jal artIsAssignableFromCode
Douglas Leung735b8552014-10-31 12:21:40 -0700603 addiu $sp, $sp, -16 # reserve argument slots on the stack
604 addiu $sp, $sp, 16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800605 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700606 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -0800607 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700608 addiu $sp, $sp, 16
609 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800610.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700611 lw $t9, 8($sp)
612 lw $a1, 4($sp)
613 lw $a0, 0($sp)
614 addiu $sp, $sp, 16
615 .cfi_adjust_cfa_offset -16
616 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700617 la $t9, artThrowClassCastException
Andreas Gampe8d365912015-01-13 11:32:32 -0800618 jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700619 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700620END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800621
buzbee5bc5a7b2012-03-07 15:52:59 -0800622 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700623 * Entry from managed code for array put operations of objects where the value being stored
624 * needs to be checked for compatibility.
625 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800626 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700627ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800628 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700629 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800630 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700631 nop
632END art_quick_aput_obj_with_null_and_bound_check
633
634ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700635 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700636 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800637 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700638 nop
639 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800640 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700641 move $a1, $t0
642END art_quick_aput_obj_with_bound_check
643
644ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800645 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700646 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700647 lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
648 lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
649 lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800650 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700651 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800652.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700653 sll $a1, $a1, 2
654 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700655 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700656 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
657 srl $t1, $a0, 7
658 add $t1, $t1, $t0
659 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -0800660 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700661 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800662.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700663 sll $a1, $a1, 2
664 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700665 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -0800666 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700667 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800668.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700669 addiu $sp, $sp, -32
670 .cfi_adjust_cfa_offset 32
671 sw $ra, 28($sp)
672 .cfi_rel_offset 31, 28
673 sw $t9, 12($sp)
674 sw $a2, 8($sp)
675 sw $a1, 4($sp)
676 sw $a0, 0($sp)
677 move $a1, $t1
678 move $a0, $t0
679 jal artIsAssignableFromCode # (Class*, Class*)
Douglas Leung735b8552014-10-31 12:21:40 -0700680 addiu $sp, $sp, -16 # reserve argument slots on the stack
681 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -0700682 lw $ra, 28($sp)
683 lw $t9, 12($sp)
684 lw $a2, 8($sp)
685 lw $a1, 4($sp)
686 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -0800687 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -0700688 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800689 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700690 nop
691 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
692 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -0700693 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -0800694 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700695 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -0700696END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800697
buzbee5bc5a7b2012-03-07 15:52:59 -0800698 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700699 * Called by managed code to resolve a static field and load a boolean primitive value.
700 */
701 .extern artGetBooleanStaticFromCode
702ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -0700703 lw $a1, 0($sp) # pass referrer's Method*
704 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700705 jal artGetBooleanStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700706 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700707 RETURN_IF_NO_EXCEPTION
708END art_quick_get_boolean_static
709 /*
710 * Called by managed code to resolve a static field and load a byte primitive value.
711 */
712 .extern artGetByteStaticFromCode
713ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -0700714 lw $a1, 0($sp) # pass referrer's Method*
715 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700716 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700717 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700718 RETURN_IF_NO_EXCEPTION
719END art_quick_get_byte_static
720
721 /*
722 * Called by managed code to resolve a static field and load a char primitive value.
723 */
724 .extern artGetCharStaticFromCode
725ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -0700726 lw $a1, 0($sp) # pass referrer's Method*
727 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700728 jal artGetCharStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700729 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700730 RETURN_IF_NO_EXCEPTION
731END art_quick_get_char_static
732 /*
733 * Called by managed code to resolve a static field and load a short primitive value.
734 */
735 .extern artGetShortStaticFromCode
736ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -0700737 lw $a1, 0($sp) # pass referrer's Method*
738 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700739 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700740 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700741 RETURN_IF_NO_EXCEPTION
742END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800743
buzbee5bc5a7b2012-03-07 15:52:59 -0800744 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700745 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800746 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800747 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700748ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700749 lw $a1, 0($sp) # pass referrer's Method*
750 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700751 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700752 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800753 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700754END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800755
buzbee5bc5a7b2012-03-07 15:52:59 -0800756 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700757 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800758 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800759 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700760ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700761 lw $a1, 0($sp) # pass referrer's Method*
762 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700763 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700764 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800765 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700766END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800767
buzbee5bc5a7b2012-03-07 15:52:59 -0800768 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700769 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800770 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800771 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700772ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700773 lw $a1, 0($sp) # pass referrer's Method*
774 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700775 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700776 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800777 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700778END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800779
buzbee5bc5a7b2012-03-07 15:52:59 -0800780 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700781 * Called by managed code to resolve an instance field and load a boolean primitive value.
782 */
783 .extern artGetBooleanInstanceFromCode
784ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700785 lw $a2, 0($sp) # pass referrer's Method*
786 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700787 jal artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700788 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700789 RETURN_IF_NO_EXCEPTION
790END art_quick_get_boolean_instance
791 /*
792 * Called by managed code to resolve an instance field and load a byte primitive value.
793 */
794 .extern artGetByteInstanceFromCode
795ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700796 lw $a2, 0($sp) # pass referrer's Method*
797 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700798 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700799 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700800 RETURN_IF_NO_EXCEPTION
801END art_quick_get_byte_instance
802
803 /*
804 * Called by managed code to resolve an instance field and load a char primitive value.
805 */
806 .extern artGetCharInstanceFromCode
807ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700808 lw $a2, 0($sp) # pass referrer's Method*
809 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700810 jal artGetCharInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700811 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700812 RETURN_IF_NO_EXCEPTION
813END art_quick_get_char_instance
814 /*
815 * Called by managed code to resolve an instance field and load a short primitive value.
816 */
817 .extern artGetShortInstanceFromCode
818ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700819 lw $a2, 0($sp) # pass referrer's Method*
820 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
821 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700822 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700823 RETURN_IF_NO_EXCEPTION
824END art_quick_get_short_instance
825
826 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700827 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800828 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800829 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700830ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700831 lw $a2, 0($sp) # pass referrer's Method*
832 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
833 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700834 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800835 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700836END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800837
buzbee5bc5a7b2012-03-07 15:52:59 -0800838 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700839 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800840 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800841 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700842ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700843 lw $a2, 0($sp) # pass referrer's Method*
844 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
845 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700846 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800847 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700848END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800849
buzbee5bc5a7b2012-03-07 15:52:59 -0800850 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700851 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800852 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800853 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700854ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700855 lw $a2, 0($sp) # pass referrer's Method*
856 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700857 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700858 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800859 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700860END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800861
buzbee5bc5a7b2012-03-07 15:52:59 -0800862 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700863 * Called by managed code to resolve a static field and store a 8-bit primitive value.
864 */
865 .extern artSet8StaticFromCode
866ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -0700867 lw $a2, 0($sp) # pass referrer's Method*
868 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700869 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700870 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700871 RETURN_IF_ZERO
872END art_quick_set8_static
873
874 /*
875 * Called by managed code to resolve a static field and store a 16-bit primitive value.
876 */
877 .extern artSet16StaticFromCode
878ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -0700879 lw $a2, 0($sp) # pass referrer's Method*
880 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Fred Shih37f05ef2014-07-16 18:38:08 -0700881 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700882 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700883 RETURN_IF_ZERO
884END art_quick_set16_static
885
886 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700887 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800888 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800889 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700890ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700891 lw $a2, 0($sp) # pass referrer's Method*
892 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700893 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700894 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800895 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700896END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800897
buzbee5bc5a7b2012-03-07 15:52:59 -0800898 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700899 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800900 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700901 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700902ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700903 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -0800904 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -0700905 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700906 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700907 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800908 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700909END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800910
buzbee5bc5a7b2012-03-07 15:52:59 -0800911 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700912 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800913 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800914 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700915ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700916 lw $a2, 0($sp) # pass referrer's Method*
917 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao7fbee072012-08-24 17:56:54 -0700918 move $a3, rSELF # pass Thread::Current
Douglas Leung735b8552014-10-31 12:21:40 -0700919 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800920 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700921END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800922
buzbee5bc5a7b2012-03-07 15:52:59 -0800923 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700924 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
925 */
926 .extern artSet8InstanceFromCode
927ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700928 lw $a3, 0($sp) # pass referrer's Method*
929 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
930 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700931 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700932 RETURN_IF_ZERO
933END art_quick_set8_instance
934
935 /*
936 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
937 */
938 .extern artSet16InstanceFromCode
939ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700940 lw $a3, 0($sp) # pass referrer's Method*
941 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700942 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700943 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700944 RETURN_IF_ZERO
945END art_quick_set16_instance
946
947 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700948 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800949 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800950 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700951ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700952 lw $a3, 0($sp) # pass referrer's Method*
953 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700954 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700955 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800956 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700957END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800958
buzbee5bc5a7b2012-03-07 15:52:59 -0800959 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700960 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800961 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700962 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700963ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700964 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -0800965 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -0700966 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700967 sw rSELF, 20($sp) # pass Thread::Current
968 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -0700969 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800970 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700971END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800972
buzbee5bc5a7b2012-03-07 15:52:59 -0800973 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700974 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800975 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800976 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700977ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700978 lw $a3, 0($sp) # pass referrer's Method*
979 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700980 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700981 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800982 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700983END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800984
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800985// Macro to facilitate adding new allocation entrypoints.
986.macro TWO_ARG_DOWNCALL name, entrypoint, return
987 .extern \entrypoint
988ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -0700989 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800990 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700991 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800992 \return
993END \name
994.endm
buzbee5bc5a7b2012-03-07 15:52:59 -0800995
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800996.macro THREE_ARG_DOWNCALL name, entrypoint, return
997 .extern \entrypoint
998ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -0700999 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001000 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001001 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001002 \return
1003END \name
1004.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001005
Mathieu Chartier7410f292013-11-24 13:17:35 -08001006// Generate the allocation entrypoints for each allocator.
1007GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001008
buzbee5bc5a7b2012-03-07 15:52:59 -08001009 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001010 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
1011 * exception on error. On success the String is returned. R0 holds the referring method,
1012 * R1 holds the string index. The fast path check for hit in strings cache has already been
1013 * performed.
1014 */
1015TWO_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1016
1017 /*
1018 * Entry from managed code when uninitialized static storage, this stub will run the class
1019 * initializer and deliver the exception on error. On success the static storage base is
1020 * returned.
1021 */
1022TWO_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1023
1024 /*
1025 * Entry from managed code when dex cache misses for a type_idx.
1026 */
1027TWO_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1028
1029 /*
1030 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1031 * miss.
1032 */
1033TWO_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1034
1035 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001036 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001037 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001038 .extern artTestSuspendFromCode
1039ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001040 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001041 bnez $a0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001042 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001043 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001044 nop
10451:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001046 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1047 jal artTestSuspendFromCode # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001048 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001049 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001050END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001051
buzbee5bc5a7b2012-03-07 15:52:59 -08001052 /*
1053 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001054 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001055 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001056 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001057ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001058 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1059 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001060 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001061 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001062 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001063 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001064 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001065 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1066 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001067 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001068 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080010691:
1070 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001071END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001072
Jeff Hao88474b42013-10-23 16:24:40 -07001073 /*
1074 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1075 * dex method index.
1076 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001077ENTRY art_quick_imt_conflict_trampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001078 lw $a0, 0($sp) # load caller Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001079 lw $a0, MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET($a0) # load dex_cache_resolved_methods
Jeff Hao88474b42013-10-23 16:24:40 -07001080 sll $t0, 2 # convert target method offset to bytes
1081 add $a0, $t0 # get address of target method
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001082 lw $a0, MIRROR_OBJECT_ARRAY_DATA_OFFSET($a0) # load the target method
Jeff Hao88474b42013-10-23 16:24:40 -07001083 la $t9, art_quick_invoke_interface_trampoline
Andreas Gampe8d365912015-01-13 11:32:32 -08001084 jalr $zero, $t9
Jeff Hao88474b42013-10-23 16:24:40 -07001085END art_quick_imt_conflict_trampoline
1086
Ian Rogers468532e2013-08-05 10:56:33 -07001087 .extern artQuickResolutionTrampoline
1088ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001089 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001090 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001091 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001092 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001093 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001094 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001095 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001096 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Andreas Gampe8d365912015-01-13 11:32:32 -08001097 jalr $zero, $v0 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001098 nop
Ian Rogers468532e2013-08-05 10:56:33 -070010991:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001100 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001101 DELIVER_PENDING_EXCEPTION
1102END art_quick_resolution_trampoline
1103
Douglas Leung735b8552014-10-31 12:21:40 -07001104 .extern artQuickGenericJniTrampoline
1105 .extern artQuickGenericJniEndTrampoline
1106ENTRY art_quick_generic_jni_trampoline
1107 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1108 move $s8, $sp # save $sp to $s8
1109 move $s3, $gp # save $gp to $s3
1110
1111 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1112 move $a0, rSELF # pass Thread::Current
1113 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
1114 jal artQuickGenericJniTrampoline # (Thread*, SP)
1115 addiu $sp, $sp, -5120 # reserve space on the stack
1116
1117 # The C call will have registered the complete save-frame on success.
1118 # The result of the call is:
1119 # v0: ptr to native code, 0 on error.
1120 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1121 beq $v0, $zero, 1f # check entry error
1122 move $t9, $v0 # save the code ptr
1123 move $sp, $v1 # release part of the alloca
1124
1125 # Load parameters from stack into registers
1126 lw $a0, 0($sp)
1127 lw $a1, 4($sp)
1128 lw $a2, 8($sp)
1129
1130 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1131 jalr $t9 # native call
1132 lw $a3, 12($sp)
1133 addiu $sp, $sp, 16 # remove arg slots
1134
1135 move $gp, $s3 # restore $gp from $s3
1136
1137 # result sign extension is handled in C code
1138 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1139 move $a0, rSELF # pass Thread::Current
1140 move $a2, $v0 # pass result
1141 move $a3, $v1
1142 addiu $sp, $sp, -24 # reserve arg slots
1143 jal artQuickGenericJniEndTrampoline
1144 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001145
1146 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001147 bne $t0, $zero, 1f # check for pending exceptions
1148
Douglas Leung735b8552014-10-31 12:21:40 -07001149 move $sp, $s8 # tear down the alloca
1150
1151 # tear dpown the callee-save frame
1152 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1153
Duane Sande34652f2014-11-04 11:09:36 -08001154 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001155 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001156 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001157
11581:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001159 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1160 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07001161 DELIVER_PENDING_EXCEPTION
1162END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001163
Ian Rogers468532e2013-08-05 10:56:33 -07001164 .extern artQuickToInterpreterBridge
1165ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001166 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001167 move $a1, rSELF # pass Thread::Current
1168 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
1169 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08001170 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001171 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001172 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001173 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1174 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001175 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001176 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080011771:
1178 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001179END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001180
buzbee5bc5a7b2012-03-07 15:52:59 -08001181 /*
jeffhao725a9572012-11-13 18:20:12 -08001182 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001183 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001184 .extern artInstrumentationMethodEntryFromCode
1185 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001186ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001187 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001188 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001189 move $a3, $ra # pass $ra
1190 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001191 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001192 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07001193 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001194 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001195 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001196 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001197END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001198 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001199 .global art_quick_instrumentation_exit
1200art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001201 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001202 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001203 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001204 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07001205
1206 addiu $sp, $sp, -16 # allocate temp storage on the stack
1207 .cfi_adjust_cfa_offset 16
1208 sw $v0, 12($sp)
Douglas Leungc3d131e2014-07-16 17:32:41 -07001209 .cfi_rel_offset 2, 32
Douglas Leung735b8552014-10-31 12:21:40 -07001210 sw $v1, 8($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001211 .cfi_rel_offset 3, 36
1212 s.d $f0, 0($sp)
Douglas Leung735b8552014-10-31 12:21:40 -07001213 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Duane Sande34652f2014-11-04 11:09:36 -08001214 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08001215 move $a2, $v0 # pass gpr result
1216 move $a3, $v1
Douglas Leung735b8552014-10-31 12:21:40 -07001217 addiu $a1, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers62d6c772013-02-27 08:32:07 -08001218 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001219 move $a0, rSELF # pass Thread::Current
1220 move $t0, $v0 # set aside returned link register
1221 move $ra, $v1 # set link register for deoptimization
Douglas Leung735b8552014-10-31 12:21:40 -07001222 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE # args slot + refs_only callee save frame
1223 lw $v0, 12($sp) # restore return values
1224 lw $v1, 8($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001225 l.d $f0, 0($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -08001226 jalr $zero, $t0 # return
Douglas Leung735b8552014-10-31 12:21:40 -07001227 addiu $sp, $sp, 16 # remove temp storage from stack
1228 .cfi_adjust_cfa_offset -16
Ian Rogers468532e2013-08-05 10:56:33 -07001229END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001230
jeffhao12051ea2013-01-10 11:24:31 -08001231 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001232 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1233 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001234 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001235 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001236ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001237 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001238 jal artDeoptimize # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001239 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001240 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001241END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001242
buzbee5bc5a7b2012-03-07 15:52:59 -08001243 /*
1244 * Long integer shift. This is different from the generic 32/64-bit
1245 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1246 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1247 * 6 bits.
1248 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001249 * $a0: low word
1250 * $a1: high word
1251 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001252 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001253ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001254 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001255 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1256 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1257 srl $a0, 1
1258 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1259 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001260 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001261 beqz $a2, 1f
1262 or $v1, $a0 # rhi<- rhi | alo
1263
1264 move $v1, $v0 # rhi<- rlo (if shift&0x20)
1265 move $v0, $zero # rlo<- 0 (if shift&0x20)
1266
Andreas Gampe8d365912015-01-13 11:32:32 -080012671: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001268 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001269END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001270
buzbee5bc5a7b2012-03-07 15:52:59 -08001271 /*
1272 * Long integer shift. This is different from the generic 32/64-bit
1273 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1274 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1275 * 6 bits.
1276 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001277 * $a0: low word
1278 * $a1: high word
1279 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001280 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001281ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001282 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1283 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1284 sra $a3, $a1, 31 # $a3<- sign(ah)
1285 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1286 sll $a1, 1
1287 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001288 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08001289 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001290 or $v0, $a1 # rlo<- rlo | ahi
1291
1292 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1293 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
1294
Andreas Gampe8d365912015-01-13 11:32:32 -080012951: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001296 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001297END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001298
buzbee5bc5a7b2012-03-07 15:52:59 -08001299 /*
1300 * Long integer shift. This is different from the generic 32/64-bit
1301 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1302 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1303 * 6 bits.
1304 * On entry:
1305 * r0: low word
1306 * r1: high word
1307 * r2: shift count
1308 */
1309 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001310ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001311 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001312 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001313 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1314 sll $a1, 1
1315 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001316 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001317 beqz $a2, 1f
1318 or $v0, $a1 # rlo<- rlo | ahi
1319
1320 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1321 move $v1, $zero # rhi<- 0 (if shift&0x20)
1322
Andreas Gampe8d365912015-01-13 11:32:32 -080013231: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001324 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001325END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001326
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001327UNIMPLEMENTED art_quick_indexof
1328UNIMPLEMENTED art_quick_string_compareto