blob: b926bdfb9f74961f65f34ffaa58c88659cf8cbdc [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 /*
Vladimir Marko952dbb12016-07-28 12:01:51 +0100280 * Macro that sets up the callee save frame to conform with
281 * Runtime::CreateCalleeSaveMethod(kSaveEverything).
282 * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31;
283 * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method*
284 * Clobbers $t0 and $t1.
285 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
286 * Reserves FRAME_SIZE_SAVE_EVERYTHING_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack.
287 * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP.
288 */
289.macro SETUP_SAVE_EVERYTHING_CALLEE_SAVE_FRAME
290 addiu $sp, $sp, -256
291 .cfi_adjust_cfa_offset 256
292
293 // Ugly compile-time check, but we only have the preprocessor.
294#if (FRAME_SIZE_SAVE_EVERYTHING_CALLEE_SAVE != 256)
295#error "SAVE_EVERYTHING_CALLEE_SAVE_FRAME(MIPS) size not as expected."
296#endif
297
298 sw $ra, 252($sp)
299 .cfi_rel_offset 31, 252
300 sw $fp, 248($sp)
301 .cfi_rel_offset 30, 248
302 sw $gp, 244($sp)
303 .cfi_rel_offset 28, 244
304 sw $t9, 240($sp)
305 .cfi_rel_offset 25, 240
306 sw $t8, 236($sp)
307 .cfi_rel_offset 24, 236
308 sw $s7, 232($sp)
309 .cfi_rel_offset 23, 232
310 sw $s6, 228($sp)
311 .cfi_rel_offset 22, 228
312 sw $s5, 224($sp)
313 .cfi_rel_offset 21, 224
314 sw $s4, 220($sp)
315 .cfi_rel_offset 20, 220
316 sw $s3, 216($sp)
317 .cfi_rel_offset 19, 216
318 sw $s2, 212($sp)
319 .cfi_rel_offset 18, 212
320 sw $s1, 208($sp)
321 .cfi_rel_offset 17, 208
322 sw $s0, 204($sp)
323 .cfi_rel_offset 16, 204
324 sw $t7, 200($sp)
325 .cfi_rel_offset 15, 200
326 sw $t6, 196($sp)
327 .cfi_rel_offset 14, 196
328 sw $t5, 192($sp)
329 .cfi_rel_offset 13, 192
330 sw $t4, 188($sp)
331 .cfi_rel_offset 12, 188
332 sw $t3, 184($sp)
333 .cfi_rel_offset 11, 184
334 sw $t2, 180($sp)
335 .cfi_rel_offset 10, 180
336 sw $t1, 176($sp)
337 .cfi_rel_offset 9, 176
338 sw $t0, 172($sp)
339 .cfi_rel_offset 8, 172
340 sw $a3, 168($sp)
341 .cfi_rel_offset 7, 168
342 sw $a2, 164($sp)
343 .cfi_rel_offset 6, 164
344 sw $a1, 160($sp)
345 .cfi_rel_offset 5, 160
346 sw $a0, 156($sp)
347 .cfi_rel_offset 4, 156
348 sw $v1, 152($sp)
349 .cfi_rel_offset 3, 152
350 sw $v0, 148($sp)
351 .cfi_rel_offset 2, 148
352
353 // Set up $gp, clobbering $ra and using the branch delay slot for a useful instruction.
354 bal 1f
355 sw $at, 144($sp)
356 .cfi_rel_offset 1, 144
3571:
358 .cpload $ra
359
360 SDu $f30, $f31, 136, $sp, $t1
361 SDu $f28, $f29, 128, $sp, $t1
362 SDu $f26, $f27, 120, $sp, $t1
363 SDu $f24, $f25, 112, $sp, $t1
364 SDu $f22, $f23, 104, $sp, $t1
365 SDu $f20, $f21, 96, $sp, $t1
366 SDu $f18, $f19, 88, $sp, $t1
367 SDu $f16, $f17, 80, $sp, $t1
368 SDu $f14, $f15, 72, $sp, $t1
369 SDu $f12, $f13, 64, $sp, $t1
370 SDu $f10, $f11, 56, $sp, $t1
371 SDu $f8, $f9, 48, $sp, $t1
372 SDu $f6, $f7, 40, $sp, $t1
373 SDu $f4, $f5, 32, $sp, $t1
374 SDu $f2, $f3, 24, $sp, $t1
375 SDu $f0, $f1, 16, $sp, $t1
376
377 # 3 words padding and 1 word for holding Method*
378
379 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
380 lw $t0, 0($t0)
381 lw $t0, RUNTIME_SAVE_EVERYTHING_CALLEE_SAVE_FRAME_OFFSET($t0)
382 sw $t0, 0($sp) # Place Method* at bottom of stack.
383 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
384 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
385 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
386.endm
387
388.macro RESTORE_SAVE_EVERYTHING_CALLEE_SAVE_FRAME
389 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
390 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
391
392 LDu $f30, $f31, 136, $sp, $t1
393 LDu $f28, $f29, 128, $sp, $t1
394 LDu $f26, $f27, 120, $sp, $t1
395 LDu $f24, $f25, 112, $sp, $t1
396 LDu $f22, $f23, 104, $sp, $t1
397 LDu $f20, $f21, 96, $sp, $t1
398 LDu $f18, $f19, 88, $sp, $t1
399 LDu $f16, $f17, 80, $sp, $t1
400 LDu $f14, $f15, 72, $sp, $t1
401 LDu $f12, $f13, 64, $sp, $t1
402 LDu $f10, $f11, 56, $sp, $t1
403 LDu $f8, $f9, 48, $sp, $t1
404 LDu $f6, $f7, 40, $sp, $t1
405 LDu $f4, $f5, 32, $sp, $t1
406 LDu $f2, $f3, 24, $sp, $t1
407 LDu $f0, $f1, 16, $sp, $t1
408
409 lw $ra, 252($sp)
410 .cfi_restore 31
411 lw $fp, 248($sp)
412 .cfi_restore 30
413 lw $gp, 244($sp)
414 .cfi_restore 28
415 lw $t9, 240($sp)
416 .cfi_restore 25
417 lw $t8, 236($sp)
418 .cfi_restore 24
419 lw $s7, 232($sp)
420 .cfi_restore 23
421 lw $s6, 228($sp)
422 .cfi_restore 22
423 lw $s5, 224($sp)
424 .cfi_restore 21
425 lw $s4, 220($sp)
426 .cfi_restore 20
427 lw $s3, 216($sp)
428 .cfi_restore 19
429 lw $s2, 212($sp)
430 .cfi_restore 18
431 lw $s1, 208($sp)
432 .cfi_restore 17
433 lw $s0, 204($sp)
434 .cfi_restore 16
435 lw $t7, 200($sp)
436 .cfi_restore 15
437 lw $t6, 196($sp)
438 .cfi_restore 14
439 lw $t5, 192($sp)
440 .cfi_restore 13
441 lw $t4, 188($sp)
442 .cfi_restore 12
443 lw $t3, 184($sp)
444 .cfi_restore 11
445 lw $t2, 180($sp)
446 .cfi_restore 10
447 lw $t1, 176($sp)
448 .cfi_restore 9
449 lw $t0, 172($sp)
450 .cfi_restore 8
451 lw $a3, 168($sp)
452 .cfi_restore 7
453 lw $a2, 164($sp)
454 .cfi_restore 6
455 lw $a1, 160($sp)
456 .cfi_restore 5
457 lw $a0, 156($sp)
458 .cfi_restore 4
459 lw $v1, 152($sp)
460 .cfi_restore 3
461 lw $v0, 148($sp)
462 .cfi_restore 2
463 lw $at, 144($sp)
464 .cfi_restore 1
465
466 addiu $sp, $sp, 256 # pop frame
467 .cfi_adjust_cfa_offset -256
468.endm
469
470 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800471 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
472 * exception is Thread::Current()->exception_
473 */
474.macro DELIVER_PENDING_EXCEPTION
jeffhao8161c032012-10-31 15:50:00 -0700475 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700476 la $t9, artDeliverPendingExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800477 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700478 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800479.endm
480
481.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700482 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700483 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700484 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800485 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800486 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800487 nop
4881:
489 DELIVER_PENDING_EXCEPTION
490.endm
491
492.macro RETURN_IF_ZERO
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700493 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700494 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800495 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800496 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800497 nop
4981:
499 DELIVER_PENDING_EXCEPTION
500.endm
501
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800502.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700503 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700504 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800505 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800506 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800507 nop
5081:
509 DELIVER_PENDING_EXCEPTION
510.endm
511
buzbee5bc5a7b2012-03-07 15:52:59 -0800512 /*
Goran Jakovljevic3bc13812016-03-22 17:16:05 +0100513 * On stack replacement stub.
514 * On entry:
515 * a0 = stack to copy
516 * a1 = size of stack
517 * a2 = pc to call
518 * a3 = JValue* result
519 * [sp + 16] = shorty
520 * [sp + 20] = thread
521 */
522ENTRY art_quick_osr_stub
523 // Save callee general purpose registers, RA and GP.
524 addiu $sp, $sp, -48
525 .cfi_adjust_cfa_offset 48
526 sw $ra, 44($sp)
527 .cfi_rel_offset 31, 44
528 sw $s8, 40($sp)
529 .cfi_rel_offset 30, 40
530 sw $gp, 36($sp)
531 .cfi_rel_offset 28, 36
532 sw $s7, 32($sp)
533 .cfi_rel_offset 23, 32
534 sw $s6, 28($sp)
535 .cfi_rel_offset 22, 28
536 sw $s5, 24($sp)
537 .cfi_rel_offset 21, 24
538 sw $s4, 20($sp)
539 .cfi_rel_offset 20, 20
540 sw $s3, 16($sp)
541 .cfi_rel_offset 19, 16
542 sw $s2, 12($sp)
543 .cfi_rel_offset 18, 12
544 sw $s1, 8($sp)
545 .cfi_rel_offset 17, 8
546 sw $s0, 4($sp)
547 .cfi_rel_offset 16, 4
548
549 move $s8, $sp # Save the stack pointer
550 move $s7, $a1 # Save size of stack
551 move $s6, $a2 # Save the pc to call
552 lw rSELF, 48+20($sp) # Save managed thread pointer into rSELF
553 addiu $t0, $sp, -12 # Reserve space for stack pointer,
554 # JValue* result, and ArtMethod* slot.
555 srl $t0, $t0, 4 # Align stack pointer to 16 bytes
556 sll $sp, $t0, 4 # Update stack pointer
557 sw $s8, 4($sp) # Save old stack pointer
558 sw $a3, 8($sp) # Save JValue* result
559 sw $zero, 0($sp) # Store null for ArtMethod* at bottom of frame
560 subu $sp, $a1 # Reserve space for callee stack
561 move $a2, $a1
562 move $a1, $a0
563 move $a0, $sp
564 la $t9, memcpy
565 jalr $t9 # memcpy (dest a0, src a1, bytes a2)
566 addiu $sp, $sp, -16 # make space for argument slots for memcpy
567 bal .Losr_entry # Call the method
568 addiu $sp, $sp, 16 # restore stack after memcpy
569 lw $a2, 8($sp) # Restore JValue* result
570 lw $sp, 4($sp) # Restore saved stack pointer
571 lw $a0, 48+16($sp) # load shorty
572 lbu $a0, 0($a0) # load return type
573 li $a1, 'D' # put char 'D' into a1
574 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'D'
575 li $a1, 'F' # put char 'F' into a1
576 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'F'
577 nop
578 sw $v0, 0($a2)
579 b .Losr_exit
580 sw $v1, 4($a2) # store v0/v1 into result
581.Losr_fp_result:
582 SDu $f0, $f1, 0, $a2, $t0 # store f0/f1 into result
583.Losr_exit:
584 lw $ra, 44($sp)
585 .cfi_restore 31
586 lw $s8, 40($sp)
587 .cfi_restore 30
588 lw $gp, 36($sp)
589 .cfi_restore 28
590 lw $s7, 32($sp)
591 .cfi_restore 23
592 lw $s6, 28($sp)
593 .cfi_restore 22
594 lw $s5, 24($sp)
595 .cfi_restore 21
596 lw $s4, 20($sp)
597 .cfi_restore 20
598 lw $s3, 16($sp)
599 .cfi_restore 19
600 lw $s2, 12($sp)
601 .cfi_restore 18
602 lw $s1, 8($sp)
603 .cfi_restore 17
604 lw $s0, 4($sp)
605 .cfi_restore 16
606 jalr $zero, $ra
607 addiu $sp, $sp, 48
608 .cfi_adjust_cfa_offset -48
609.Losr_entry:
610 addiu $s7, $s7, -4
611 addu $t0, $s7, $sp
612 move $t9, $s6
613 jalr $zero, $t9
614 sw $ra, 0($t0) # Store RA per the compiler ABI
615END art_quick_osr_stub
616
617 /*
jeffhao7fbee072012-08-24 17:56:54 -0700618 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800619 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
620 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800621ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800622 LDu $f0, $f1, 0*8, $a1, $t1
623 LDu $f2, $f3, 1*8, $a1, $t1
624 LDu $f4, $f5, 2*8, $a1, $t1
625 LDu $f6, $f7, 3*8, $a1, $t1
626 LDu $f8, $f9, 4*8, $a1, $t1
627 LDu $f10, $f11, 5*8, $a1, $t1
628 LDu $f12, $f13, 6*8, $a1, $t1
629 LDu $f14, $f15, 7*8, $a1, $t1
630 LDu $f16, $f17, 8*8, $a1, $t1
631 LDu $f18, $f19, 9*8, $a1, $t1
632 LDu $f20, $f21, 10*8, $a1, $t1
633 LDu $f22, $f23, 11*8, $a1, $t1
634 LDu $f24, $f25, 12*8, $a1, $t1
635 LDu $f26, $f27, 13*8, $a1, $t1
636 LDu $f28, $f29, 14*8, $a1, $t1
637 LDu $f30, $f31, 15*8, $a1, $t1
638
Chris Dearman748dd952014-05-23 10:47:01 -0700639 .set push
640 .set nomacro
641 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700642 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700643 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700644 lw $v0, 8($a0)
645 lw $v1, 12($a0)
646 lw $a1, 20($a0)
647 lw $a2, 24($a0)
648 lw $a3, 28($a0)
649 lw $t0, 32($a0)
650 lw $t1, 36($a0)
651 lw $t2, 40($a0)
652 lw $t3, 44($a0)
653 lw $t4, 48($a0)
654 lw $t5, 52($a0)
655 lw $t6, 56($a0)
656 lw $t7, 60($a0)
657 lw $s0, 64($a0)
658 lw $s1, 68($a0)
659 lw $s2, 72($a0)
660 lw $s3, 76($a0)
661 lw $s4, 80($a0)
662 lw $s5, 84($a0)
663 lw $s6, 88($a0)
664 lw $s7, 92($a0)
665 lw $t8, 96($a0)
666 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700667 lw $gp, 112($a0)
668 lw $sp, 116($a0)
669 lw $fp, 120($a0)
670 lw $ra, 124($a0)
671 lw $a0, 16($a0)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100672 move $v0, $zero # clear result registers v0 and v1 (in branch delay slot)
Goran Jakovljevic75969962015-10-27 12:29:07 +0100673 jalr $zero, $t9 # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700674 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800675END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800676
buzbee5bc5a7b2012-03-07 15:52:59 -0800677 /*
678 * Called by managed code, saves most registers (forms basis of long jump context) and passes
679 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
Lazar Trsic84bc06e2015-06-10 16:05:46 +0200680 * the bottom of the thread. On entry a0 holds Throwable*
buzbee5bc5a7b2012-03-07 15:52:59 -0800681 */
Ian Rogers468532e2013-08-05 10:56:33 -0700682ENTRY art_quick_deliver_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700683 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700684 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800685 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700686 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700687END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800688
buzbee5bc5a7b2012-03-07 15:52:59 -0800689 /*
690 * Called by managed code to create and deliver a NullPointerException
691 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800692 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700693ENTRY art_quick_throw_null_pointer_exception
Ian Rogers57b86d42012-03-27 16:05:41 -0700694 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700695 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800696 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700697 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700698END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800699
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100700
701 /*
702 * Call installed by a signal handler to create and deliver a NullPointerException.
703 */
704 .extern artThrowNullPointerExceptionFromSignal
705ENTRY art_quick_throw_null_pointer_exception_from_signal
706 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
707 la $t9, artThrowNullPointerExceptionFromSignal
708 jalr $zero, $t9 # artThrowNullPointerExceptionFromSignal(uintptr_t, Thread*)
709 move $a1, rSELF # pass Thread::Current
710END art_quick_throw_null_pointer_exception_from_signal
711
buzbee5bc5a7b2012-03-07 15:52:59 -0800712 /*
713 * Called by managed code to create and deliver an ArithmeticException
714 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800715 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700716ENTRY art_quick_throw_div_zero
Ian Rogers57b86d42012-03-27 16:05:41 -0700717 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700718 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800719 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700720 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700721END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800722
buzbee5bc5a7b2012-03-07 15:52:59 -0800723 /*
724 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
725 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800726 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700727ENTRY art_quick_throw_array_bounds
Ian Rogers57b86d42012-03-27 16:05:41 -0700728 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700729 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800730 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700731 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700732END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800733
Ian Rogers57b86d42012-03-27 16:05:41 -0700734 /*
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100735 * Called by managed code to create and deliver a StringIndexOutOfBoundsException
736 * as if thrown from a call to String.charAt().
737 */
738 .extern artThrowStringBoundsFromCode
739ENTRY art_quick_throw_string_bounds
740 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
741 la $t9, artThrowStringBoundsFromCode
742 jalr $zero, $t9 # artThrowStringBoundsFromCode(index, limit, Thread*)
743 move $a2, rSELF # pass Thread::Current
744END art_quick_throw_string_bounds
745
746 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700747 * Called by managed code to create and deliver a StackOverflowError.
748 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800749 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700750ENTRY art_quick_throw_stack_overflow
Ian Rogers57b86d42012-03-27 16:05:41 -0700751 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700752 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800753 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700754 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700755END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800756
Ian Rogers57b86d42012-03-27 16:05:41 -0700757 /*
758 * Called by managed code to create and deliver a NoSuchMethodError.
759 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800760 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700761ENTRY art_quick_throw_no_such_method
Ian Rogers57b86d42012-03-27 16:05:41 -0700762 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700763 la $t9, artThrowNoSuchMethodFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800764 jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700765 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700766END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800767
buzbee5bc5a7b2012-03-07 15:52:59 -0800768 /*
769 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700770 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100771 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700772 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800773 *
jeffhao7fbee072012-08-24 17:56:54 -0700774 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
775 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800776 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700777 * If unsuccessful, the helper will return null/null. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800778 * thread and we branch to another stub to deliver it.
779 *
780 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
781 * pointing back to the original caller.
782 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700783.macro INVOKE_TRAMPOLINE_BODY cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800784 .extern \cxx_name
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700785 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME # save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100786 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100787 la $t9, \cxx_name
788 jalr $t9 # (method_idx, this, Thread*, $sp)
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100789 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
790 move $a0, $v0 # save target Method*
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700791 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700792 beqz $v0, 1f
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100793 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800794 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800795 nop
7961:
797 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700798.endm
799.macro INVOKE_TRAMPOLINE c_name, cxx_name
800ENTRY \c_name
801 INVOKE_TRAMPOLINE_BODY \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800802END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800803.endm
804
Logan Chien8dbb7082013-01-25 20:31:17 +0800805INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800806
Logan Chien8dbb7082013-01-25 20:31:17 +0800807INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
808INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
809INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
810INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800811
Goran Jakovljevicff734982015-08-24 12:58:55 +0000812.macro LOAD_WORD_TO_REG reg, next_arg, index, label
813 lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
814 b \label
815 addiu $\index, 1
816.endm
817
818.macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index, label
819 lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8)
820 lw $\reg2, -4($\next_arg)
821 b \label
822 li $\index, 4 # long can be loaded only to a2_a3 pair so index will be always 4
823.endm
824
825.macro LOAD_FLOAT_TO_REG reg, next_arg, index, label
826 lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
827 b \label
828 addiu $\index, 1
829.endm
830
831.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index, tmp, label
832 LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one
833 # (offset is 8)
834 b \label
835 addiu $\index, 1
836.endm
837
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100838#define SPILL_SIZE 32
839
Jeff Hao79fe5392013-04-24 18:41:58 -0700840 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800841 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800842 * On entry:
843 * a0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700844 * a1 = argument array or null for no argument methods
Jeff Hao5d917302013-02-27 17:57:33 -0800845 * a2 = size of argument array in bytes
846 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700847 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800848 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800849 */
850ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800851 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100852 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
853 .cfi_adjust_cfa_offset SPILL_SIZE
854 sw $gp, 16($sp)
Jeff Hao5d917302013-02-27 17:57:33 -0800855 sw $ra, 12($sp)
856 .cfi_rel_offset 31, 12
857 sw $fp, 8($sp)
858 .cfi_rel_offset 30, 8
859 sw $s1, 4($sp)
860 .cfi_rel_offset 17, 4
861 sw $s0, 0($sp)
862 .cfi_rel_offset 16, 0
863 move $fp, $sp # save sp in fp
864 .cfi_def_cfa_register 30
865 move $s1, $a3 # move managed thread pointer into s1
866 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Goran Jakovljevicff734982015-08-24 12:58:55 +0000867 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700868 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
Goran Jakovljevicff734982015-08-24 12:58:55 +0000869 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
870 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
871 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100872 la $t9, memcpy
873 jalr $t9 # (dest, src, bytes)
Jeff Hao5d917302013-02-27 17:57:33 -0800874 addiu $sp, $sp, -16 # make space for argument slots for memcpy
875 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100876 lw $gp, 16($fp) # restore $gp
877 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000878 lw $a1, 4($sp) # a1 = this*
879 addiu $t0, $sp, 8 # t0 = pointer to the current argument (skip ArtMethod* and this*)
880 li $t3, 2 # t3 = gpr_index = 2 (skip A0 and A1)
881 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100882 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
883 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000884 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
885loop:
886 lbu $t2, 0($t1) # t2 = shorty[i]
887 beqz $t2, loopEnd # finish getting args when shorty[i] == '\0'
888 addiu $t1, 1
889
890 li $t9, 'J' # put char 'J' into t9
891 beq $t9, $t2, isLong # branch if result type char == 'J'
892 li $t9, 'D' # put char 'D' into t9
893 beq $t9, $t2, isDouble # branch if result type char == 'D'
894 li $t9, 'F' # put char 'F' into t9
895 beq $t9, $t2, isSingle # branch if result type char == 'F'
896 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
897 # for both, int and single)
898
899 li $t5, 2 # skip a0 and a1 (ArtMethod* and this*)
900 bne $t5, $t3, 1f # if (gpr_index == 2)
901 addiu $t5, 1
902 LOAD_WORD_TO_REG a2, t0, t3, loop # a2 = current argument, gpr_index++
9031: bne $t5, $t3, loop # else if (gpr_index == 3)
904 nop
905 LOAD_WORD_TO_REG a3, t0, t3, loop # a3 = current argument, gpr_index++
906
907isLong:
908 addiu $t0, 8 # next_arg = curr_arg + 8
909 slti $t5, $t3, 3
910 beqz $t5, 2f # if (gpr_index < 3)
911 nop
912 LOAD_LONG_TO_REG a2, a3, t0, t3, loop # a2_a3 = curr_arg, gpr_index = 4
9132: b loop # else
914 li $t3, 4 # gpr_index = 4
915
916isDouble:
917 addiu $t0, 8 # next_arg = curr_arg + 8
918 li $t5, 0
919 bne $t5, $t4, 3f # if (fp_index == 0)
920 addiu $t5, 1
921 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loop # f12_f13 = curr_arg, fp_index++
9223: bne $t5, $t4, loop # else if (fp_index == 1)
923 nop
924 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loop # f14_f15 = curr_arg, fp_index++
925
926isSingle:
927 li $t5, 0
928 bne $t5, $t4, 4f # if (fp_index == 0)
929 addiu $t5, 1
930 LOAD_FLOAT_TO_REG f12, t0, t4, loop # f12 = curr_arg, fp_index++
9314: bne $t5, $t4, loop # else if (fp_index == 1)
932 nop
933 LOAD_FLOAT_TO_REG f14, t0, t4, loop # f14 = curr_arg, fp_index++
934
935loopEnd:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700936 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800937 jalr $t9 # call the method
Goran Jakovljevicff734982015-08-24 12:58:55 +0000938 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
Jeff Hao5d917302013-02-27 17:57:33 -0800939 move $sp, $fp # restore the stack
940 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800941 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800942 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800943 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800944 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800945 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800946 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800947 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100948 addiu $sp, $sp, SPILL_SIZE
949 .cfi_adjust_cfa_offset -SPILL_SIZE
Jeff Hao5d917302013-02-27 17:57:33 -0800950 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800951 lw $t1, 20($sp) # get shorty
952 lb $t1, 0($t1) # get result type char
Goran Jakovljevicff734982015-08-24 12:58:55 +0000953 li $t2, 'D' # put char 'D' into t2
954 beq $t1, $t2, 5f # branch if result type char == 'D'
955 li $t3, 'F' # put char 'F' into t3
956 beq $t1, $t3, 5f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800957 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -0800958 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800959 sw $v1, 4($t0) # store the other half of the result
Goran Jakovljevicff734982015-08-24 12:58:55 +00009605:
Duane Sande34652f2014-11-04 11:09:36 -0800961 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -0800962 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -0800963 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800964END art_quick_invoke_stub
965
966 /*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000967 * Invocation static stub for quick code.
968 * On entry:
969 * a0 = method pointer
970 * a1 = argument array or null for no argument methods
971 * a2 = size of argument array in bytes
972 * a3 = (managed) thread pointer
973 * [sp + 16] = JValue* result
974 * [sp + 20] = shorty
975 */
976ENTRY art_quick_invoke_static_stub
977 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100978 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
979 .cfi_adjust_cfa_offset SPILL_SIZE
980 sw $gp, 16($sp)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000981 sw $ra, 12($sp)
982 .cfi_rel_offset 31, 12
983 sw $fp, 8($sp)
984 .cfi_rel_offset 30, 8
985 sw $s1, 4($sp)
986 .cfi_rel_offset 17, 4
987 sw $s0, 0($sp)
988 .cfi_rel_offset 16, 0
989 move $fp, $sp # save sp in fp
990 .cfi_def_cfa_register 30
991 move $s1, $a3 # move managed thread pointer into s1
992 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
993 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
994 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
995 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
996 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
997 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100998 la $t9, memcpy
999 jalr $t9 # (dest, src, bytes)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001000 addiu $sp, $sp, -16 # make space for argument slots for memcpy
1001 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001002 lw $gp, 16($fp) # restore $gp
1003 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +00001004 addiu $t0, $sp, 4 # t0 = pointer to the current argument (skip ArtMethod*)
1005 li $t3, 1 # t3 = gpr_index = 1 (skip A0)
1006 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001007 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
1008 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001009 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
1010loopS:
1011 lbu $t2, 0($t1) # t2 = shorty[i]
1012 beqz $t2, loopEndS # finish getting args when shorty[i] == '\0'
1013 addiu $t1, 1
1014
1015 li $t9, 'J' # put char 'J' into t9
1016 beq $t9, $t2, isLongS # branch if result type char == 'J'
1017 li $t9, 'D' # put char 'D' into t9
1018 beq $t9, $t2, isDoubleS # branch if result type char == 'D'
1019 li $t9, 'F' # put char 'F' into t9
1020 beq $t9, $t2, isSingleS # branch if result type char == 'F'
1021 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
1022 # for both, int and single)
1023
1024 li $t5, 1 # skip a0 (ArtMethod*)
1025 bne $t5, $t3, 1f # if (gpr_index == 1)
1026 addiu $t5, 1
1027 LOAD_WORD_TO_REG a1, t0, t3, loopS # a1 = current argument, gpr_index++
10281: bne $t5, $t3, 2f # else if (gpr_index == 2)
1029 addiu $t5, 1
1030 LOAD_WORD_TO_REG a2, t0, t3, loopS # a2 = current argument, gpr_index++
10312: bne $t5, $t3, loopS # else if (gpr_index == 3)
1032 nop
1033 LOAD_WORD_TO_REG a3, t0, t3, loopS # a3 = current argument, gpr_index++
1034
1035isLongS:
1036 addiu $t0, 8 # next_arg = curr_arg + 8
1037 slti $t5, $t3, 3
1038 beqz $t5, 3f # if (gpr_index < 3)
1039 nop
1040 LOAD_LONG_TO_REG a2, a3, t0, t3, loopS # a2_a3 = curr_arg, gpr_index = 4
10413: b loopS # else
1042 li $t3, 4 # gpr_index = 4
1043
1044isDoubleS:
1045 addiu $t0, 8 # next_arg = curr_arg + 8
1046 li $t5, 0
1047 bne $t5, $t4, 4f # if (fp_index == 0)
1048 addiu $t5, 1
1049 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loopS # f12_f13 = curr_arg, fp_index++
10504: bne $t5, $t4, loopS # else if (fp_index == 1)
1051 nop
1052 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loopS # f14_f15 = curr_arg, fp_index++
1053
1054isSingleS:
1055 li $t5, 0
1056 bne $t5, $t4, 5f # if (fp_index == 0)
1057 addiu $t5, 1
1058 LOAD_FLOAT_TO_REG f12, t0, t4, loopS # f12 = curr_arg, fp_index++
10595: bne $t5, $t4, loopS # else if (fp_index == 1)
1060 nop
1061 LOAD_FLOAT_TO_REG f14, t0, t4, loopS # f14 = curr_arg, fp_index++
1062
1063loopEndS:
1064 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
1065 jalr $t9 # call the method
1066 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
1067 move $sp, $fp # restore the stack
1068 lw $s0, 0($sp)
1069 .cfi_restore 16
1070 lw $s1, 4($sp)
1071 .cfi_restore 17
1072 lw $fp, 8($sp)
1073 .cfi_restore 30
1074 lw $ra, 12($sp)
1075 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001076 addiu $sp, $sp, SPILL_SIZE
1077 .cfi_adjust_cfa_offset -SPILL_SIZE
Goran Jakovljevicff734982015-08-24 12:58:55 +00001078 lw $t0, 16($sp) # get result pointer
1079 lw $t1, 20($sp) # get shorty
1080 lb $t1, 0($t1) # get result type char
1081 li $t2, 'D' # put char 'D' into t2
1082 beq $t1, $t2, 6f # branch if result type char == 'D'
1083 li $t3, 'F' # put char 'F' into t3
1084 beq $t1, $t3, 6f # branch if result type char == 'F'
1085 sw $v0, 0($t0) # store the result
1086 jalr $zero, $ra
1087 sw $v1, 4($t0) # store the other half of the result
10886:
1089 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
1090 jalr $zero, $ra
1091 nop
1092END art_quick_invoke_static_stub
1093
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001094#undef SPILL_SIZE
1095
Goran Jakovljevicff734982015-08-24 12:58:55 +00001096 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08001097 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
1098 * failure.
1099 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001100 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001101ENTRY art_quick_handle_fill_data
Douglas Leung735b8552014-10-31 12:21:40 -07001102 lw $a2, 0($sp) # pass referrer's Method*
1103 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001104 la $t9, artHandleFillArrayDataFromCode
1105 jalr $t9 # (payload offset, Array*, method, Thread*)
Ian Rogers832336b2014-10-08 15:35:22 -07001106 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -07001107 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001108END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -08001109
buzbee5bc5a7b2012-03-07 15:52:59 -08001110 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001111 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -08001112 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001113 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001114ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -08001115 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001116 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001117 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001118 la $t9, artLockObjectFromCode
1119 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001120 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -07001121 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001122END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001123
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001124ENTRY art_quick_lock_object_no_inline
1125 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
1126 nop
1127 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block
1128 la $t9, artLockObjectFromCode
1129 jalr $t9 # (Object* obj, Thread*)
1130 move $a1, rSELF # pass Thread::Current
1131 RETURN_IF_ZERO
1132END art_quick_lock_object_no_inline
1133
buzbee5bc5a7b2012-03-07 15:52:59 -08001134 /*
1135 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
1136 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001137 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001138ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -08001139 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001140 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001141 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001142 la $t9, artUnlockObjectFromCode
1143 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001144 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001145 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001146END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001147
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001148ENTRY art_quick_unlock_object_no_inline
1149 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
1150 nop
1151 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
1152 la $t9, artUnlockObjectFromCode
1153 jalr $t9 # (Object* obj, Thread*)
1154 move $a1, rSELF # pass Thread::Current
1155 RETURN_IF_ZERO
1156END art_quick_unlock_object_no_inline
1157
buzbee5bc5a7b2012-03-07 15:52:59 -08001158 /*
1159 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
1160 */
Ian Rogersa9a82542013-10-04 11:17:26 -07001161 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -07001162ENTRY art_quick_check_cast
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001163 addiu $sp, $sp, -32
1164 .cfi_adjust_cfa_offset 32
1165 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001166 sw $ra, 12($sp)
1167 .cfi_rel_offset 31, 12
1168 sw $t9, 8($sp)
1169 sw $a1, 4($sp)
1170 sw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001171 la $t9, artIsAssignableFromCode
1172 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001173 addiu $sp, $sp, -16 # reserve argument slots on the stack
1174 addiu $sp, $sp, 16
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001175 lw $gp, 16($sp)
Ian Rogers86bcdc22014-02-21 22:06:38 -08001176 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001177 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -08001178 jalr $zero, $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001179 addiu $sp, $sp, 32
1180 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001181.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -07001182 lw $t9, 8($sp)
1183 lw $a1, 4($sp)
1184 lw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001185 addiu $sp, $sp, 32
1186 .cfi_adjust_cfa_offset -32
Ian Rogersa9a82542013-10-04 11:17:26 -07001187 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -07001188 la $t9, artThrowClassCastException
Andreas Gampe8d365912015-01-13 11:32:32 -08001189 jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001190 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001191END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -08001192
buzbee5bc5a7b2012-03-07 15:52:59 -08001193 /*
Man Cao1aee9002015-07-14 22:31:42 -07001194 * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
1195 * nReg is the register number for rReg.
1196 */
1197.macro POP_REG_NE rReg, nReg, offset, rExclude
1198 .ifnc \rReg, \rExclude
1199 lw \rReg, \offset($sp) # restore rReg
1200 .cfi_restore \nReg
1201 .endif
1202.endm
1203
1204 /*
1205 * Macro to insert read barrier, only used in art_quick_aput_obj.
1206 * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
1207 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
1208 */
1209.macro READ_BARRIER rDest, rObj, offset
1210#ifdef USE_READ_BARRIER
1211 # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment.
1212 addiu $sp, $sp, -32
1213 .cfi_adjust_cfa_offset 32
1214 sw $ra, 28($sp)
1215 .cfi_rel_offset 31, 28
1216 sw $t9, 24($sp)
1217 .cfi_rel_offset 25, 24
1218 sw $t1, 20($sp)
1219 .cfi_rel_offset 9, 20
1220 sw $t0, 16($sp)
1221 .cfi_rel_offset 8, 16
1222 sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B)
1223 .cfi_rel_offset 6, 8
1224 sw $a1, 4($sp)
1225 .cfi_rel_offset 5, 4
1226 sw $a0, 0($sp)
1227 .cfi_rel_offset 4, 0
1228
Man Cao63069212015-08-21 15:51:39 -07001229 # move $a0, \rRef # pass ref in a0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -07001230 .ifnc \rObj, $a1
1231 move $a1, \rObj # pass rObj
1232 .endif
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001233 addiu $a2, $zero, \offset # pass offset
1234 la $t9, artReadBarrierSlow
1235 jalr $t9 # artReadBarrierSlow(ref, rObj, offset)
Man Cao1aee9002015-07-14 22:31:42 -07001236 addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack
1237 # before the call to artReadBarrierSlow.
1238 addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow
1239 # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
1240 move \rDest, $v0 # save return value in rDest
1241 # (rDest cannot be v0 in art_quick_aput_obj)
1242
1243 lw $a0, 0($sp) # restore registers except rDest
1244 # (rDest can only be t0 or t1 in art_quick_aput_obj)
1245 .cfi_restore 4
1246 lw $a1, 4($sp)
1247 .cfi_restore 5
1248 lw $a2, 8($sp)
1249 .cfi_restore 6
1250 POP_REG_NE $t0, 8, 16, \rDest
1251 POP_REG_NE $t1, 9, 20, \rDest
1252 lw $t9, 24($sp)
1253 .cfi_restore 25
1254 lw $ra, 28($sp) # restore $ra
1255 .cfi_restore 31
1256 addiu $sp, $sp, 32
1257 .cfi_adjust_cfa_offset -32
1258#else
1259 lw \rDest, \offset(\rObj)
1260 UNPOISON_HEAP_REF \rDest
1261#endif // USE_READ_BARRIER
1262.endm
1263
1264 /*
Ian Rogersa9a82542013-10-04 11:17:26 -07001265 * Entry from managed code for array put operations of objects where the value being stored
1266 * needs to be checked for compatibility.
1267 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -08001268 */
Ian Rogersa9a82542013-10-04 11:17:26 -07001269ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -08001270 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001271 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001272 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001273 nop
1274END art_quick_aput_obj_with_null_and_bound_check
1275
1276ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001277 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001278 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -08001279 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001280 nop
1281 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -08001282 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001283 move $a1, $t0
1284END art_quick_aput_obj_with_bound_check
1285
Man Cao1aee9002015-07-14 22:31:42 -07001286#ifdef USE_READ_BARRIER
1287 .extern artReadBarrierSlow
1288#endif
Ian Rogersa9a82542013-10-04 11:17:26 -07001289ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -08001290 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -07001291 nop
Man Cao1aee9002015-07-14 22:31:42 -07001292 READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
1293 READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
1294 READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogers86bcdc22014-02-21 22:06:38 -08001295 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -07001296 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001297.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -07001298 sll $a1, $a1, 2
1299 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001300 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001301 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001302 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
1303 srl $t1, $a0, 7
1304 add $t1, $t1, $t0
1305 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -08001306 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001307 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001308.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -07001309 sll $a1, $a1, 2
1310 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001311 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -08001312 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001313 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001314.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -07001315 addiu $sp, $sp, -32
1316 .cfi_adjust_cfa_offset 32
1317 sw $ra, 28($sp)
1318 .cfi_rel_offset 31, 28
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001319 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001320 sw $t9, 12($sp)
1321 sw $a2, 8($sp)
1322 sw $a1, 4($sp)
1323 sw $a0, 0($sp)
1324 move $a1, $t1
1325 move $a0, $t0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001326 la $t9, artIsAssignableFromCode
1327 jalr $t9 # (Class*, Class*)
1328 addiu $sp, $sp, -16 # reserve argument slots on the stack
1329 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -07001330 lw $ra, 28($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001331 lw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001332 lw $t9, 12($sp)
1333 lw $a2, 8($sp)
1334 lw $a1, 4($sp)
1335 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001336 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -07001337 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001338 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -07001339 nop
1340 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1341 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -07001342 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -08001343 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001344 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -07001345END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -08001346
buzbee5bc5a7b2012-03-07 15:52:59 -08001347 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001348 * Called by managed code to resolve a static field and load a boolean primitive value.
1349 */
1350 .extern artGetBooleanStaticFromCode
1351ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -07001352 lw $a1, 0($sp) # pass referrer's Method*
1353 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001354 la $t9, artGetBooleanStaticFromCode
1355 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001356 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001357 RETURN_IF_NO_EXCEPTION
1358END art_quick_get_boolean_static
1359 /*
1360 * Called by managed code to resolve a static field and load a byte primitive value.
1361 */
1362 .extern artGetByteStaticFromCode
1363ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -07001364 lw $a1, 0($sp) # pass referrer's Method*
1365 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001366 la $t9, artGetByteStaticFromCode
1367 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001368 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001369 RETURN_IF_NO_EXCEPTION
1370END art_quick_get_byte_static
1371
1372 /*
1373 * Called by managed code to resolve a static field and load a char primitive value.
1374 */
1375 .extern artGetCharStaticFromCode
1376ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -07001377 lw $a1, 0($sp) # pass referrer's Method*
1378 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001379 la $t9, artGetCharStaticFromCode
1380 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001381 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001382 RETURN_IF_NO_EXCEPTION
1383END art_quick_get_char_static
1384 /*
1385 * Called by managed code to resolve a static field and load a short primitive value.
1386 */
1387 .extern artGetShortStaticFromCode
1388ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -07001389 lw $a1, 0($sp) # pass referrer's Method*
1390 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001391 la $t9, artGetShortStaticFromCode
1392 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001393 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001394 RETURN_IF_NO_EXCEPTION
1395END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001396
buzbee5bc5a7b2012-03-07 15:52:59 -08001397 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001398 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001399 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001400 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001401ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001402 lw $a1, 0($sp) # pass referrer's Method*
1403 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001404 la $t9, artGet32StaticFromCode
1405 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001406 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001407 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001408END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001409
buzbee5bc5a7b2012-03-07 15:52:59 -08001410 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001411 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001412 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001413 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001414ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001415 lw $a1, 0($sp) # pass referrer's Method*
1416 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001417 la $t9, artGet64StaticFromCode
1418 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001419 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001420 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001421END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001422
buzbee5bc5a7b2012-03-07 15:52:59 -08001423 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001424 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001425 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001426 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001427ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001428 lw $a1, 0($sp) # pass referrer's Method*
1429 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001430 la $t9, artGetObjStaticFromCode
1431 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001432 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001433 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001434END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001435
buzbee5bc5a7b2012-03-07 15:52:59 -08001436 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001437 * Called by managed code to resolve an instance field and load a boolean primitive value.
1438 */
1439 .extern artGetBooleanInstanceFromCode
1440ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001441 lw $a2, 0($sp) # pass referrer's Method*
1442 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001443 la $t9, artGetBooleanInstanceFromCode
1444 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001445 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001446 RETURN_IF_NO_EXCEPTION
1447END art_quick_get_boolean_instance
1448 /*
1449 * Called by managed code to resolve an instance field and load a byte primitive value.
1450 */
1451 .extern artGetByteInstanceFromCode
1452ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001453 lw $a2, 0($sp) # pass referrer's Method*
1454 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001455 la $t9, artGetByteInstanceFromCode
1456 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001457 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001458 RETURN_IF_NO_EXCEPTION
1459END art_quick_get_byte_instance
1460
1461 /*
1462 * Called by managed code to resolve an instance field and load a char primitive value.
1463 */
1464 .extern artGetCharInstanceFromCode
1465ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001466 lw $a2, 0($sp) # pass referrer's Method*
1467 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001468 la $t9, artGetCharInstanceFromCode
1469 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001470 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001471 RETURN_IF_NO_EXCEPTION
1472END art_quick_get_char_instance
1473 /*
1474 * Called by managed code to resolve an instance field and load a short primitive value.
1475 */
1476 .extern artGetShortInstanceFromCode
1477ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001478 lw $a2, 0($sp) # pass referrer's Method*
1479 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001480 la $t9, artGetShortInstanceFromCode
1481 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001482 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001483 RETURN_IF_NO_EXCEPTION
1484END art_quick_get_short_instance
1485
1486 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001487 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001488 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001489 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001490ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001491 lw $a2, 0($sp) # pass referrer's Method*
1492 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001493 la $t9, artGet32InstanceFromCode
1494 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001495 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001496 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001497END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001498
buzbee5bc5a7b2012-03-07 15:52:59 -08001499 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001500 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001501 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001502 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001503ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001504 lw $a2, 0($sp) # pass referrer's Method*
1505 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001506 la $t9, artGet64InstanceFromCode
1507 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001508 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001509 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001510END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001511
buzbee5bc5a7b2012-03-07 15:52:59 -08001512 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001513 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001514 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001515 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001516ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001517 lw $a2, 0($sp) # pass referrer's Method*
1518 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001519 la $t9, artGetObjInstanceFromCode
1520 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001521 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001522 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001523END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001524
buzbee5bc5a7b2012-03-07 15:52:59 -08001525 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001526 * Called by managed code to resolve a static field and store a 8-bit primitive value.
1527 */
1528 .extern artSet8StaticFromCode
1529ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -07001530 lw $a2, 0($sp) # pass referrer's Method*
1531 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001532 la $t9, artSet8StaticFromCode
1533 jalr $t9 # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001534 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001535 RETURN_IF_ZERO
1536END art_quick_set8_static
1537
1538 /*
1539 * Called by managed code to resolve a static field and store a 16-bit primitive value.
1540 */
1541 .extern artSet16StaticFromCode
1542ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -07001543 lw $a2, 0($sp) # pass referrer's Method*
1544 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001545 la $t9, artSet16StaticFromCode
1546 jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001547 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001548 RETURN_IF_ZERO
1549END art_quick_set16_static
1550
1551 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001552 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001553 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001554 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001555ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001556 lw $a2, 0($sp) # pass referrer's Method*
1557 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001558 la $t9, artSet32StaticFromCode
1559 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001560 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001561 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001562END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001563
buzbee5bc5a7b2012-03-07 15:52:59 -08001564 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001565 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001566 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001567 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001568ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001569 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001570 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -07001571 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001572 la $t9, artSet64StaticFromCode
1573 jalr $t9 # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001574 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001575 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001576END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001577
buzbee5bc5a7b2012-03-07 15:52:59 -08001578 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001579 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001580 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001581 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001582ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001583 lw $a2, 0($sp) # pass referrer's Method*
1584 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001585 la $t9, artSetObjStaticFromCode
1586 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001587 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001588 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001589END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001590
buzbee5bc5a7b2012-03-07 15:52:59 -08001591 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001592 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1593 */
1594 .extern artSet8InstanceFromCode
1595ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001596 lw $a3, 0($sp) # pass referrer's Method*
1597 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001598 la $t9, artSet8InstanceFromCode
1599 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001600 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001601 RETURN_IF_ZERO
1602END art_quick_set8_instance
1603
1604 /*
1605 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1606 */
1607 .extern artSet16InstanceFromCode
1608ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001609 lw $a3, 0($sp) # pass referrer's Method*
1610 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001611 la $t9, artSet16InstanceFromCode
1612 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001613 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001614 RETURN_IF_ZERO
1615END art_quick_set16_instance
1616
1617 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001618 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001619 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001620 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001621ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001622 lw $a3, 0($sp) # pass referrer's Method*
1623 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001624 la $t9, artSet32InstanceFromCode
1625 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001626 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001627 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001628END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001629
buzbee5bc5a7b2012-03-07 15:52:59 -08001630 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001631 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001632 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001633 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001634ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001635 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001636 # 64 bit new_val is in a2:a3 pair
Douglas Leung735b8552014-10-31 12:21:40 -07001637 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001638 sw rSELF, 20($sp) # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001639 la $t9, artSet64InstanceFromCode
1640 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001641 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001642 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001643END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001644
buzbee5bc5a7b2012-03-07 15:52:59 -08001645 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001646 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001647 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001648 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001649ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001650 lw $a3, 0($sp) # pass referrer's Method*
1651 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001652 la $t9, artSetObjInstanceFromCode
1653 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001654 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001655 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001656END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001657
Vladimir Markoa3c38272015-04-28 12:37:09 +01001658// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001659.macro ONE_ARG_DOWNCALL name, entrypoint, return
1660 .extern \entrypoint
1661ENTRY \name
1662 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001663 la $t9, \entrypoint
1664 jalr $t9
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001665 move $a1, rSELF # pass Thread::Current
1666 \return
1667END \name
1668.endm
1669
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001670.macro TWO_ARG_DOWNCALL name, entrypoint, return
1671 .extern \entrypoint
1672ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001673 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001674 la $t9, \entrypoint
1675 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001676 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001677 \return
1678END \name
1679.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001680
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001681.macro THREE_ARG_DOWNCALL name, entrypoint, return
1682 .extern \entrypoint
1683ENTRY \name
Douglas Leung735b8552014-10-31 12:21:40 -07001684 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001685 la $t9, \entrypoint
1686 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001687 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001688 \return
1689END \name
1690.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001691
Jeff Hao848f70a2014-01-15 13:49:50 -08001692.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1693 .extern \entrypoint
1694ENTRY \name
Vladimir Markoa3c38272015-04-28 12:37:09 +01001695 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001696 la $t9, \entrypoint
1697 jalr $t9
Vladimir Markoa3c38272015-04-28 12:37:09 +01001698 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001699 \return
1700END \name
1701.endm
1702
Mathieu Chartier7410f292013-11-24 13:17:35 -08001703// Generate the allocation entrypoints for each allocator.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001704GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001705
Pavle Batuta712c59d2015-12-02 18:39:01 +01001706// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1707ENTRY art_quick_alloc_object_rosalloc
1708
1709 # Fast path rosalloc allocation
1710 # a0: type_idx
1711 # a1: ArtMethod*
1712 # s1: Thread::Current
1713 # -----------------------------
1714 # t0: class
1715 # t1: object size
1716 # t2: rosalloc run
1717 # t3: thread stack top offset
1718 # t4: thread stack bottom offset
1719 # v0: free list head
1720 #
1721 # t5, t6 : temps
1722
1723 lw $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_32($a1) # Load dex cache resolved types
1724 # array.
1725
1726 sll $t5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT # Shift the value.
1727 addu $t5, $t0, $t5 # Compute the index.
1728 lw $t0, 0($t5) # Load class (t0).
1729 beqz $t0, .Lart_quick_alloc_object_rosalloc_slow_path
1730
1731 li $t6, MIRROR_CLASS_STATUS_INITIALIZED
1732 lw $t5, MIRROR_CLASS_STATUS_OFFSET($t0) # Check class status.
1733 bne $t5, $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1734
1735 # Add a fake dependence from the following access flag and size loads to the status load. This
1736 # is to prevent those loads from being reordered above the status load and reading wrong values.
1737 xor $t5, $t5, $t5
1738 addu $t0, $t0, $t5
1739
1740 lw $t5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0) # Check if access flags has
1741 li $t6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE # kAccClassIsFinalizable.
1742 and $t6, $t5, $t6
1743 bnez $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1744
1745 lw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) # Check if thread local allocation
1746 lw $t4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1) # stack has any room left.
1747 bgeu $t3, $t4, .Lart_quick_alloc_object_rosalloc_slow_path
1748
1749 lw $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0) # Load object size (t1).
1750 li $t5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE # Check if size is for a thread local
1751 # allocation.
1752 bgtu $t1, $t5, .Lart_quick_alloc_object_rosalloc_slow_path
1753
1754 # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket
1755 # quantum size and divide by the quantum size and subtract by 1.
1756
1757 addiu $t1, $t1, -1 # Decrease obj size and shift right
1758 srl $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT # by quantum.
1759
1760 sll $t2, $t1, POINTER_SIZE_SHIFT
1761 addu $t2, $t2, $s1
1762 lw $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2) # Load rosalloc run (t2).
1763
1764 # Load the free list head (v0).
1765 # NOTE: this will be the return val.
1766
1767 lw $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1768 beqz $v0, .Lart_quick_alloc_object_rosalloc_slow_path
1769 nop
1770
1771 # Load the next pointer of the head and update the list head with the next pointer.
1772
1773 lw $t5, ROSALLOC_SLOT_NEXT_OFFSET($v0)
1774 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1775
1776 # Store the class pointer in the header. This also overwrites the first pointer. The offsets are
1777 # asserted to match.
1778
1779#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1780#error "Class pointer needs to overwrite next pointer."
1781#endif
1782
1783 POISON_HEAP_REF $t0
1784 sw $t0, MIRROR_OBJECT_CLASS_OFFSET($v0)
1785
1786 # Push the new object onto the thread local allocation stack and increment the thread local
1787 # allocation stack top.
1788
1789 sw $v0, 0($t3)
1790 addiu $t3, $t3, COMPRESSED_REFERENCE_SIZE
1791 sw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)
1792
1793 # Decrement the size of the free list.
1794
1795 lw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1796 addiu $t5, $t5, -1
1797 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1798
1799 sync # Fence.
1800
1801 jalr $zero, $ra
1802 nop
1803
1804 .Lart_quick_alloc_object_rosalloc_slow_path:
1805
1806 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001807 la $t9, artAllocObjectFromCodeRosAlloc
1808 jalr $t9
Chris Larsencf283da2016-01-19 16:45:35 -08001809 move $a2, $s1 # Pass self as argument.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001810 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1811
1812END art_quick_alloc_object_rosalloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001813
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001814GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB)
1815GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB)
1816
buzbee5bc5a7b2012-03-07 15:52:59 -08001817 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001818 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001819 * exception on error. On success the String is returned. A0 holds the string index. The fast
1820 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001821 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001822ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001823
1824 /*
1825 * Entry from managed code when uninitialized static storage, this stub will run the class
1826 * initializer and deliver the exception on error. On success the static storage base is
1827 * returned.
1828 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001829ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001830
1831 /*
1832 * Entry from managed code when dex cache misses for a type_idx.
1833 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001834ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001835
1836 /*
1837 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1838 * miss.
1839 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001840ONE_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 -08001841
1842 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001843 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001844 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001845 .extern artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001846ENTRY_NO_GP art_quick_test_suspend
1847 lh rSUSPEND, THREAD_FLAGS_OFFSET(rSELF)
1848 bnez rSUSPEND, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001849 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001850 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001851 nop
18521:
Vladimir Marko952dbb12016-07-28 12:01:51 +01001853 SETUP_SAVE_EVERYTHING_CALLEE_SAVE_FRAME # save everything for stack crawl
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001854 la $t9, artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001855 jalr $t9 # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001856 move $a0, rSELF
Vladimir Marko952dbb12016-07-28 12:01:51 +01001857 RESTORE_SAVE_EVERYTHING_CALLEE_SAVE_FRAME
1858 jalr $zero, $ra
1859 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001860END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001861
buzbee5bc5a7b2012-03-07 15:52:59 -08001862 /*
1863 * Called by managed code that is attempting to call a method on a proxy class. On entry
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001864 * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001865 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001866 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001867ENTRY art_quick_proxy_invoke_handler
Douglas Leung735b8552014-10-31 12:21:40 -07001868 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1869 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001870 la $t9, artQuickProxyInvokeHandler
1871 jalr $t9 # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001872 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001873 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07001874 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001875 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001876 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1877 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001878 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001879 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080018801:
1881 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001882END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001883
Jeff Hao88474b42013-10-23 16:24:40 -07001884 /*
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001885 * Called to resolve an imt conflict.
1886 * a0 is the conflict ArtMethod.
1887 * t0 is a hidden argument that holds the target interface method's dex method index.
1888 *
1889 * Note that this stub writes to a0, t0 and t1.
Jeff Hao88474b42013-10-23 16:24:40 -07001890 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001891ENTRY art_quick_imt_conflict_trampoline
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001892 lw $t1, 0($sp) # Load referrer.
1893 lw $t1, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t1) # Load dex cache methods array.
1894 sll $t0, $t0, POINTER_SIZE_SHIFT # Calculate offset.
1895 addu $t0, $t1, $t0 # Add offset to base.
1896 lw $t0, 0($t0) # Load interface method.
1897 lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable.
1898
1899.Limt_table_iterate:
1900 lw $t1, 0($a0) # Load next entry in ImtConflictTable.
1901 # Branch if found.
1902 beq $t1, $t0, .Limt_table_found
1903 nop
1904 # If the entry is null, the interface method is not in the ImtConflictTable.
1905 beqz $t1, .Lconflict_trampoline
1906 nop
1907 # Iterate over the entries of the ImtConflictTable.
1908 b .Limt_table_iterate
1909 addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry.
1910
1911.Limt_table_found:
1912 # We successfully hit an entry in the table. Load the target method and jump to it.
1913 lw $a0, __SIZEOF_POINTER__($a0)
1914 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
1915 jr $t9
1916 nop
1917
1918.Lconflict_trampoline:
1919 # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001920 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001921END art_quick_imt_conflict_trampoline
1922
Ian Rogers468532e2013-08-05 10:56:33 -07001923 .extern artQuickResolutionTrampoline
1924ENTRY art_quick_resolution_trampoline
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001925 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001926 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001927 la $t9, artQuickResolutionTrampoline
1928 jalr $t9 # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001929 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001930 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001931 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001932 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001933 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001934 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001935 nop
Ian Rogers468532e2013-08-05 10:56:33 -070019361:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001937 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001938 DELIVER_PENDING_EXCEPTION
1939END art_quick_resolution_trampoline
1940
Douglas Leung735b8552014-10-31 12:21:40 -07001941 .extern artQuickGenericJniTrampoline
1942 .extern artQuickGenericJniEndTrampoline
1943ENTRY art_quick_generic_jni_trampoline
1944 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1945 move $s8, $sp # save $sp to $s8
1946 move $s3, $gp # save $gp to $s3
1947
1948 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1949 move $a0, rSELF # pass Thread::Current
1950 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001951 la $t9, artQuickGenericJniTrampoline
1952 jalr $t9 # (Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001953 addiu $sp, $sp, -5120 # reserve space on the stack
1954
1955 # The C call will have registered the complete save-frame on success.
1956 # The result of the call is:
1957 # v0: ptr to native code, 0 on error.
1958 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1959 beq $v0, $zero, 1f # check entry error
1960 move $t9, $v0 # save the code ptr
1961 move $sp, $v1 # release part of the alloca
1962
1963 # Load parameters from stack into registers
1964 lw $a0, 0($sp)
1965 lw $a1, 4($sp)
1966 lw $a2, 8($sp)
1967
1968 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1969 jalr $t9 # native call
1970 lw $a3, 12($sp)
1971 addiu $sp, $sp, 16 # remove arg slots
1972
1973 move $gp, $s3 # restore $gp from $s3
1974
1975 # result sign extension is handled in C code
1976 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1977 move $a0, rSELF # pass Thread::Current
1978 move $a2, $v0 # pass result
1979 move $a3, $v1
1980 addiu $sp, $sp, -24 # reserve arg slots
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001981 la $t9, artQuickGenericJniEndTrampoline
1982 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001983 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001984
1985 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001986 bne $t0, $zero, 1f # check for pending exceptions
1987
Douglas Leung735b8552014-10-31 12:21:40 -07001988 move $sp, $s8 # tear down the alloca
1989
1990 # tear dpown the callee-save frame
1991 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1992
Duane Sande34652f2014-11-04 11:09:36 -08001993 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001994 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001995 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001996
19971:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001998 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1999 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07002000 DELIVER_PENDING_EXCEPTION
2001END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08002002
Ian Rogers468532e2013-08-05 10:56:33 -07002003 .extern artQuickToInterpreterBridge
2004ENTRY art_quick_to_interpreter_bridge
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002005 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002006 move $a1, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002007 la $t9, artQuickToInterpreterBridge
2008 jalr $t9 # (Method* method, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07002009 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08002010 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Douglas Leung735b8552014-10-31 12:21:40 -07002011 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08002012 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002013 # don't care if $v0 and/or $v1 are modified, when exception branch taken
2014 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002015 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002016 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080020171:
2018 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07002019END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08002020
buzbee5bc5a7b2012-03-07 15:52:59 -08002021 /*
jeffhao725a9572012-11-13 18:20:12 -08002022 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08002023 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002024 .extern artInstrumentationMethodEntryFromCode
2025 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07002026ENTRY art_quick_instrumentation_entry
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002027 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002028 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002029 move $a3, $ra # pass $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002030 la $t9, artInstrumentationMethodEntryFromCode
2031 jalr $t9 # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08002032 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07002033 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07002034 lw $a0, 28($sp) # restore arg0 from free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002035 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
jeffhao8161c032012-10-31 15:50:00 -07002036 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08002037 nop
Ian Rogers468532e2013-08-05 10:56:33 -07002038END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08002039 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07002040 .global art_quick_instrumentation_exit
2041art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002042 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08002043 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002044 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07002045 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07002046
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002047 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002048 addiu $sp, $sp, -16 # allocate temp storage on the stack
2049 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002050 sw $v0, ARG_SLOT_SIZE+12($sp)
2051 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
2052 sw $v1, ARG_SLOT_SIZE+8($sp)
2053 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
2054 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08002055 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08002056 move $a2, $v0 # pass gpr result
2057 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002058 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002059 la $t9, artInstrumentationMethodExitFromCode
2060 jalr $t9 # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08002061 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002062 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08002063 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002064 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
2065 lw $v1, ARG_SLOT_SIZE+8($sp)
2066 l.d $f0, ARG_SLOT_SIZE($sp)
2067 jalr $zero, $t9 # return
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002068 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16 # restore stack
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002069 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16)
Ian Rogers468532e2013-08-05 10:56:33 -07002070END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08002071
jeffhao12051ea2013-01-10 11:24:31 -08002072 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08002073 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
2074 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08002075 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002076 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002077ENTRY art_quick_deoptimize
Jeff Hao14dd5a82013-04-11 10:23:36 -07002078 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002079 la $t9, artDeoptimize
2080 jalr $t9 # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08002081 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002082 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002083END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08002084
buzbee5bc5a7b2012-03-07 15:52:59 -08002085 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00002086 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
2087 * will long jump to the upcall with a special exception of -1.
2088 */
2089 .extern artDeoptimizeFromCompiledCode
2090ENTRY art_quick_deoptimize_from_compiled_code
2091 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002092 la $t9, artDeoptimizeFromCompiledCode
2093 jalr $t9 # artDeoptimizeFromCompiledCode(Thread*)
Sebastien Hertz07474662015-08-25 15:12:33 +00002094 # Returns caller method's frame size.
2095 move $a0, rSELF # pass Thread::current
2096END art_quick_deoptimize_from_compiled_code
2097
2098 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08002099 * Long integer shift. This is different from the generic 32/64-bit
2100 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2101 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2102 * 6 bits.
2103 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002104 * $a0: low word
2105 * $a1: high word
2106 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002107 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002108ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002109 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07002110 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
2111 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
2112 srl $a0, 1
2113 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
2114 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002115 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002116 beqz $a2, 1f
2117 or $v1, $a0 # rhi<- rhi | alo
2118
2119 move $v1, $v0 # rhi<- rlo (if shift&0x20)
2120 move $v0, $zero # rlo<- 0 (if shift&0x20)
2121
Andreas Gampe8d365912015-01-13 11:32:32 -080021221: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002123 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002124END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002125
buzbee5bc5a7b2012-03-07 15:52:59 -08002126 /*
2127 * Long integer shift. This is different from the generic 32/64-bit
2128 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2129 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2130 * 6 bits.
2131 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002132 * $a0: low word
2133 * $a1: high word
2134 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002135 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002136ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07002137 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
2138 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
2139 sra $a3, $a1, 31 # $a3<- sign(ah)
2140 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2141 sll $a1, 1
2142 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002143 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08002144 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002145 or $v0, $a1 # rlo<- rlo | ahi
2146
2147 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2148 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
2149
Andreas Gampe8d365912015-01-13 11:32:32 -080021501: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002151 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002152END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002153
buzbee5bc5a7b2012-03-07 15:52:59 -08002154 /*
2155 * Long integer shift. This is different from the generic 32/64-bit
2156 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2157 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2158 * 6 bits.
2159 * On entry:
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002160 * $a0: low word
2161 * $a1: high word
2162 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002163 */
2164 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002165ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07002166 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002167 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002168 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2169 sll $a1, 1
2170 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002171 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002172 beqz $a2, 1f
2173 or $v0, $a1 # rlo<- rlo | ahi
2174
2175 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2176 move $v1, $zero # rhi<- 0 (if shift&0x20)
2177
Andreas Gampe8d365912015-01-13 11:32:32 -080021781: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002179 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002180END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07002181
Chris Larsencf283da2016-01-19 16:45:35 -08002182/* java.lang.String.indexOf(int ch, int fromIndex=0) */
2183ENTRY_NO_GP art_quick_indexof
2184/* $a0 holds address of "this" */
2185/* $a1 holds "ch" */
2186/* $a2 holds "fromIndex" */
2187 lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002188 slt $t1, $a2, $zero # if fromIndex < 0
Chris Larsencf283da2016-01-19 16:45:35 -08002189#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002190 seleqz $a2, $a2, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002191#else
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002192 movn $a2, $zero, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002193#endif
2194 subu $t0, $t0, $a2 # this.length() - fromIndex
2195 blez $t0, 6f # if this.length()-fromIndex <= 0
2196 li $v0, -1 # return -1;
2197
2198 sll $v0, $a2, 1 # $a0 += $a2 * 2
2199 addu $a0, $a0, $v0 # " " " " "
2200 move $v0, $a2 # Set i to fromIndex.
2201
22021:
2203 lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch
2204 beq $t3, $a1, 6f # return i;
2205 addu $a0, $a0, 2 # i++
2206 subu $t0, $t0, 1 # this.length() - i
2207 bnez $t0, 1b # while this.length() - i > 0
2208 addu $v0, $v0, 1 # i++
2209
2210 li $v0, -1 # if this.length() - i <= 0
2211 # return -1;
2212
22136:
2214 j $ra
2215 nop
2216END art_quick_indexof
2217
Chris Larsencf283da2016-01-19 16:45:35 -08002218/* java.lang.String.compareTo(String anotherString) */
2219ENTRY_NO_GP art_quick_string_compareto
2220/* $a0 holds address of "this" */
2221/* $a1 holds address of "anotherString" */
2222 beq $a0, $a1, 9f # this and anotherString are the same object
2223 move $v0, $zero
2224
2225 lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
2226 lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length()
2227 MINu $t2, $a2, $a3
2228# $t2 now holds min(this.length(),anotherString.length())
2229
2230 beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0
2231 subu $v0, $a2, $a3 # if $t2==0 return
2232 # (this.length() - anotherString.length())
22331:
2234 lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i)
2235 lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1)
2236 bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i)
2237 subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i))
2238 addiu $a0, $a0, 2 # point at this.charAt(i++)
2239 subu $t2, $t2, 1 # new value of
2240 # min(this.length(),anotherString.length())-i
2241 bnez $t2, 1b
2242 addiu $a1, $a1, 2 # point at anotherString.charAt(i++)
2243 subu $v0, $a2, $a3
2244
22459:
2246 j $ra
2247 nop
2248END art_quick_string_compareto