blob: c85887a0c32c3154749f926cbef522212b73eba9 [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)
Douglas Leung4af77b72014-10-22 16:32:28 -070082 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070083 sw $t0, 0($sp) # Place Method* at bottom of stack.
84 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -070085 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
86 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -080087.endm
88
89 /*
90 * Macro that sets up the callee save frame to conform with
91 * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
92 * Does not include rSUSPEND or rSELF
Douglas Leung735b8552014-10-31 12:21:40 -070093 * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
94 * Clobbers $t0 and $sp
95 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
96 * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080097 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070098.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -070099 addiu $sp, $sp, -48
100 .cfi_adjust_cfa_offset 48
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700101
102 // Ugly compile-time check, but we only have the preprocessor.
Douglas Leung735b8552014-10-31 12:21:40 -0700103#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700104#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
105#endif
106
Douglas Leung735b8552014-10-31 12:21:40 -0700107 sw $ra, 44($sp)
108 .cfi_rel_offset 31, 44
109 sw $s8, 40($sp)
110 .cfi_rel_offset 30, 40
111 sw $gp, 36($sp)
112 .cfi_rel_offset 28, 36
113 sw $s7, 32($sp)
114 .cfi_rel_offset 23, 32
115 sw $s6, 28($sp)
116 .cfi_rel_offset 22, 28
117 sw $s5, 24($sp)
118 .cfi_rel_offset 21, 24
119 sw $s4, 20($sp)
120 .cfi_rel_offset 20, 20
121 sw $s3, 16($sp)
122 .cfi_rel_offset 19, 16
123 sw $s2, 12($sp)
124 .cfi_rel_offset 18, 12
125 # 2 words for alignment and bottom word will hold Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700126
Douglas Leung4af77b72014-10-22 16:32:28 -0700127 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
128 lw $t0, 0($t0)
Douglas Leung4af77b72014-10-22 16:32:28 -0700129 lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700130 sw $t0, 0($sp) # Place Method* at bottom of stack.
131 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700132 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
133 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800134.endm
135
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700136.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700137 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
138 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
139 lw $ra, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800140 .cfi_restore 31
Douglas Leung735b8552014-10-31 12:21:40 -0700141 lw $s8, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800142 .cfi_restore 30
Douglas Leung735b8552014-10-31 12:21:40 -0700143 lw $gp, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800144 .cfi_restore 28
Douglas Leung735b8552014-10-31 12:21:40 -0700145 lw $s7, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800146 .cfi_restore 23
Douglas Leung735b8552014-10-31 12:21:40 -0700147 lw $s6, 28($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800148 .cfi_restore 22
Douglas Leung735b8552014-10-31 12:21:40 -0700149 lw $s5, 24($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800150 .cfi_restore 21
Douglas Leung735b8552014-10-31 12:21:40 -0700151 lw $s4, 20($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800152 .cfi_restore 20
Douglas Leung735b8552014-10-31 12:21:40 -0700153 lw $s3, 16($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800154 .cfi_restore 19
Douglas Leung735b8552014-10-31 12:21:40 -0700155 lw $s2, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800156 .cfi_restore 18
Douglas Leung735b8552014-10-31 12:21:40 -0700157 addiu $sp, $sp, 48
158 .cfi_adjust_cfa_offset -48
buzbee5bc5a7b2012-03-07 15:52:59 -0800159.endm
160
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700161.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Douglas Leung735b8552014-10-31 12:21:40 -0700162 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
Andreas Gampe8d365912015-01-13 11:32:32 -0800163 jalr $zero, $ra
Douglas Leung735b8552014-10-31 12:21:40 -0700164 nop
buzbee5bc5a7b2012-03-07 15:52:59 -0800165.endm
166
167 /*
168 * Macro that sets up the callee save frame to conform with
Douglas Leung735b8552014-10-31 12:21:40 -0700169 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
Jeff Hao1f3bc2f2013-04-30 15:17:19 -0700170 * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
buzbee5bc5a7b2012-03-07 15:52:59 -0800171 */
Douglas Leung735b8552014-10-31 12:21:40 -0700172.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
Goran Jakovljevicff734982015-08-24 12:58:55 +0000173 addiu $sp, $sp, -80
174 .cfi_adjust_cfa_offset 80
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700175
176 // Ugly compile-time check, but we only have the preprocessor.
Goran Jakovljevicff734982015-08-24 12:58:55 +0000177#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 80)
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700178#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
179#endif
180
Goran Jakovljevicff734982015-08-24 12:58:55 +0000181 sw $ra, 76($sp)
182 .cfi_rel_offset 31, 76
183 sw $s8, 72($sp)
184 .cfi_rel_offset 30, 72
185 sw $gp, 68($sp)
186 .cfi_rel_offset 28, 68
187 sw $s7, 64($sp)
188 .cfi_rel_offset 23, 64
189 sw $s6, 60($sp)
190 .cfi_rel_offset 22, 60
191 sw $s5, 56($sp)
192 .cfi_rel_offset 21, 56
193 sw $s4, 52($sp)
194 .cfi_rel_offset 20, 52
195 sw $s3, 48($sp)
196 .cfi_rel_offset 19, 48
197 sw $s2, 44($sp)
198 .cfi_rel_offset 18, 44
199 sw $a3, 40($sp)
200 .cfi_rel_offset 7, 40
201 sw $a2, 36($sp)
202 .cfi_rel_offset 6, 36
203 sw $a1, 32($sp)
204 .cfi_rel_offset 5, 32
205 SDu $f14, $f15, 24, $sp, $t0
206 SDu $f12, $f13, 16, $sp, $t0
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.
Goran Jakovljevicff734982015-08-24 12:58:55 +0000213 * callee-save: $a1-$a3, $f12-$f15, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
Douglas Leung735b8552014-10-31 12:21:40 -0700214 * 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)
Douglas Leung4af77b72014-10-22 16:32:28 -0700222 lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700223 sw $t0, 0($sp) # Place Method* at bottom of stack.
224 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700225 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
226 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
227.endm
228
229 /*
230 * Macro that sets up the callee save frame to conform with
231 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
Goran Jakovljevicff734982015-08-24 12:58:55 +0000232 * callee-save: $a1-$a3, $f12-$f15, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
Douglas Leung735b8552014-10-31 12:21:40 -0700233 * Clobbers $sp
234 * Use $a0 as the Method* and loads it into bottom of stack.
235 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
236 * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
237 */
238.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
239 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
240 sw $a0, 0($sp) # Place Method* at bottom of stack.
241 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
242 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
243 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800244.endm
245
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700246.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700247 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
248 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
Goran Jakovljevicff734982015-08-24 12:58:55 +0000249 lw $ra, 76($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800250 .cfi_restore 31
Goran Jakovljevicff734982015-08-24 12:58:55 +0000251 lw $s8, 72($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800252 .cfi_restore 30
Goran Jakovljevicff734982015-08-24 12:58:55 +0000253 lw $gp, 68($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800254 .cfi_restore 28
Goran Jakovljevicff734982015-08-24 12:58:55 +0000255 lw $s7, 64($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800256 .cfi_restore 23
Goran Jakovljevicff734982015-08-24 12:58:55 +0000257 lw $s6, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800258 .cfi_restore 22
Goran Jakovljevicff734982015-08-24 12:58:55 +0000259 lw $s5, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800260 .cfi_restore 21
Goran Jakovljevicff734982015-08-24 12:58:55 +0000261 lw $s4, 52($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800262 .cfi_restore 20
Goran Jakovljevicff734982015-08-24 12:58:55 +0000263 lw $s3, 48($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800264 .cfi_restore 19
Goran Jakovljevicff734982015-08-24 12:58:55 +0000265 lw $s2, 44($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800266 .cfi_restore 18
Goran Jakovljevicff734982015-08-24 12:58:55 +0000267 lw $a3, 40($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800268 .cfi_restore 7
Goran Jakovljevicff734982015-08-24 12:58:55 +0000269 lw $a2, 36($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800270 .cfi_restore 6
Goran Jakovljevicff734982015-08-24 12:58:55 +0000271 lw $a1, 32($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800272 .cfi_restore 5
Goran Jakovljevicff734982015-08-24 12:58:55 +0000273 LDu $f14, $f15, 24, $sp, $t1
274 LDu $f12, $f13, 16, $sp, $t1
275 addiu $sp, $sp, 80 # pop frame
276 .cfi_adjust_cfa_offset -80
buzbee5bc5a7b2012-03-07 15:52:59 -0800277.endm
278
279 /*
280 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
281 * exception is Thread::Current()->exception_
282 */
283.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700284 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700285 la $t9, artDeliverPendingExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800286 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700287 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800288.endm
289
290.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700291 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700292 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700293 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800294 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800295 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800296 nop
2971:
298 DELIVER_PENDING_EXCEPTION
299.endm
300
301.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700302 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700303 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800304 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800305 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800306 nop
3071:
308 DELIVER_PENDING_EXCEPTION
309.endm
310
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800311.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700312 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700313 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800314 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800315 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800316 nop
3171:
318 DELIVER_PENDING_EXCEPTION
319.endm
320
buzbee5bc5a7b2012-03-07 15:52:59 -0800321 /*
jeffhao7fbee072012-08-24 17:56:54 -0700322 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800323 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
324 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800325ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800326 LDu $f0, $f1, 0*8, $a1, $t1
327 LDu $f2, $f3, 1*8, $a1, $t1
328 LDu $f4, $f5, 2*8, $a1, $t1
329 LDu $f6, $f7, 3*8, $a1, $t1
330 LDu $f8, $f9, 4*8, $a1, $t1
331 LDu $f10, $f11, 5*8, $a1, $t1
332 LDu $f12, $f13, 6*8, $a1, $t1
333 LDu $f14, $f15, 7*8, $a1, $t1
334 LDu $f16, $f17, 8*8, $a1, $t1
335 LDu $f18, $f19, 9*8, $a1, $t1
336 LDu $f20, $f21, 10*8, $a1, $t1
337 LDu $f22, $f23, 11*8, $a1, $t1
338 LDu $f24, $f25, 12*8, $a1, $t1
339 LDu $f26, $f27, 13*8, $a1, $t1
340 LDu $f28, $f29, 14*8, $a1, $t1
341 LDu $f30, $f31, 15*8, $a1, $t1
342
Chris Dearman748dd952014-05-23 10:47:01 -0700343 .set push
344 .set nomacro
345 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700346 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700347 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700348 lw $v0, 8($a0)
349 lw $v1, 12($a0)
350 lw $a1, 20($a0)
351 lw $a2, 24($a0)
352 lw $a3, 28($a0)
353 lw $t0, 32($a0)
354 lw $t1, 36($a0)
355 lw $t2, 40($a0)
356 lw $t3, 44($a0)
357 lw $t4, 48($a0)
358 lw $t5, 52($a0)
359 lw $t6, 56($a0)
360 lw $t7, 60($a0)
361 lw $s0, 64($a0)
362 lw $s1, 68($a0)
363 lw $s2, 72($a0)
364 lw $s3, 76($a0)
365 lw $s4, 80($a0)
366 lw $s5, 84($a0)
367 lw $s6, 88($a0)
368 lw $s7, 92($a0)
369 lw $t8, 96($a0)
370 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700371 lw $gp, 112($a0)
372 lw $sp, 116($a0)
373 lw $fp, 120($a0)
374 lw $ra, 124($a0)
375 lw $a0, 16($a0)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100376 move $v0, $zero # clear result registers v0 and v1 (in branch delay slot)
Goran Jakovljevic75969962015-10-27 12:29:07 +0100377 jalr $zero, $t9 # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700378 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800379END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800380
buzbee5bc5a7b2012-03-07 15:52:59 -0800381 /*
382 * Called by managed code, saves most registers (forms basis of long jump context) and passes
383 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
Lazar Trsic84bc06e2015-06-10 16:05:46 +0200384 * the bottom of the thread. On entry a0 holds Throwable*
buzbee5bc5a7b2012-03-07 15:52:59 -0800385 */
Ian Rogers468532e2013-08-05 10:56:33 -0700386ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700387 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700388 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800389 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700390 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700391END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800392
buzbee5bc5a7b2012-03-07 15:52:59 -0800393 /*
394 * Called by managed code to create and deliver a NullPointerException
395 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800396 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700397ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700398 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700399 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800400 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700401 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700402END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800403
buzbee5bc5a7b2012-03-07 15:52:59 -0800404 /*
405 * Called by managed code to create and deliver an ArithmeticException
406 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800407 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700408ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700409 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700410 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800411 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700412 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700413END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800414
buzbee5bc5a7b2012-03-07 15:52:59 -0800415 /*
416 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
417 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800418 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700419ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700420 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700421 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800422 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700423 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700424END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800425
Ian Rogers57b86d42012-03-27 16:05:41 -0700426 /*
427 * Called by managed code to create and deliver a StackOverflowError.
428 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800429 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700430ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700431 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700432 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800433 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700434 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700435END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800436
Ian Rogers57b86d42012-03-27 16:05:41 -0700437 /*
438 * Called by managed code to create and deliver a NoSuchMethodError.
439 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800440 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700441ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700442 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700443 la $t9, artThrowNoSuchMethodFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800444 jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700445 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700446END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800447
buzbee5bc5a7b2012-03-07 15:52:59 -0800448 /*
449 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700450 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100451 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700452 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800453 *
jeffhao7fbee072012-08-24 17:56:54 -0700454 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
455 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800456 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700457 * If unsuccessful, the helper will return null/null. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800458 * thread and we branch to another stub to deliver it.
459 *
460 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
461 * pointing back to the original caller.
462 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700463.macro INVOKE_TRAMPOLINE_BODY cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800464 .extern \cxx_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700465 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100466 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100467 la $t9, \cxx_name
468 jalr $t9 # (method_idx, this, Thread*, $sp)
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100469 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
470 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700471 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700472 beqz $v0, 1f
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100473 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800474 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800475 nop
4761:
477 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700478.endm
479.macro INVOKE_TRAMPOLINE c_name, cxx_name
480ENTRY \c_name
481 INVOKE_TRAMPOLINE_BODY \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800482END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800483.endm
484
Logan Chien8dbb7082013-01-25 20:31:17 +0800485INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800486
Logan Chien8dbb7082013-01-25 20:31:17 +0800487INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
488INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
489INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
490INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800491
Goran Jakovljevicff734982015-08-24 12:58:55 +0000492.macro LOAD_WORD_TO_REG reg, next_arg, index, label
493 lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
494 b \label
495 addiu $\index, 1
496.endm
497
498.macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index, label
499 lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8)
500 lw $\reg2, -4($\next_arg)
501 b \label
502 li $\index, 4 # long can be loaded only to a2_a3 pair so index will be always 4
503.endm
504
505.macro LOAD_FLOAT_TO_REG reg, next_arg, index, label
506 lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
507 b \label
508 addiu $\index, 1
509.endm
510
511.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index, tmp, label
512 LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one
513 # (offset is 8)
514 b \label
515 addiu $\index, 1
516.endm
517
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100518#define SPILL_SIZE 32
519
Jeff Hao79fe5392013-04-24 18:41:58 -0700520 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800521 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800522 * On entry:
523 * a0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700524 * a1 = argument array or null for no argument methods
Jeff Hao5d917302013-02-27 17:57:33 -0800525 * a2 = size of argument array in bytes
526 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700527 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800528 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800529 */
530ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800531 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100532 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
533 .cfi_adjust_cfa_offset SPILL_SIZE
534 sw $gp, 16($sp)
Jeff Hao5d917302013-02-27 17:57:33 -0800535 sw $ra, 12($sp)
536 .cfi_rel_offset 31, 12
537 sw $fp, 8($sp)
538 .cfi_rel_offset 30, 8
539 sw $s1, 4($sp)
540 .cfi_rel_offset 17, 4
541 sw $s0, 0($sp)
542 .cfi_rel_offset 16, 0
543 move $fp, $sp # save sp in fp
544 .cfi_def_cfa_register 30
545 move $s1, $a3 # move managed thread pointer into s1
546 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Goran Jakovljevicff734982015-08-24 12:58:55 +0000547 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700548 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
Goran Jakovljevicff734982015-08-24 12:58:55 +0000549 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
550 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
551 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100552 la $t9, memcpy
553 jalr $t9 # (dest, src, bytes)
Jeff Hao5d917302013-02-27 17:57:33 -0800554 addiu $sp, $sp, -16 # make space for argument slots for memcpy
555 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100556 lw $gp, 16($fp) # restore $gp
557 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000558 lw $a1, 4($sp) # a1 = this*
559 addiu $t0, $sp, 8 # t0 = pointer to the current argument (skip ArtMethod* and this*)
560 li $t3, 2 # t3 = gpr_index = 2 (skip A0 and A1)
561 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100562 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
563 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000564 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
565loop:
566 lbu $t2, 0($t1) # t2 = shorty[i]
567 beqz $t2, loopEnd # finish getting args when shorty[i] == '\0'
568 addiu $t1, 1
569
570 li $t9, 'J' # put char 'J' into t9
571 beq $t9, $t2, isLong # branch if result type char == 'J'
572 li $t9, 'D' # put char 'D' into t9
573 beq $t9, $t2, isDouble # branch if result type char == 'D'
574 li $t9, 'F' # put char 'F' into t9
575 beq $t9, $t2, isSingle # branch if result type char == 'F'
576 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
577 # for both, int and single)
578
579 li $t5, 2 # skip a0 and a1 (ArtMethod* and this*)
580 bne $t5, $t3, 1f # if (gpr_index == 2)
581 addiu $t5, 1
582 LOAD_WORD_TO_REG a2, t0, t3, loop # a2 = current argument, gpr_index++
5831: bne $t5, $t3, loop # else if (gpr_index == 3)
584 nop
585 LOAD_WORD_TO_REG a3, t0, t3, loop # a3 = current argument, gpr_index++
586
587isLong:
588 addiu $t0, 8 # next_arg = curr_arg + 8
589 slti $t5, $t3, 3
590 beqz $t5, 2f # if (gpr_index < 3)
591 nop
592 LOAD_LONG_TO_REG a2, a3, t0, t3, loop # a2_a3 = curr_arg, gpr_index = 4
5932: b loop # else
594 li $t3, 4 # gpr_index = 4
595
596isDouble:
597 addiu $t0, 8 # next_arg = curr_arg + 8
598 li $t5, 0
599 bne $t5, $t4, 3f # if (fp_index == 0)
600 addiu $t5, 1
601 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loop # f12_f13 = curr_arg, fp_index++
6023: bne $t5, $t4, loop # else if (fp_index == 1)
603 nop
604 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loop # f14_f15 = curr_arg, fp_index++
605
606isSingle:
607 li $t5, 0
608 bne $t5, $t4, 4f # if (fp_index == 0)
609 addiu $t5, 1
610 LOAD_FLOAT_TO_REG f12, t0, t4, loop # f12 = curr_arg, fp_index++
6114: bne $t5, $t4, loop # else if (fp_index == 1)
612 nop
613 LOAD_FLOAT_TO_REG f14, t0, t4, loop # f14 = curr_arg, fp_index++
614
615loopEnd:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700616 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800617 jalr $t9 # call the method
Goran Jakovljevicff734982015-08-24 12:58:55 +0000618 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
Jeff Hao5d917302013-02-27 17:57:33 -0800619 move $sp, $fp # restore the stack
620 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800621 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800622 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800623 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800624 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800625 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800626 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800627 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100628 addiu $sp, $sp, SPILL_SIZE
629 .cfi_adjust_cfa_offset -SPILL_SIZE
Jeff Hao5d917302013-02-27 17:57:33 -0800630 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800631 lw $t1, 20($sp) # get shorty
632 lb $t1, 0($t1) # get result type char
Goran Jakovljevicff734982015-08-24 12:58:55 +0000633 li $t2, 'D' # put char 'D' into t2
634 beq $t1, $t2, 5f # branch if result type char == 'D'
635 li $t3, 'F' # put char 'F' into t3
636 beq $t1, $t3, 5f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800637 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -0800638 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800639 sw $v1, 4($t0) # store the other half of the result
Goran Jakovljevicff734982015-08-24 12:58:55 +00006405:
Duane Sande34652f2014-11-04 11:09:36 -0800641 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -0800642 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -0800643 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800644END art_quick_invoke_stub
645
646 /*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000647 * Invocation static stub for quick code.
648 * On entry:
649 * a0 = method pointer
650 * a1 = argument array or null for no argument methods
651 * a2 = size of argument array in bytes
652 * a3 = (managed) thread pointer
653 * [sp + 16] = JValue* result
654 * [sp + 20] = shorty
655 */
656ENTRY art_quick_invoke_static_stub
657 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100658 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
659 .cfi_adjust_cfa_offset SPILL_SIZE
660 sw $gp, 16($sp)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000661 sw $ra, 12($sp)
662 .cfi_rel_offset 31, 12
663 sw $fp, 8($sp)
664 .cfi_rel_offset 30, 8
665 sw $s1, 4($sp)
666 .cfi_rel_offset 17, 4
667 sw $s0, 0($sp)
668 .cfi_rel_offset 16, 0
669 move $fp, $sp # save sp in fp
670 .cfi_def_cfa_register 30
671 move $s1, $a3 # move managed thread pointer into s1
672 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
673 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
674 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
675 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
676 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
677 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100678 la $t9, memcpy
679 jalr $t9 # (dest, src, bytes)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000680 addiu $sp, $sp, -16 # make space for argument slots for memcpy
681 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100682 lw $gp, 16($fp) # restore $gp
683 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000684 addiu $t0, $sp, 4 # t0 = pointer to the current argument (skip ArtMethod*)
685 li $t3, 1 # t3 = gpr_index = 1 (skip A0)
686 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100687 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
688 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000689 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
690loopS:
691 lbu $t2, 0($t1) # t2 = shorty[i]
692 beqz $t2, loopEndS # finish getting args when shorty[i] == '\0'
693 addiu $t1, 1
694
695 li $t9, 'J' # put char 'J' into t9
696 beq $t9, $t2, isLongS # branch if result type char == 'J'
697 li $t9, 'D' # put char 'D' into t9
698 beq $t9, $t2, isDoubleS # branch if result type char == 'D'
699 li $t9, 'F' # put char 'F' into t9
700 beq $t9, $t2, isSingleS # branch if result type char == 'F'
701 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
702 # for both, int and single)
703
704 li $t5, 1 # skip a0 (ArtMethod*)
705 bne $t5, $t3, 1f # if (gpr_index == 1)
706 addiu $t5, 1
707 LOAD_WORD_TO_REG a1, t0, t3, loopS # a1 = current argument, gpr_index++
7081: bne $t5, $t3, 2f # else if (gpr_index == 2)
709 addiu $t5, 1
710 LOAD_WORD_TO_REG a2, t0, t3, loopS # a2 = current argument, gpr_index++
7112: bne $t5, $t3, loopS # else if (gpr_index == 3)
712 nop
713 LOAD_WORD_TO_REG a3, t0, t3, loopS # a3 = current argument, gpr_index++
714
715isLongS:
716 addiu $t0, 8 # next_arg = curr_arg + 8
717 slti $t5, $t3, 3
718 beqz $t5, 3f # if (gpr_index < 3)
719 nop
720 LOAD_LONG_TO_REG a2, a3, t0, t3, loopS # a2_a3 = curr_arg, gpr_index = 4
7213: b loopS # else
722 li $t3, 4 # gpr_index = 4
723
724isDoubleS:
725 addiu $t0, 8 # next_arg = curr_arg + 8
726 li $t5, 0
727 bne $t5, $t4, 4f # if (fp_index == 0)
728 addiu $t5, 1
729 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loopS # f12_f13 = curr_arg, fp_index++
7304: bne $t5, $t4, loopS # else if (fp_index == 1)
731 nop
732 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loopS # f14_f15 = curr_arg, fp_index++
733
734isSingleS:
735 li $t5, 0
736 bne $t5, $t4, 5f # if (fp_index == 0)
737 addiu $t5, 1
738 LOAD_FLOAT_TO_REG f12, t0, t4, loopS # f12 = curr_arg, fp_index++
7395: bne $t5, $t4, loopS # else if (fp_index == 1)
740 nop
741 LOAD_FLOAT_TO_REG f14, t0, t4, loopS # f14 = curr_arg, fp_index++
742
743loopEndS:
744 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
745 jalr $t9 # call the method
746 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
747 move $sp, $fp # restore the stack
748 lw $s0, 0($sp)
749 .cfi_restore 16
750 lw $s1, 4($sp)
751 .cfi_restore 17
752 lw $fp, 8($sp)
753 .cfi_restore 30
754 lw $ra, 12($sp)
755 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100756 addiu $sp, $sp, SPILL_SIZE
757 .cfi_adjust_cfa_offset -SPILL_SIZE
Goran Jakovljevicff734982015-08-24 12:58:55 +0000758 lw $t0, 16($sp) # get result pointer
759 lw $t1, 20($sp) # get shorty
760 lb $t1, 0($t1) # get result type char
761 li $t2, 'D' # put char 'D' into t2
762 beq $t1, $t2, 6f # branch if result type char == 'D'
763 li $t3, 'F' # put char 'F' into t3
764 beq $t1, $t3, 6f # branch if result type char == 'F'
765 sw $v0, 0($t0) # store the result
766 jalr $zero, $ra
767 sw $v1, 4($t0) # store the other half of the result
7686:
769 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
770 jalr $zero, $ra
771 nop
772END art_quick_invoke_static_stub
773
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100774#undef SPILL_SIZE
775
Goran Jakovljevicff734982015-08-24 12:58:55 +0000776 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800777 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
778 * failure.
779 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800780 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700781ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -0700782 lw $a2, 0($sp) # pass referrer's Method*
783 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100784 la $t9, artHandleFillArrayDataFromCode
785 jalr $t9 # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -0700786 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -0700787 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700788END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -0800789
buzbee5bc5a7b2012-03-07 15:52:59 -0800790 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700791 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -0800792 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800793 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700794ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800795 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700796 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700797 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100798 la $t9, artLockObjectFromCode
799 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700800 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -0700801 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700802END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800803
buzbee5bc5a7b2012-03-07 15:52:59 -0800804 /*
805 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
806 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800807 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700808ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -0800809 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700810 nop
Douglas Leung735b8552014-10-31 12:21:40 -0700811 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100812 la $t9, artUnlockObjectFromCode
813 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -0700814 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800815 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -0700816END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -0800817
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 /*
819 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
820 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700821 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -0700822ENTRY art_quick_check_cast
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100823 addiu $sp, $sp, -32
824 .cfi_adjust_cfa_offset 32
825 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -0700826 sw $ra, 12($sp)
827 .cfi_rel_offset 31, 12
828 sw $t9, 8($sp)
829 sw $a1, 4($sp)
830 sw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100831 la $t9, artIsAssignableFromCode
832 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -0700833 addiu $sp, $sp, -16 # reserve argument slots on the stack
834 addiu $sp, $sp, 16
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100835 lw $gp, 16($sp)
Ian Rogers86bcdc22014-02-21 22:06:38 -0800836 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -0700837 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -0800838 jalr $zero, $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100839 addiu $sp, $sp, 32
840 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800841.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -0700842 lw $t9, 8($sp)
843 lw $a1, 4($sp)
844 lw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100845 addiu $sp, $sp, 32
846 .cfi_adjust_cfa_offset -32
Ian Rogersa9a82542013-10-04 11:17:26 -0700847 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -0700848 la $t9, artThrowClassCastException
Andreas Gampe8d365912015-01-13 11:32:32 -0800849 jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700850 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700851END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -0800852
buzbee5bc5a7b2012-03-07 15:52:59 -0800853 /*
Man Cao1aee9002015-07-14 22:31:42 -0700854 * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
855 * nReg is the register number for rReg.
856 */
857.macro POP_REG_NE rReg, nReg, offset, rExclude
858 .ifnc \rReg, \rExclude
859 lw \rReg, \offset($sp) # restore rReg
860 .cfi_restore \nReg
861 .endif
862.endm
863
864 /*
865 * Macro to insert read barrier, only used in art_quick_aput_obj.
866 * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
867 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
868 */
869.macro READ_BARRIER rDest, rObj, offset
870#ifdef USE_READ_BARRIER
871 # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment.
872 addiu $sp, $sp, -32
873 .cfi_adjust_cfa_offset 32
874 sw $ra, 28($sp)
875 .cfi_rel_offset 31, 28
876 sw $t9, 24($sp)
877 .cfi_rel_offset 25, 24
878 sw $t1, 20($sp)
879 .cfi_rel_offset 9, 20
880 sw $t0, 16($sp)
881 .cfi_rel_offset 8, 16
882 sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B)
883 .cfi_rel_offset 6, 8
884 sw $a1, 4($sp)
885 .cfi_rel_offset 5, 4
886 sw $a0, 0($sp)
887 .cfi_rel_offset 4, 0
888
Man Cao63069212015-08-21 15:51:39 -0700889 # move $a0, \rRef # pass ref in a0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -0700890 .ifnc \rObj, $a1
891 move $a1, \rObj # pass rObj
892 .endif
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100893 addiu $a2, $zero, \offset # pass offset
894 la $t9, artReadBarrierSlow
895 jalr $t9 # artReadBarrierSlow(ref, rObj, offset)
Man Cao1aee9002015-07-14 22:31:42 -0700896 addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack
897 # before the call to artReadBarrierSlow.
898 addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow
899 # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
900 move \rDest, $v0 # save return value in rDest
901 # (rDest cannot be v0 in art_quick_aput_obj)
902
903 lw $a0, 0($sp) # restore registers except rDest
904 # (rDest can only be t0 or t1 in art_quick_aput_obj)
905 .cfi_restore 4
906 lw $a1, 4($sp)
907 .cfi_restore 5
908 lw $a2, 8($sp)
909 .cfi_restore 6
910 POP_REG_NE $t0, 8, 16, \rDest
911 POP_REG_NE $t1, 9, 20, \rDest
912 lw $t9, 24($sp)
913 .cfi_restore 25
914 lw $ra, 28($sp) # restore $ra
915 .cfi_restore 31
916 addiu $sp, $sp, 32
917 .cfi_adjust_cfa_offset -32
918#else
919 lw \rDest, \offset(\rObj)
920 UNPOISON_HEAP_REF \rDest
921#endif // USE_READ_BARRIER
922.endm
923
924 /*
Ian Rogersa9a82542013-10-04 11:17:26 -0700925 * Entry from managed code for array put operations of objects where the value being stored
926 * needs to be checked for compatibility.
927 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -0800928 */
Ian Rogersa9a82542013-10-04 11:17:26 -0700929ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -0800930 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700931 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800932 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700933 nop
934END art_quick_aput_obj_with_null_and_bound_check
935
936ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700937 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700938 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -0800939 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700940 nop
941 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -0800942 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -0700943 move $a1, $t0
944END art_quick_aput_obj_with_bound_check
945
Man Cao1aee9002015-07-14 22:31:42 -0700946#ifdef USE_READ_BARRIER
947 .extern artReadBarrierSlow
948#endif
Ian Rogersa9a82542013-10-04 11:17:26 -0700949ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -0800950 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -0700951 nop
Man Cao1aee9002015-07-14 22:31:42 -0700952 READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
953 READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
954 READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogers86bcdc22014-02-21 22:06:38 -0800955 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -0700956 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800957.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -0700958 sll $a1, $a1, 2
959 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -0700960 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700961 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -0700962 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
963 srl $t1, $a0, 7
964 add $t1, $t1, $t0
965 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -0800966 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700967 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800968.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -0700969 sll $a1, $a1, 2
970 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700971 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -0800972 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -0700973 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -0800974.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -0700975 addiu $sp, $sp, -32
976 .cfi_adjust_cfa_offset 32
977 sw $ra, 28($sp)
978 .cfi_rel_offset 31, 28
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100979 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -0700980 sw $t9, 12($sp)
981 sw $a2, 8($sp)
982 sw $a1, 4($sp)
983 sw $a0, 0($sp)
984 move $a1, $t1
985 move $a0, $t0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100986 la $t9, artIsAssignableFromCode
987 jalr $t9 # (Class*, Class*)
988 addiu $sp, $sp, -16 # reserve argument slots on the stack
989 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -0700990 lw $ra, 28($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100991 lw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -0700992 lw $t9, 12($sp)
993 lw $a2, 8($sp)
994 lw $a1, 4($sp)
995 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -0800996 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -0700997 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -0800998 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -0700999 nop
1000 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1001 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -07001002 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -08001003 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001004 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -07001005END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -08001006
buzbee5bc5a7b2012-03-07 15:52:59 -08001007 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001008 * Called by managed code to resolve a static field and load a boolean primitive value.
1009 */
1010 .extern artGetBooleanStaticFromCode
1011ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -07001012 lw $a1, 0($sp) # pass referrer's Method*
1013 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001014 la $t9, artGetBooleanStaticFromCode
1015 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001016 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001017 RETURN_IF_NO_EXCEPTION
1018END art_quick_get_boolean_static
1019 /*
1020 * Called by managed code to resolve a static field and load a byte primitive value.
1021 */
1022 .extern artGetByteStaticFromCode
1023ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -07001024 lw $a1, 0($sp) # pass referrer's Method*
1025 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001026 la $t9, artGetByteStaticFromCode
1027 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001028 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001029 RETURN_IF_NO_EXCEPTION
1030END art_quick_get_byte_static
1031
1032 /*
1033 * Called by managed code to resolve a static field and load a char primitive value.
1034 */
1035 .extern artGetCharStaticFromCode
1036ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -07001037 lw $a1, 0($sp) # pass referrer's Method*
1038 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001039 la $t9, artGetCharStaticFromCode
1040 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001041 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001042 RETURN_IF_NO_EXCEPTION
1043END art_quick_get_char_static
1044 /*
1045 * Called by managed code to resolve a static field and load a short primitive value.
1046 */
1047 .extern artGetShortStaticFromCode
1048ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -07001049 lw $a1, 0($sp) # pass referrer's Method*
1050 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001051 la $t9, artGetShortStaticFromCode
1052 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001053 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001054 RETURN_IF_NO_EXCEPTION
1055END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001056
buzbee5bc5a7b2012-03-07 15:52:59 -08001057 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001058 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001059 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001060 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001061ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001062 lw $a1, 0($sp) # pass referrer's Method*
1063 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001064 la $t9, artGet32StaticFromCode
1065 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001066 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001067 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001068END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001069
buzbee5bc5a7b2012-03-07 15:52:59 -08001070 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001071 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001072 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001073 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001074ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001075 lw $a1, 0($sp) # pass referrer's Method*
1076 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001077 la $t9, artGet64StaticFromCode
1078 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001079 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001080 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001081END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001082
buzbee5bc5a7b2012-03-07 15:52:59 -08001083 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001084 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001085 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001086 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001087ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001088 lw $a1, 0($sp) # pass referrer's Method*
1089 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001090 la $t9, artGetObjStaticFromCode
1091 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001092 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001093 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001094END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001095
buzbee5bc5a7b2012-03-07 15:52:59 -08001096 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001097 * Called by managed code to resolve an instance field and load a boolean primitive value.
1098 */
1099 .extern artGetBooleanInstanceFromCode
1100ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001101 lw $a2, 0($sp) # pass referrer's Method*
1102 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001103 la $t9, artGetBooleanInstanceFromCode
1104 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001105 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001106 RETURN_IF_NO_EXCEPTION
1107END art_quick_get_boolean_instance
1108 /*
1109 * Called by managed code to resolve an instance field and load a byte primitive value.
1110 */
1111 .extern artGetByteInstanceFromCode
1112ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001113 lw $a2, 0($sp) # pass referrer's Method*
1114 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001115 la $t9, artGetByteInstanceFromCode
1116 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001117 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001118 RETURN_IF_NO_EXCEPTION
1119END art_quick_get_byte_instance
1120
1121 /*
1122 * Called by managed code to resolve an instance field and load a char primitive value.
1123 */
1124 .extern artGetCharInstanceFromCode
1125ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001126 lw $a2, 0($sp) # pass referrer's Method*
1127 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001128 la $t9, artGetCharInstanceFromCode
1129 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001130 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001131 RETURN_IF_NO_EXCEPTION
1132END art_quick_get_char_instance
1133 /*
1134 * Called by managed code to resolve an instance field and load a short primitive value.
1135 */
1136 .extern artGetShortInstanceFromCode
1137ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001138 lw $a2, 0($sp) # pass referrer's Method*
1139 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001140 la $t9, artGetShortInstanceFromCode
1141 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001142 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001143 RETURN_IF_NO_EXCEPTION
1144END art_quick_get_short_instance
1145
1146 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001147 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001148 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001149 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001150ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001151 lw $a2, 0($sp) # pass referrer's Method*
1152 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001153 la $t9, artGet32InstanceFromCode
1154 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001155 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001156 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001157END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001158
buzbee5bc5a7b2012-03-07 15:52:59 -08001159 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001160 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001161 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001162 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001163ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001164 lw $a2, 0($sp) # pass referrer's Method*
1165 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001166 la $t9, artGet64InstanceFromCode
1167 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001168 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001169 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001170END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001171
buzbee5bc5a7b2012-03-07 15:52:59 -08001172 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001173 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001174 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001175 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001176ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001177 lw $a2, 0($sp) # pass referrer's Method*
1178 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001179 la $t9, artGetObjInstanceFromCode
1180 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001181 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001182 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001183END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001184
buzbee5bc5a7b2012-03-07 15:52:59 -08001185 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001186 * Called by managed code to resolve a static field and store a 8-bit primitive value.
1187 */
1188 .extern artSet8StaticFromCode
1189ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -07001190 lw $a2, 0($sp) # pass referrer's Method*
1191 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001192 la $t9, artSet8StaticFromCode
1193 jalr $t9 # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001194 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001195 RETURN_IF_ZERO
1196END art_quick_set8_static
1197
1198 /*
1199 * Called by managed code to resolve a static field and store a 16-bit primitive value.
1200 */
1201 .extern artSet16StaticFromCode
1202ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -07001203 lw $a2, 0($sp) # pass referrer's Method*
1204 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001205 la $t9, artSet16StaticFromCode
1206 jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001207 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001208 RETURN_IF_ZERO
1209END art_quick_set16_static
1210
1211 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001212 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001213 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001214 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001215ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001216 lw $a2, 0($sp) # pass referrer's Method*
1217 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001218 la $t9, artSet32StaticFromCode
1219 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001220 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001221 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001222END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001223
buzbee5bc5a7b2012-03-07 15:52:59 -08001224 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001225 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001226 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001227 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001228ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001229 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001230 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -07001231 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001232 la $t9, artSet64StaticFromCode
1233 jalr $t9 # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001234 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001235 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001236END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001237
buzbee5bc5a7b2012-03-07 15:52:59 -08001238 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001239 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001240 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001241 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001242ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001243 lw $a2, 0($sp) # pass referrer's Method*
1244 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001245 la $t9, artSetObjStaticFromCode
1246 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001247 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001248 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001249END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001250
buzbee5bc5a7b2012-03-07 15:52:59 -08001251 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001252 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1253 */
1254 .extern artSet8InstanceFromCode
1255ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001256 lw $a3, 0($sp) # pass referrer's Method*
1257 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001258 la $t9, artSet8InstanceFromCode
1259 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001260 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001261 RETURN_IF_ZERO
1262END art_quick_set8_instance
1263
1264 /*
1265 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1266 */
1267 .extern artSet16InstanceFromCode
1268ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001269 lw $a3, 0($sp) # pass referrer's Method*
1270 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001271 la $t9, artSet16InstanceFromCode
1272 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001273 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001274 RETURN_IF_ZERO
1275END art_quick_set16_instance
1276
1277 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001278 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001279 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001280 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001281ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001282 lw $a3, 0($sp) # pass referrer's Method*
1283 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001284 la $t9, artSet32InstanceFromCode
1285 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001286 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001287 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001288END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001289
buzbee5bc5a7b2012-03-07 15:52:59 -08001290 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001291 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001292 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001293 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001294ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001295 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001296 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -07001297 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001298 sw rSELF, 20($sp) # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001299 la $t9, artSet64InstanceFromCode
1300 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001301 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001302 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001303END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001304
buzbee5bc5a7b2012-03-07 15:52:59 -08001305 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001306 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001307 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001308 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001309ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001310 lw $a3, 0($sp) # pass referrer's Method*
1311 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001312 la $t9, artSetObjInstanceFromCode
1313 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001314 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001315 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001316END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001317
Vladimir Markoa3c38272015-04-28 12:37:09 +01001318// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001319.macro ONE_ARG_DOWNCALL name, entrypoint, return
1320 .extern \entrypoint
1321ENTRY \name
1322 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001323 la $t9, \entrypoint
1324 jalr $t9
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001325 move $a1, rSELF # pass Thread::Current
1326 \return
1327END \name
1328.endm
1329
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001330.macro TWO_ARG_DOWNCALL name, entrypoint, return
1331 .extern \entrypoint
1332ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001333 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001334 la $t9, \entrypoint
1335 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001336 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001337 \return
1338END \name
1339.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001340
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001341.macro THREE_ARG_DOWNCALL name, entrypoint, return
1342 .extern \entrypoint
1343ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001344 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001345 la $t9, \entrypoint
1346 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001347 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001348 \return
1349END \name
1350.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001351
Jeff Hao848f70a2014-01-15 13:49:50 -08001352.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1353 .extern \entrypoint
1354ENTRY \name
Vladimir Markoa3c38272015-04-28 12:37:09 +01001355 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001356 la $t9, \entrypoint
1357 jalr $t9
Vladimir Markoa3c38272015-04-28 12:37:09 +01001358 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001359 \return
1360END \name
1361.endm
1362
Mathieu Chartier7410f292013-11-24 13:17:35 -08001363// Generate the allocation entrypoints for each allocator.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001364GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001365
Pavle Batuta712c59d2015-12-02 18:39:01 +01001366// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1367ENTRY art_quick_alloc_object_rosalloc
1368
1369 # Fast path rosalloc allocation
1370 # a0: type_idx
1371 # a1: ArtMethod*
1372 # s1: Thread::Current
1373 # -----------------------------
1374 # t0: class
1375 # t1: object size
1376 # t2: rosalloc run
1377 # t3: thread stack top offset
1378 # t4: thread stack bottom offset
1379 # v0: free list head
1380 #
1381 # t5, t6 : temps
1382
1383 lw $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_32($a1) # Load dex cache resolved types
1384 # array.
1385
1386 sll $t5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT # Shift the value.
1387 addu $t5, $t0, $t5 # Compute the index.
1388 lw $t0, 0($t5) # Load class (t0).
1389 beqz $t0, .Lart_quick_alloc_object_rosalloc_slow_path
1390
1391 li $t6, MIRROR_CLASS_STATUS_INITIALIZED
1392 lw $t5, MIRROR_CLASS_STATUS_OFFSET($t0) # Check class status.
1393 bne $t5, $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1394
1395 # Add a fake dependence from the following access flag and size loads to the status load. This
1396 # is to prevent those loads from being reordered above the status load and reading wrong values.
1397 xor $t5, $t5, $t5
1398 addu $t0, $t0, $t5
1399
1400 lw $t5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0) # Check if access flags has
1401 li $t6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE # kAccClassIsFinalizable.
1402 and $t6, $t5, $t6
1403 bnez $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1404
1405 lw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) # Check if thread local allocation
1406 lw $t4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1) # stack has any room left.
1407 bgeu $t3, $t4, .Lart_quick_alloc_object_rosalloc_slow_path
1408
1409 lw $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0) # Load object size (t1).
1410 li $t5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE # Check if size is for a thread local
1411 # allocation.
1412 bgtu $t1, $t5, .Lart_quick_alloc_object_rosalloc_slow_path
1413
1414 # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket
1415 # quantum size and divide by the quantum size and subtract by 1.
1416
1417 addiu $t1, $t1, -1 # Decrease obj size and shift right
1418 srl $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT # by quantum.
1419
1420 sll $t2, $t1, POINTER_SIZE_SHIFT
1421 addu $t2, $t2, $s1
1422 lw $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2) # Load rosalloc run (t2).
1423
1424 # Load the free list head (v0).
1425 # NOTE: this will be the return val.
1426
1427 lw $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1428 beqz $v0, .Lart_quick_alloc_object_rosalloc_slow_path
1429 nop
1430
1431 # Load the next pointer of the head and update the list head with the next pointer.
1432
1433 lw $t5, ROSALLOC_SLOT_NEXT_OFFSET($v0)
1434 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1435
1436 # Store the class pointer in the header. This also overwrites the first pointer. The offsets are
1437 # asserted to match.
1438
1439#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1440#error "Class pointer needs to overwrite next pointer."
1441#endif
1442
1443 POISON_HEAP_REF $t0
1444 sw $t0, MIRROR_OBJECT_CLASS_OFFSET($v0)
1445
1446 # Push the new object onto the thread local allocation stack and increment the thread local
1447 # allocation stack top.
1448
1449 sw $v0, 0($t3)
1450 addiu $t3, $t3, COMPRESSED_REFERENCE_SIZE
1451 sw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)
1452
1453 # Decrement the size of the free list.
1454
1455 lw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1456 addiu $t5, $t5, -1
1457 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1458
1459 sync # Fence.
1460
1461 jalr $zero, $ra
1462 nop
1463
1464 .Lart_quick_alloc_object_rosalloc_slow_path:
1465
1466 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001467 la $t9, artAllocObjectFromCodeRosAlloc
1468 jalr $t9
Chris Larsencf283da2016-01-19 16:45:35 -08001469 move $a2, $s1 # Pass self as argument.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001470 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1471
1472END art_quick_alloc_object_rosalloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001473
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001474GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB)
1475GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB)
1476
buzbee5bc5a7b2012-03-07 15:52:59 -08001477 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001478 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001479 * exception on error. On success the String is returned. A0 holds the string index. The fast
1480 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001481 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001482ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001483
1484 /*
1485 * Entry from managed code when uninitialized static storage, this stub will run the class
1486 * initializer and deliver the exception on error. On success the static storage base is
1487 * returned.
1488 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001489ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001490
1491 /*
1492 * Entry from managed code when dex cache misses for a type_idx.
1493 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001494ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001495
1496 /*
1497 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1498 * miss.
1499 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001500ONE_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 -08001501
1502 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001503 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001504 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001505 .extern artTestSuspendFromCode
1506ENTRY art_quick_test_suspend
Ian Rogers474b6da2012-09-25 00:20:38 -07001507 lh $a0, THREAD_FLAGS_OFFSET(rSELF)
jeffhao7fbee072012-08-24 17:56:54 -07001508 bnez $a0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001509 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001510 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001511 nop
15121:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001513 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves for stack crawl
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001514 la $t9, artTestSuspendFromCode
1515 jalr $t9 # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001516 move $a0, rSELF
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001517 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001518END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001519
buzbee5bc5a7b2012-03-07 15:52:59 -08001520 /*
1521 * Called by managed code that is attempting to call a method on a proxy class. On entry
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001522 * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001523 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001524 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001525ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001526 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1527 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001528 la $t9, artQuickProxyInvokeHandler
1529 jalr $t9 # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001530 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001531 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001532 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001533 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001534 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1535 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001536 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001537 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080015381:
1539 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001540END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001541
Jeff Hao88474b42013-10-23 16:24:40 -07001542 /*
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001543 * Called to resolve an imt conflict.
1544 * a0 is the conflict ArtMethod.
1545 * t0 is a hidden argument that holds the target interface method's dex method index.
1546 *
1547 * Note that this stub writes to a0, t0 and t1.
Jeff Hao88474b42013-10-23 16:24:40 -07001548 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001549ENTRY art_quick_imt_conflict_trampoline
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001550 lw $t1, 0($sp) # Load referrer.
1551 lw $t1, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t1) # Load dex cache methods array.
1552 sll $t0, $t0, POINTER_SIZE_SHIFT # Calculate offset.
1553 addu $t0, $t1, $t0 # Add offset to base.
1554 lw $t0, 0($t0) # Load interface method.
1555 lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable.
1556
1557.Limt_table_iterate:
1558 lw $t1, 0($a0) # Load next entry in ImtConflictTable.
1559 # Branch if found.
1560 beq $t1, $t0, .Limt_table_found
1561 nop
1562 # If the entry is null, the interface method is not in the ImtConflictTable.
1563 beqz $t1, .Lconflict_trampoline
1564 nop
1565 # Iterate over the entries of the ImtConflictTable.
1566 b .Limt_table_iterate
1567 addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry.
1568
1569.Limt_table_found:
1570 # We successfully hit an entry in the table. Load the target method and jump to it.
1571 lw $a0, __SIZEOF_POINTER__($a0)
1572 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
1573 jr $t9
1574 nop
1575
1576.Lconflict_trampoline:
1577 # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001578 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001579END art_quick_imt_conflict_trampoline
1580
Ian Rogers468532e2013-08-05 10:56:33 -07001581 .extern artQuickResolutionTrampoline
1582ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001583 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001584 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001585 la $t9, artQuickResolutionTrampoline
1586 jalr $t9 # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001587 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001588 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001589 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001590 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001591 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001592 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001593 nop
Ian Rogers468532e2013-08-05 10:56:33 -070015941:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001595 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001596 DELIVER_PENDING_EXCEPTION
1597END art_quick_resolution_trampoline
1598
Douglas Leung735b8552014-10-31 12:21:40 -07001599 .extern artQuickGenericJniTrampoline
1600 .extern artQuickGenericJniEndTrampoline
1601ENTRY art_quick_generic_jni_trampoline
1602 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1603 move $s8, $sp # save $sp to $s8
1604 move $s3, $gp # save $gp to $s3
1605
1606 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1607 move $a0, rSELF # pass Thread::Current
1608 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001609 la $t9, artQuickGenericJniTrampoline
1610 jalr $t9 # (Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001611 addiu $sp, $sp, -5120 # reserve space on the stack
1612
1613 # The C call will have registered the complete save-frame on success.
1614 # The result of the call is:
1615 # v0: ptr to native code, 0 on error.
1616 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1617 beq $v0, $zero, 1f # check entry error
1618 move $t9, $v0 # save the code ptr
1619 move $sp, $v1 # release part of the alloca
1620
1621 # Load parameters from stack into registers
1622 lw $a0, 0($sp)
1623 lw $a1, 4($sp)
1624 lw $a2, 8($sp)
1625
1626 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1627 jalr $t9 # native call
1628 lw $a3, 12($sp)
1629 addiu $sp, $sp, 16 # remove arg slots
1630
1631 move $gp, $s3 # restore $gp from $s3
1632
1633 # result sign extension is handled in C code
1634 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1635 move $a0, rSELF # pass Thread::Current
1636 move $a2, $v0 # pass result
1637 move $a3, $v1
1638 addiu $sp, $sp, -24 # reserve arg slots
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001639 la $t9, artQuickGenericJniEndTrampoline
1640 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001641 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001642
1643 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001644 bne $t0, $zero, 1f # check for pending exceptions
1645
Douglas Leung735b8552014-10-31 12:21:40 -07001646 move $sp, $s8 # tear down the alloca
1647
1648 # tear dpown the callee-save frame
1649 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1650
Duane Sande34652f2014-11-04 11:09:36 -08001651 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001652 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001653 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001654
16551:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001656 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1657 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07001658 DELIVER_PENDING_EXCEPTION
1659END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08001660
Ian Rogers468532e2013-08-05 10:56:33 -07001661 .extern artQuickToInterpreterBridge
1662ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001663 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001664 move $a1, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001665 la $t9, artQuickToInterpreterBridge
1666 jalr $t9 # (Method* method, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001667 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08001668 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001669 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08001670 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001671 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1672 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001673 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001674 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080016751:
1676 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001677END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08001678
buzbee5bc5a7b2012-03-07 15:52:59 -08001679 /*
jeffhao725a9572012-11-13 18:20:12 -08001680 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08001681 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001682 .extern artInstrumentationMethodEntryFromCode
1683 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001684ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001685 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001686 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001687 move $a3, $ra # pass $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001688 la $t9, artInstrumentationMethodEntryFromCode
1689 jalr $t9 # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08001690 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07001691 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07001692 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001693 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07001694 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08001695 nop
Ian Rogers468532e2013-08-05 10:56:33 -07001696END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08001697 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07001698 .global art_quick_instrumentation_exit
1699art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001700 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08001701 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001702 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07001703 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07001704
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001705 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001706 addiu $sp, $sp, -16 # allocate temp storage on the stack
1707 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001708 sw $v0, ARG_SLOT_SIZE+12($sp)
1709 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
1710 sw $v1, ARG_SLOT_SIZE+8($sp)
1711 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
1712 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001713 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08001714 move $a2, $v0 # pass gpr result
1715 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001716 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001717 la $t9, artInstrumentationMethodExitFromCode
1718 jalr $t9 # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08001719 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001720 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08001721 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001722 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
1723 lw $v1, ARG_SLOT_SIZE+8($sp)
1724 l.d $f0, ARG_SLOT_SIZE($sp)
1725 jalr $zero, $t9 # return
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001726 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16 # restore stack
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001727 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16)
Ian Rogers468532e2013-08-05 10:56:33 -07001728END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08001729
jeffhao12051ea2013-01-10 11:24:31 -08001730 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08001731 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
1732 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08001733 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001734 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001735ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07001736 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001737 la $t9, artDeoptimize
1738 jalr $t9 # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08001739 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001740 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001741END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08001742
buzbee5bc5a7b2012-03-07 15:52:59 -08001743 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00001744 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
1745 * will long jump to the upcall with a special exception of -1.
1746 */
1747 .extern artDeoptimizeFromCompiledCode
1748ENTRY art_quick_deoptimize_from_compiled_code
1749 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001750 la $t9, artDeoptimizeFromCompiledCode
1751 jalr $t9 # artDeoptimizeFromCompiledCode(Thread*)
Sebastien Hertz07474662015-08-25 15:12:33 +00001752 # Returns caller method's frame size.
1753 move $a0, rSELF # pass Thread::current
1754END art_quick_deoptimize_from_compiled_code
1755
1756 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08001757 * Long integer shift. This is different from the generic 32/64-bit
1758 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1759 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1760 * 6 bits.
1761 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001762 * $a0: low word
1763 * $a1: high word
1764 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001765 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001766ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001767 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07001768 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
1769 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
1770 srl $a0, 1
1771 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
1772 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001773 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001774 beqz $a2, 1f
1775 or $v1, $a0 # rhi<- rhi | alo
1776
1777 move $v1, $v0 # rhi<- rlo (if shift&0x20)
1778 move $v0, $zero # rlo<- 0 (if shift&0x20)
1779
Andreas Gampe8d365912015-01-13 11:32:32 -080017801: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001781 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001782END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001783
buzbee5bc5a7b2012-03-07 15:52:59 -08001784 /*
1785 * Long integer shift. This is different from the generic 32/64-bit
1786 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1787 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1788 * 6 bits.
1789 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07001790 * $a0: low word
1791 * $a1: high word
1792 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001793 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001794ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07001795 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
1796 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
1797 sra $a3, $a1, 31 # $a3<- sign(ah)
1798 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1799 sll $a1, 1
1800 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001801 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08001802 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001803 or $v0, $a1 # rlo<- rlo | ahi
1804
1805 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1806 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
1807
Andreas Gampe8d365912015-01-13 11:32:32 -080018081: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001809 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001810END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08001811
buzbee5bc5a7b2012-03-07 15:52:59 -08001812 /*
1813 * Long integer shift. This is different from the generic 32/64-bit
1814 * binary operations because vAA/vBB are 64-bit but vCC (the shift
1815 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
1816 * 6 bits.
1817 * On entry:
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001818 * $a0: low word
1819 * $a1: high word
1820 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08001821 */
1822 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001823ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07001824 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001825 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07001826 not $a0, $a2 # alo<- 31-shift (shift is 5b)
1827 sll $a1, 1
1828 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07001829 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08001830 beqz $a2, 1f
1831 or $v0, $a1 # rlo<- rlo | ahi
1832
1833 move $v0, $v1 # rlo<- rhi (if shift&0x20)
1834 move $v1, $zero # rhi<- 0 (if shift&0x20)
1835
Andreas Gampe8d365912015-01-13 11:32:32 -080018361: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001837 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001838END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07001839
Chris Larsencf283da2016-01-19 16:45:35 -08001840/* java.lang.String.indexOf(int ch, int fromIndex=0) */
1841ENTRY_NO_GP art_quick_indexof
1842/* $a0 holds address of "this" */
1843/* $a1 holds "ch" */
1844/* $a2 holds "fromIndex" */
1845 lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001846 slt $t1, $a2, $zero # if fromIndex < 0
Chris Larsencf283da2016-01-19 16:45:35 -08001847#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001848 seleqz $a2, $a2, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08001849#else
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001850 movn $a2, $zero, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08001851#endif
1852 subu $t0, $t0, $a2 # this.length() - fromIndex
1853 blez $t0, 6f # if this.length()-fromIndex <= 0
1854 li $v0, -1 # return -1;
1855
1856 sll $v0, $a2, 1 # $a0 += $a2 * 2
1857 addu $a0, $a0, $v0 # " " " " "
1858 move $v0, $a2 # Set i to fromIndex.
1859
18601:
1861 lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch
1862 beq $t3, $a1, 6f # return i;
1863 addu $a0, $a0, 2 # i++
1864 subu $t0, $t0, 1 # this.length() - i
1865 bnez $t0, 1b # while this.length() - i > 0
1866 addu $v0, $v0, 1 # i++
1867
1868 li $v0, -1 # if this.length() - i <= 0
1869 # return -1;
1870
18716:
1872 j $ra
1873 nop
1874END art_quick_indexof
1875
Chris Larsencf283da2016-01-19 16:45:35 -08001876/* java.lang.String.compareTo(String anotherString) */
1877ENTRY_NO_GP art_quick_string_compareto
1878/* $a0 holds address of "this" */
1879/* $a1 holds address of "anotherString" */
1880 beq $a0, $a1, 9f # this and anotherString are the same object
1881 move $v0, $zero
1882
1883 lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
1884 lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length()
1885 MINu $t2, $a2, $a3
1886# $t2 now holds min(this.length(),anotherString.length())
1887
1888 beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0
1889 subu $v0, $a2, $a3 # if $t2==0 return
1890 # (this.length() - anotherString.length())
18911:
1892 lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i)
1893 lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1)
1894 bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i)
1895 subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i))
1896 addiu $a0, $a0, 2 # point at this.charAt(i++)
1897 subu $t2, $t2, 1 # new value of
1898 # min(this.length(),anotherString.length())-i
1899 bnez $t2, 1b
1900 addiu $a1, $a1, 2 # point at anotherString.charAt(i++)
1901 subu $v0, $a2, $a3
1902
19039:
1904 j $ra
1905 nop
1906END art_quick_string_compareto