blob: 2819f92a0d4f125281d39541c76fa2cadeda80b5 [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
Andreas Gampea4e0e672015-05-27 18:31:42 -070040 addiu $sp, $sp, -96
41 .cfi_adjust_cfa_offset 96
Andreas Gampe5c1e4352014-04-21 19:28:24 -070042
43 // Ugly compile-time check, but we only have the preprocessor.
Andreas Gampea4e0e672015-05-27 18:31:42 -070044#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 96)
Andreas Gampe5c1e4352014-04-21 19:28:24 -070045#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
46#endif
47
Andreas Gampea4e0e672015-05-27 18:31:42 -070048 sw $ra, 92($sp)
49 .cfi_rel_offset 31, 92
50 sw $s8, 88($sp)
51 .cfi_rel_offset 30, 88
52 sw $gp, 84($sp)
53 .cfi_rel_offset 28, 84
54 sw $s7, 80($sp)
55 .cfi_rel_offset 23, 80
56 sw $s6, 76($sp)
57 .cfi_rel_offset 22, 76
58 sw $s5, 72($sp)
59 .cfi_rel_offset 21, 72
60 sw $s4, 68($sp)
61 .cfi_rel_offset 20, 68
62 sw $s3, 64($sp)
63 .cfi_rel_offset 19, 64
64 sw $s2, 60($sp)
65 .cfi_rel_offset 18, 60
66 sw $s1, 56($sp)
67 .cfi_rel_offset 17, 56
68 sw $s0, 52($sp)
69 .cfi_rel_offset 16, 52
70
71 SDu $f30, $f31, 44, $sp, $t1
72 SDu $f28, $f29, 36, $sp, $t1
73 SDu $f26, $f27, 28, $sp, $t1
74 SDu $f24, $f25, 20, $sp, $t1
75 SDu $f22, $f23, 12, $sp, $t1
76 SDu $f20, $f21, 4, $sp, $t1
77
Douglas Leung735b8552014-10-31 12:21:40 -070078 # 1 word for holding Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070079
Douglas Leung4af77b72014-10-22 16:32:28 -070080 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
81 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070082 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -070083 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070084 sw $t0, 0($sp) # Place Method* at bottom of stack.
85 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -070086 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
87 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -080088.endm
89
90 /*
91 * Macro that sets up the callee save frame to conform with
92 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
93 * Does not include rSUSPEND or rSELF
Douglas Leung735b8552014-10-31 12:21:40 -070094 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
95 * Clobbers $t0 and $sp
96 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
97 * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080098 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070099.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700100 addiu $sp, $sp, -48
101 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700102
103 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -0700104#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700105#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
106#endif
107
Douglas Leung735b8552014-10-31 12:21:40 -0700108 sw $ra, 44($sp)
109 .cfi_rel_offset 31, 44
110 sw $s8, 40($sp)
111 .cfi_rel_offset 30, 40
112 sw $gp, 36($sp)
113 .cfi_rel_offset 28, 36
114 sw $s7, 32($sp)
115 .cfi_rel_offset 23, 32
116 sw $s6, 28($sp)
117 .cfi_rel_offset 22, 28
118 sw $s5, 24($sp)
119 .cfi_rel_offset 21, 24
120 sw $s4, 20($sp)
121 .cfi_rel_offset 20, 20
122 sw $s3, 16($sp)
123 .cfi_rel_offset 19, 16
124 sw $s2, 12($sp)
125 .cfi_rel_offset 18, 12
126 # 2 words for alignment and bottom word will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700127
Douglas Leung4af77b72014-10-22 16:32:28 -0700128 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
129 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700130 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700131 lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700132 sw $t0, 0($sp) # Place Method* at bottom of stack.
133 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700134 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
135 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800136.endm
137
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700138.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700139 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
140 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
141 lw $ra, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800142 .cfi_restore 31
Douglas Leung735b8552014-10-31 12:21:40 -0700143 lw $s8, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800144 .cfi_restore 30
Douglas Leung735b8552014-10-31 12:21:40 -0700145 lw $gp, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800146 .cfi_restore 28
Douglas Leung735b8552014-10-31 12:21:40 -0700147 lw $s7, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800148 .cfi_restore 23
Douglas Leung735b8552014-10-31 12:21:40 -0700149 lw $s6, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800150 .cfi_restore 22
Douglas Leung735b8552014-10-31 12:21:40 -0700151 lw $s5, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800152 .cfi_restore 21
Douglas Leung735b8552014-10-31 12:21:40 -0700153 lw $s4, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800154 .cfi_restore 20
Douglas Leung735b8552014-10-31 12:21:40 -0700155 lw $s3, 16($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800156 .cfi_restore 19
Douglas Leung735b8552014-10-31 12:21:40 -0700157 lw $s2, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800158 .cfi_restore 18
Douglas Leung735b8552014-10-31 12:21:40 -0700159 addiu $sp, $sp, 48
160 .cfi_adjust_cfa_offset -48
buzbee5bc5a7b2012-03-07 15:52:59 -0800161.endm
162
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700163.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Douglas Leung735b8552014-10-31 12:21:40 -0700164 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Andreas Gampe8d365912015-01-13 11:32:32 -0800165 jalr $zero, $ra
Douglas Leung735b8552014-10-31 12:21:40 -0700166 nop
buzbee5bc5a7b2012-03-07 15:52:59 -0800167.endm
168
169 /*
170 * Macro that sets up the callee save frame to conform with
Douglas Leung735b8552014-10-31 12:21:40 -0700171 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700172 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800173 */
Douglas Leung735b8552014-10-31 12:21:40 -0700174.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700175 addiu $sp, $sp, -64
176 .cfi_adjust_cfa_offset 64
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700177
178 // Ugly compile-time check, but we only have the preprocessor.
179#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
180#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
181#endif
182
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700183 sw $ra, 60($sp)
184 .cfi_rel_offset 31, 60
185 sw $s8, 56($sp)
186 .cfi_rel_offset 30, 56
187 sw $gp, 52($sp)
188 .cfi_rel_offset 28, 52
189 sw $s7, 48($sp)
190 .cfi_rel_offset 23, 48
191 sw $s6, 44($sp)
192 .cfi_rel_offset 22, 44
193 sw $s5, 40($sp)
194 .cfi_rel_offset 21, 40
195 sw $s4, 36($sp)
196 .cfi_rel_offset 20, 36
197 sw $s3, 32($sp)
198 .cfi_rel_offset 19, 32
199 sw $s2, 28($sp)
200 .cfi_rel_offset 18, 28
Douglas Leungc6d86722014-12-10 16:15:17 -0800201 sw $a3, 24($sp)
202 .cfi_rel_offset 7, 24
203 sw $a2, 20($sp)
204 .cfi_rel_offset 6, 20
205 sw $a1, 16($sp)
206 .cfi_rel_offset 5, 16
jeffhaofa147e22012-10-12 17:03:32 -0700207 # bottom will hold Method*
Douglas Leung735b8552014-10-31 12:21:40 -0700208.endm
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700209
Douglas Leung735b8552014-10-31 12:21:40 -0700210 /*
211 * Macro that sets up the callee save frame to conform with
212 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
213 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
214 * Clobbers $t0 and $sp
215 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
216 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
217 */
218.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
219 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Douglas Leung4af77b72014-10-22 16:32:28 -0700220 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
221 lw $t0, 0($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700222 THIS_LOAD_REQUIRES_READ_BARRIER
Douglas Leung4af77b72014-10-22 16:32:28 -0700223 lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700224 sw $t0, 0($sp) # Place Method* at bottom of stack.
225 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700226 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
227 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
228.endm
229
230 /*
231 * Macro that sets up the callee save frame to conform with
232 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
233 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
234 * Clobbers $sp
235 * Use $a0 as the Method* and loads it into bottom of stack.
236 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
237 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
238 */
239.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
240 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
241 sw $a0, 0($sp) # Place Method* at bottom of stack.
242 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
243 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
244 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800245.endm
246
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700247.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700248 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
249 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700250 lw $ra, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800251 .cfi_restore 31
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700252 lw $s8, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800253 .cfi_restore 30
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700254 lw $gp, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800255 .cfi_restore 28
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700256 lw $s7, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800257 .cfi_restore 23
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700258 lw $s6, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800259 .cfi_restore 22
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700260 lw $s5, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800261 .cfi_restore 21
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700262 lw $s4, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800263 .cfi_restore 20
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700264 lw $s3, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800265 .cfi_restore 19
Mathieu Chartier2a6c7b72013-10-16 11:16:33 -0700266 lw $s2, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800267 .cfi_restore 18
Douglas Leungc6d86722014-12-10 16:15:17 -0800268 lw $a3, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800269 .cfi_restore 7
Douglas Leungc6d86722014-12-10 16:15:17 -0800270 lw $a2, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800271 .cfi_restore 6
Douglas Leungc6d86722014-12-10 16:15:17 -0800272 lw $a1, 16($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800273 .cfi_restore 5
Ian Rogers468532e2013-08-05 10:56:33 -0700274 addiu $sp, $sp, 64 # pop frame
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700275 .cfi_adjust_cfa_offset -64
buzbee5bc5a7b2012-03-07 15:52:59 -0800276.endm
277
278 /*
279 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
280 * exception is Thread::Current()->exception_
281 */
282.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700283 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700284 la $t9, artDeliverPendingExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800285 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700286 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800287.endm
288
289.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700290 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700291 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700292 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800293 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800294 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800295 nop
2961:
297 DELIVER_PENDING_EXCEPTION
298.endm
299
300.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700301 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700302 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800303 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800304 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800305 nop
3061:
307 DELIVER_PENDING_EXCEPTION
308.endm
309
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800310.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700311 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700312 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800313 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800314 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800315 nop
3161:
317 DELIVER_PENDING_EXCEPTION
318.endm
319
buzbee5bc5a7b2012-03-07 15:52:59 -0800320 /*
jeffhao7fbee072012-08-24 17:56:54 -0700321 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800322 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
323 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800324ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800325 LDu $f0, $f1, 0*8, $a1, $t1
326 LDu $f2, $f3, 1*8, $a1, $t1
327 LDu $f4, $f5, 2*8, $a1, $t1
328 LDu $f6, $f7, 3*8, $a1, $t1
329 LDu $f8, $f9, 4*8, $a1, $t1
330 LDu $f10, $f11, 5*8, $a1, $t1
331 LDu $f12, $f13, 6*8, $a1, $t1
332 LDu $f14, $f15, 7*8, $a1, $t1
333 LDu $f16, $f17, 8*8, $a1, $t1
334 LDu $f18, $f19, 9*8, $a1, $t1
335 LDu $f20, $f21, 10*8, $a1, $t1
336 LDu $f22, $f23, 11*8, $a1, $t1
337 LDu $f24, $f25, 12*8, $a1, $t1
338 LDu $f26, $f27, 13*8, $a1, $t1
339 LDu $f28, $f29, 14*8, $a1, $t1
340 LDu $f30, $f31, 15*8, $a1, $t1
341
Chris Dearman748dd952014-05-23 10:47:01 -0700342 .set push
343 .set nomacro
344 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700345 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700346 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700347 lw $v0, 8($a0)
348 lw $v1, 12($a0)
349 lw $a1, 20($a0)
350 lw $a2, 24($a0)
351 lw $a3, 28($a0)
352 lw $t0, 32($a0)
353 lw $t1, 36($a0)
354 lw $t2, 40($a0)
355 lw $t3, 44($a0)
356 lw $t4, 48($a0)
357 lw $t5, 52($a0)
358 lw $t6, 56($a0)
359 lw $t7, 60($a0)
360 lw $s0, 64($a0)
361 lw $s1, 68($a0)
362 lw $s2, 72($a0)
363 lw $s3, 76($a0)
364 lw $s4, 80($a0)
365 lw $s5, 84($a0)
366 lw $s6, 88($a0)
367 lw $s7, 92($a0)
368 lw $t8, 96($a0)
369 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700370 lw $gp, 112($a0)
371 lw $sp, 116($a0)
372 lw $fp, 120($a0)
373 lw $ra, 124($a0)
374 lw $a0, 16($a0)
375 move $v0, $zero # clear result registers r0 and r1
Andreas Gampe8d365912015-01-13 11:32:32 -0800376 jalr $zero, $ra # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700377 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800378END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800379
buzbee5bc5a7b2012-03-07 15:52:59 -0800380 /*
381 * Called by managed code, saves most registers (forms basis of long jump context) and passes
382 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
Lazar Trsic84bc06e2015-06-10 16:05:46 +0200383 * the bottom of the thread. On entry a0 holds Throwable*
buzbee5bc5a7b2012-03-07 15:52:59 -0800384 */
Ian Rogers468532e2013-08-05 10:56:33 -0700385ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700386 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700387 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800388 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700389 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700390END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800391
buzbee5bc5a7b2012-03-07 15:52:59 -0800392 /*
393 * Called by managed code to create and deliver a NullPointerException
394 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800395 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700396ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700397 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700398 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800399 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700400 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700401END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800402
buzbee5bc5a7b2012-03-07 15:52:59 -0800403 /*
404 * Called by managed code to create and deliver an ArithmeticException
405 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800406 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700407ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700408 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700409 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800410 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700411 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700412END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800413
buzbee5bc5a7b2012-03-07 15:52:59 -0800414 /*
415 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
416 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800417 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700418ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700419 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700420 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800421 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700422 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700423END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800424
Ian Rogers57b86d42012-03-27 16:05:41 -0700425 /*
426 * Called by managed code to create and deliver a StackOverflowError.
427 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800428 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700429ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700430 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700431 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800432 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700433 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700434END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800435
Ian Rogers57b86d42012-03-27 16:05:41 -0700436 /*
437 * Called by managed code to create and deliver a NoSuchMethodError.
438 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800439 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700440ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700441 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700442 la $t9, artThrowNoSuchMethodFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800443 jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700444 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700445END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800446
buzbee5bc5a7b2012-03-07 15:52:59 -0800447 /*
448 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700449 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100450 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700451 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800452 *
jeffhao7fbee072012-08-24 17:56:54 -0700453 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
454 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800455 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700456 * If unsuccessful, the helper will return null/null. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800457 * thread and we branch to another stub to deliver it.
458 *
459 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
460 * pointing back to the original caller.
461 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700462.macro INVOKE_TRAMPOLINE_BODY cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800463 .extern \cxx_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700464 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100465 move $a2, rSELF # pass Thread::Current
466 jal \cxx_name # (method_idx, this, Thread*, $sp)
467 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
468 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700469 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700470 beqz $v0, 1f
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100471 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800472 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800473 nop
4741:
475 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700476.endm
477.macro INVOKE_TRAMPOLINE c_name, cxx_name
478ENTRY \c_name
479 INVOKE_TRAMPOLINE_BODY \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800480END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800481.endm
482
Logan Chien8dbb7082013-01-25 20:31:17 +0800483INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800484
Logan Chien8dbb7082013-01-25 20:31:17 +0800485INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
486INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
487INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
488INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800489
Jeff Hao79fe5392013-04-24 18:41:58 -0700490 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800491 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800492 * On entry:
493 * a0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700494 * a1 = argument array or null for no argument methods
Jeff Hao5d917302013-02-27 17:57:33 -0800495 * a2 = size of argument array in bytes
496 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700497 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800498 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800499 */
500ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800501 sw $a0, 0($sp) # save out a0
502 addiu $sp, $sp, -16 # spill s0, s1, fp, ra
503 .cfi_adjust_cfa_offset 16
504 sw $ra, 12($sp)
505 .cfi_rel_offset 31, 12
506 sw $fp, 8($sp)
507 .cfi_rel_offset 30, 8
508 sw $s1, 4($sp)
509 .cfi_rel_offset 17, 4
510 sw $s0, 0($sp)
511 .cfi_rel_offset 16, 0
512 move $fp, $sp # save sp in fp
513 .cfi_def_cfa_register 30
514 move $s1, $a3 # move managed thread pointer into s1
515 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Douglas Leung735b8552014-10-31 12:21:40 -0700516 addiu $t0, $a2, 4 # create space for method pointer in frame.
517 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
518 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
519 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
Jeff Hao5d917302013-02-27 17:57:33 -0800520 addiu $a0, $sp, 4 # pass stack pointer + method ptr as dest for memcpy
521 jal memcpy # (dest, src, bytes)
522 addiu $sp, $sp, -16 # make space for argument slots for memcpy
523 addiu $sp, $sp, 16 # restore stack after memcpy
524 lw $a0, 16($fp) # restore method*
525 lw $a1, 4($sp) # copy arg value for a1
526 lw $a2, 8($sp) # copy arg value for a2
527 lw $a3, 12($sp) # copy arg value for a3
Mathieu Chartiere401d142015-04-22 13:56:20 -0700528 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800529 jalr $t9 # call the method
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700530 sw $zero, 0($sp) # store null for method* at bottom of frame
Jeff Hao5d917302013-02-27 17:57:33 -0800531 move $sp, $fp # restore the stack
532 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800533 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800534 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800535 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800536 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800537 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800538 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800539 .cfi_restore 31
Jeff Hao5d917302013-02-27 17:57:33 -0800540 addiu $sp, $sp, 16
541 .cfi_adjust_cfa_offset -16
542 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800543 lw $t1, 20($sp) # get shorty
544 lb $t1, 0($t1) # get result type char
Jeff Hao6474d192013-03-26 14:08:09 -0700545 li $t2, 68 # put char 'D' into t2
546 beq $t1, $t2, 1f # branch if result type char == 'D'
547 li $t3, 70 # put char 'F' into t3
548 beq $t1, $t3, 1f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800549 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -0800550 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800551 sw $v1, 4($t0) # store the other half of the result
Jeff Hao6474d192013-03-26 14:08:09 -07005521:
Duane Sande34652f2014-11-04 11:09:36 -0800553 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -0800554 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -0800555 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800556END art_quick_invoke_stub
557
558 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800559 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
560 * failure.
561 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800562 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700563ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -0700564 lw $a2, 0($sp) # pass referrer's Method*
565 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700566 jal artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700567 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700568 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700569END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800570
buzbee5bc5a7b2012-03-07 15:52:59 -0800571 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700572 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800573 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800574 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700575ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800576 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700577 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700578 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700579 jal artLockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700580 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700581 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700582END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800583
buzbee5bc5a7b2012-03-07 15:52:59 -0800584 /*
585 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
586 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800587 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700588ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800589 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700590 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700591 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700592 jal artUnlockObjectFromCode # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700593 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800594 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700595END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800596
buzbee5bc5a7b2012-03-07 15:52:59 -0800597 /*
598 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
599 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700600 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700601ENTRY art_quick_check_cast
Ian Rogersa9a82542013-10-04 11:17:26 -0700602 addiu $sp, $sp, -16
603 .cfi_adjust_cfa_offset 16
604 sw $ra, 12($sp)
605 .cfi_rel_offset 31, 12
606 sw $t9, 8($sp)
607 sw $a1, 4($sp)
608 sw $a0, 0($sp)
609 jal artIsAssignableFromCode
Douglas Leung735b8552014-10-31 12:21:40 -0700610 addiu $sp, $sp, -16 # reserve argument slots on the stack
611 addiu $sp, $sp, 16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800612 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700613 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -0800614 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700615 addiu $sp, $sp, 16
616 .cfi_adjust_cfa_offset -16
Ian Rogers86bcdc22014-02-21 22:06:38 -0800617.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700618 lw $t9, 8($sp)
619 lw $a1, 4($sp)
620 lw $a0, 0($sp)
621 addiu $sp, $sp, 16
622 .cfi_adjust_cfa_offset -16
623 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700624 la $t9, artThrowClassCastException
Andreas Gampe8d365912015-01-13 11:32:32 -0800625 jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700626 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700627END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800628
buzbee5bc5a7b2012-03-07 15:52:59 -0800629 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700630 * Entry from managed code for array put operations of objects where the value being stored
631 * needs to be checked for compatibility.
632 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800633 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700634ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800635 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700636 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800637 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700638 nop
639END art_quick_aput_obj_with_null_and_bound_check
640
641ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700642 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700643 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800644 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700645 nop
646 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800647 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700648 move $a1, $t0
649END art_quick_aput_obj_with_bound_check
650
651ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800652 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700653 nop
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700654 lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700655 UNPOISON_HEAP_REF $t0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700656 lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700657 UNPOISON_HEAP_REF $t1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700658 lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700659 UNPOISON_HEAP_REF $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800660 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700661 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800662.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700663 sll $a1, $a1, 2
664 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700665 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700666 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700667 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
668 srl $t1, $a0, 7
669 add $t1, $t1, $t0
670 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -0800671 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700672 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800673.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700674 sll $a1, $a1, 2
675 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700676 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -0800677 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700678 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800679.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700680 addiu $sp, $sp, -32
681 .cfi_adjust_cfa_offset 32
682 sw $ra, 28($sp)
683 .cfi_rel_offset 31, 28
684 sw $t9, 12($sp)
685 sw $a2, 8($sp)
686 sw $a1, 4($sp)
687 sw $a0, 0($sp)
688 move $a1, $t1
689 move $a0, $t0
690 jal artIsAssignableFromCode # (Class*, Class*)
Douglas Leung735b8552014-10-31 12:21:40 -0700691 addiu $sp, $sp, -16 # reserve argument slots on the stack
692 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -0700693 lw $ra, 28($sp)
694 lw $t9, 12($sp)
695 lw $a2, 8($sp)
696 lw $a1, 4($sp)
697 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -0800698 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -0700699 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800700 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700701 nop
702 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
703 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -0700704 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -0800705 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700706 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -0700707END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -0800708
buzbee5bc5a7b2012-03-07 15:52:59 -0800709 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700710 * Called by managed code to resolve a static field and load a boolean primitive value.
711 */
712 .extern artGetBooleanStaticFromCode
713ENTRY art_quick_get_boolean_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 artGetBooleanStaticFromCode # (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_boolean_static
720 /*
721 * Called by managed code to resolve a static field and load a byte primitive value.
722 */
723 .extern artGetByteStaticFromCode
724ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -0700725 lw $a1, 0($sp) # pass referrer's Method*
726 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700727 jal artGetByteStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700728 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700729 RETURN_IF_NO_EXCEPTION
730END art_quick_get_byte_static
731
732 /*
733 * Called by managed code to resolve a static field and load a char primitive value.
734 */
735 .extern artGetCharStaticFromCode
736ENTRY art_quick_get_char_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 artGetCharStaticFromCode # (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_char_static
743 /*
744 * Called by managed code to resolve a static field and load a short primitive value.
745 */
746 .extern artGetShortStaticFromCode
747ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -0700748 lw $a1, 0($sp) # pass referrer's Method*
749 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700750 jal artGetShortStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700751 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700752 RETURN_IF_NO_EXCEPTION
753END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800754
buzbee5bc5a7b2012-03-07 15:52:59 -0800755 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700756 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800757 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800758 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700759ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700760 lw $a1, 0($sp) # pass referrer's Method*
761 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700762 jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700763 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800764 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700765END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800766
buzbee5bc5a7b2012-03-07 15:52:59 -0800767 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700768 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800769 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800770 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700771ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700772 lw $a1, 0($sp) # pass referrer's Method*
773 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700774 jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700775 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800776 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700777END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800778
buzbee5bc5a7b2012-03-07 15:52:59 -0800779 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700780 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800781 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800782 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700783ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700784 lw $a1, 0($sp) # pass referrer's Method*
785 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700786 jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700787 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800788 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700789END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800790
buzbee5bc5a7b2012-03-07 15:52:59 -0800791 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700792 * Called by managed code to resolve an instance field and load a boolean primitive value.
793 */
794 .extern artGetBooleanInstanceFromCode
795ENTRY art_quick_get_boolean_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 artGetBooleanInstanceFromCode # (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_boolean_instance
802 /*
803 * Called by managed code to resolve an instance field and load a byte primitive value.
804 */
805 .extern artGetByteInstanceFromCode
806ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700807 lw $a2, 0($sp) # pass referrer's Method*
808 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700809 jal artGetByteInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700810 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700811 RETURN_IF_NO_EXCEPTION
812END art_quick_get_byte_instance
813
814 /*
815 * Called by managed code to resolve an instance field and load a char primitive value.
816 */
817 .extern artGetCharInstanceFromCode
818ENTRY art_quick_get_char_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
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700821 jal artGetCharInstanceFromCode # (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_char_instance
825 /*
826 * Called by managed code to resolve an instance field and load a short primitive value.
827 */
828 .extern artGetShortInstanceFromCode
829ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700830 lw $a2, 0($sp) # pass referrer's Method*
831 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
832 jal artGetShortInstanceFromCode # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700833 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700834 RETURN_IF_NO_EXCEPTION
835END art_quick_get_short_instance
836
837 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700838 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800839 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800840 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700841ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700842 lw $a2, 0($sp) # pass referrer's Method*
843 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
844 jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700845 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800846 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700847END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800848
buzbee5bc5a7b2012-03-07 15:52:59 -0800849 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700850 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800851 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800852 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700853ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700854 lw $a2, 0($sp) # pass referrer's Method*
855 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
856 jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700857 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800858 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700859END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800860
buzbee5bc5a7b2012-03-07 15:52:59 -0800861 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700862 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800863 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800864 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700865ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700866 lw $a2, 0($sp) # pass referrer's Method*
867 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700868 jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700869 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800870 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -0700871END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800872
buzbee5bc5a7b2012-03-07 15:52:59 -0800873 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700874 * Called by managed code to resolve a static field and store a 8-bit primitive value.
875 */
876 .extern artSet8StaticFromCode
877ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -0700878 lw $a2, 0($sp) # pass referrer's Method*
879 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700880 jal artSet8StaticFromCode # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700881 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700882 RETURN_IF_ZERO
883END art_quick_set8_static
884
885 /*
886 * Called by managed code to resolve a static field and store a 16-bit primitive value.
887 */
888 .extern artSet16StaticFromCode
889ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -0700890 lw $a2, 0($sp) # pass referrer's Method*
891 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Fred Shih37f05ef2014-07-16 18:38:08 -0700892 jal artSet16StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700893 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700894 RETURN_IF_ZERO
895END art_quick_set16_static
896
897 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700898 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800899 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800900 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700901ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -0700902 lw $a2, 0($sp) # pass referrer's Method*
903 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700904 jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700905 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800906 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700907END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800908
buzbee5bc5a7b2012-03-07 15:52:59 -0800909 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700910 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800911 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700912 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700913ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -0700914 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -0800915 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -0700916 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700917 jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700918 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800919 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700920END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800921
buzbee5bc5a7b2012-03-07 15:52:59 -0800922 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700923 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800924 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800925 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700926ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -0700927 lw $a2, 0($sp) # pass referrer's Method*
928 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
jeffhao7fbee072012-08-24 17:56:54 -0700929 move $a3, rSELF # pass Thread::Current
Douglas Leung735b8552014-10-31 12:21:40 -0700930 jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800931 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700932END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -0800933
buzbee5bc5a7b2012-03-07 15:52:59 -0800934 /*
Fred Shih37f05ef2014-07-16 18:38:08 -0700935 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
936 */
937 .extern artSet8InstanceFromCode
938ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700939 lw $a3, 0($sp) # pass referrer's Method*
940 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
941 jal artSet8InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700942 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700943 RETURN_IF_ZERO
944END art_quick_set8_instance
945
946 /*
947 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
948 */
949 .extern artSet16InstanceFromCode
950ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700951 lw $a3, 0($sp) # pass referrer's Method*
952 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700953 jal artSet16InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -0700954 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -0700955 RETURN_IF_ZERO
956END art_quick_set16_instance
957
958 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700959 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800960 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800961 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700962ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700963 lw $a3, 0($sp) # pass referrer's Method*
964 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700965 jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700966 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800967 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700968END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800969
buzbee5bc5a7b2012-03-07 15:52:59 -0800970 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700971 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -0800972 */
Fred Shih37f05ef2014-07-16 18:38:08 -0700973 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700974ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700975 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -0800976 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -0700977 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700978 sw rSELF, 20($sp) # pass Thread::Current
979 jal artSet64InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -0700980 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800981 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700982END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800983
buzbee5bc5a7b2012-03-07 15:52:59 -0800984 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700985 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -0800986 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800987 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700988ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -0700989 lw $a3, 0($sp) # pass referrer's Method*
990 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700991 jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -0700992 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800993 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700994END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -0800995
Vladimir Markoa3c38272015-04-28 12:37:09 +0100996// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +0100997.macro ONE_ARG_DOWNCALL name, entrypoint, return
998 .extern \entrypoint
999ENTRY \name
1000 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1001 jal \entrypoint
1002 move $a1, rSELF # pass Thread::Current
1003 \return
1004END \name
1005.endm
1006
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001007.macro TWO_ARG_DOWNCALL name, entrypoint, return
1008 .extern \entrypoint
1009ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001010 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001011 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001012 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001013 \return
1014END \name
1015.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001016
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001017.macro THREE_ARG_DOWNCALL name, entrypoint, return
1018 .extern \entrypoint
1019ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001020 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001021 jal \entrypoint
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001022 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001023 \return
1024END \name
1025.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001026
Jeff Hao848f70a2014-01-15 13:49:50 -08001027.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1028 .extern \entrypoint
1029ENTRY \name
Vladimir Markoa3c38272015-04-28 12:37:09 +01001030 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Jeff Hao848f70a2014-01-15 13:49:50 -08001031 jal \entrypoint
Vladimir Markoa3c38272015-04-28 12:37:09 +01001032 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001033 \return
1034END \name
1035.endm
1036
Mathieu Chartier7410f292013-11-24 13:17:35 -08001037// Generate the allocation entrypoints for each allocator.
1038GENERATE_ALL_ALLOC_ENTRYPOINTS
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001039
buzbee5bc5a7b2012-03-07 15:52:59 -08001040 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001041 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001042 * exception on error. On success the String is returned. A0 holds the string index. The fast
1043 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001044 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001045ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001046
1047 /*
1048 * Entry from managed code when uninitialized static storage, this stub will run the class
1049 * initializer and deliver the exception on error. On success the static storage base is
1050 * returned.
1051 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001052ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001053
1054 /*
1055 * Entry from managed code when dex cache misses for a type_idx.
1056 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001057ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001058
1059 /*
1060 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1061 * miss.
1062 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001063ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001064
1065 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001066 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001067 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001068 .extern artTestSuspendFromCode
1069ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001070 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001071 bnez $a0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001072 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001073 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001074 nop
10751:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001076 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
1077 jal artTestSuspendFromCode # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001078 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001079 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001080END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001081
buzbee5bc5a7b2012-03-07 15:52:59 -08001082 /*
1083 * Called by managed code that is attempting to call a method on a proxy class. On entry
Ian Rogers57b86d42012-03-27 16:05:41 -07001084 * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001085 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001086 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001087ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001088 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1089 move $a2, rSELF # pass Thread::Current
Jeff Hao5fa60c32013-04-04 17:57:01 -07001090 jal artQuickProxyInvokeHandler # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001091 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001092 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001093 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001094 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001095 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1096 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001097 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001098 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080010991:
1100 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001101END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001102
Jeff Hao88474b42013-10-23 16:24:40 -07001103 /*
1104 * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
1105 * dex method index.
1106 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001107ENTRY art_quick_imt_conflict_trampoline
Nicolas Geoffray8ea18d02015-05-26 16:29:08 +01001108 move $a0, $t0
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001109 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001110END art_quick_imt_conflict_trampoline
1111
Ian Rogers468532e2013-08-05 10:56:33 -07001112 .extern artQuickResolutionTrampoline
1113ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001114 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001115 move $a2, rSELF # pass Thread::Current
Ian Rogers65d1b222013-09-27 10:59:41 -07001116 jal artQuickResolutionTrampoline # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001117 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001118 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001119 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001120 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001121 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001122 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001123 nop
Ian Rogers468532e2013-08-05 10:56:33 -070011241:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001125 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001126 DELIVER_PENDING_EXCEPTION
1127END art_quick_resolution_trampoline
1128
Douglas Leung735b8552014-10-31 12:21:40 -07001129 .extern artQuickGenericJniTrampoline
1130 .extern artQuickGenericJniEndTrampoline
1131ENTRY art_quick_generic_jni_trampoline
1132 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1133 move $s8, $sp # save $sp to $s8
1134 move $s3, $gp # save $gp to $s3
1135
1136 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1137 move $a0, rSELF # pass Thread::Current
1138 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
1139 jal artQuickGenericJniTrampoline # (Thread*, SP)
1140 addiu $sp, $sp, -5120 # reserve space on the stack
1141
1142 # The C call will have registered the complete save-frame on success.
1143 # The result of the call is:
1144 # v0: ptr to native code, 0 on error.
1145 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1146 beq $v0, $zero, 1f # check entry error
1147 move $t9, $v0 # save the code ptr
1148 move $sp, $v1 # release part of the alloca
1149
1150 # Load parameters from stack into registers
1151 lw $a0, 0($sp)
1152 lw $a1, 4($sp)
1153 lw $a2, 8($sp)
1154
1155 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1156 jalr $t9 # native call
1157 lw $a3, 12($sp)
1158 addiu $sp, $sp, 16 # remove arg slots
1159
1160 move $gp, $s3 # restore $gp from $s3
1161
1162 # result sign extension is handled in C code
1163 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1164 move $a0, rSELF # pass Thread::Current
1165 move $a2, $v0 # pass result
1166 move $a3, $v1
1167 addiu $sp, $sp, -24 # reserve arg slots
1168 jal artQuickGenericJniEndTrampoline
1169 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001170
1171 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001172 bne $t0, $zero, 1f # check for pending exceptions
1173
Douglas Leung735b8552014-10-31 12:21:40 -07001174 move $sp, $s8 # tear down the alloca
1175
1176 # tear dpown the callee-save frame
1177 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1178
Duane Sande34652f2014-11-04 11:09:36 -08001179 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001180 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001181 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001182
11831:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001184 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1185 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07001186 DELIVER_PENDING_EXCEPTION
1187END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001188
Ian Rogers468532e2013-08-05 10:56:33 -07001189 .extern artQuickToInterpreterBridge
1190ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001191 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001192 move $a1, rSELF # pass Thread::Current
1193 jal artQuickToInterpreterBridge # (Method* method, Thread*, SP)
1194 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08001195 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001196 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001197 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001198 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1199 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001200 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001201 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080012021:
1203 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001204END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001205
buzbee5bc5a7b2012-03-07 15:52:59 -08001206 /*
jeffhao725a9572012-11-13 18:20:12 -08001207 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001208 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001209 .extern artInstrumentationMethodEntryFromCode
1210 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001211ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001212 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001213 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001214 move $a3, $ra # pass $ra
1215 jal artInstrumentationMethodEntryFromCode # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001216 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001217 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07001218 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001219 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001220 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001221 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001222END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001223 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001224 .global art_quick_instrumentation_exit
1225art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001226 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001227 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001228 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001229 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07001230
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001231 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001232 addiu $sp, $sp, -16 # allocate temp storage on the stack
1233 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001234 sw $v0, ARG_SLOT_SIZE+12($sp)
1235 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
1236 sw $v1, ARG_SLOT_SIZE+8($sp)
1237 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
1238 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001239 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08001240 move $a2, $v0 # pass gpr result
1241 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001242 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Ian Rogers62d6c772013-02-27 08:32:07 -08001243 jal artInstrumentationMethodExitFromCode # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001244 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001245 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08001246 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001247 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
1248 lw $v1, ARG_SLOT_SIZE+8($sp)
1249 l.d $f0, ARG_SLOT_SIZE($sp)
1250 jalr $zero, $t9 # return
1251 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16 # restore stack
1252 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16)
Ian Rogers468532e2013-08-05 10:56:33 -07001253END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001254
jeffhao12051ea2013-01-10 11:24:31 -08001255 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001256 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1257 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001258 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001259 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001260ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001261 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001262 jal artDeoptimize # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001263 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001264 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001265END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001266
buzbee5bc5a7b2012-03-07 15:52:59 -08001267 /*
1268 * Long integer shift. This is different from the generic 32/64-bit
1269 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1270 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1271 * 6 bits.
1272 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001273 * $a0: low word
1274 * $a1: high word
1275 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001276 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001277ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001278 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001279 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1280 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1281 srl $a0, 1
1282 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1283 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001284 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001285 beqz $a2, 1f
1286 or $v1, $a0 # rhi<- rhi | alo
1287
1288 move $v1, $v0 # rhi<- rlo (if shift&0x20)
1289 move $v0, $zero # rlo<- 0 (if shift&0x20)
1290
Andreas Gampe8d365912015-01-13 11:32:32 -080012911: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001292 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001293END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001294
buzbee5bc5a7b2012-03-07 15:52:59 -08001295 /*
1296 * Long integer shift. This is different from the generic 32/64-bit
1297 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1298 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1299 * 6 bits.
1300 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001301 * $a0: low word
1302 * $a1: high word
1303 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001304 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001305ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001306 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1307 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1308 sra $a3, $a1, 31 # $a3<- sign(ah)
1309 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1310 sll $a1, 1
1311 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001312 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08001313 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001314 or $v0, $a1 # rlo<- rlo | ahi
1315
1316 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1317 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
1318
Andreas Gampe8d365912015-01-13 11:32:32 -080013191: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001320 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001321END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001322
buzbee5bc5a7b2012-03-07 15:52:59 -08001323 /*
1324 * Long integer shift. This is different from the generic 32/64-bit
1325 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1326 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1327 * 6 bits.
1328 * On entry:
1329 * r0: low word
1330 * r1: high word
1331 * r2: shift count
1332 */
1333 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001334ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001335 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001336 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001337 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1338 sll $a1, 1
1339 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001340 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001341 beqz $a2, 1f
1342 or $v0, $a1 # rlo<- rlo | ahi
1343
1344 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1345 move $v1, $zero # rhi<- 0 (if shift&0x20)
1346
Andreas Gampe8d365912015-01-13 11:32:32 -080013471: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001348 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001349END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001350
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001351UNIMPLEMENTED art_quick_indexof
1352UNIMPLEMENTED art_quick_string_compareto