blob: 4bd1314d15d80d8153c845362813a7c98f40bbc8 [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
Vladimir Markofd36f1f2016-08-03 18:49:58 +010033 * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves)
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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010037 * Reserves FRAME_SIZE_SAVE_ALL_CALLEE_SAVES + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080038 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +010039.macro SETUP_SAVE_ALL_CALLEE_SAVES_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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010044#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 96)
45#error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(MIPS) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -070046#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)
Vladimir Markofd36f1f2016-08-03 18:49:58 +010082 lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_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
Vladimir Markofd36f1f2016-08-03 18:49:58 +010091 * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly). Restoration assumes non-moving GC.
buzbee5bc5a7b2012-03-07 15:52:59 -080092 * 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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010096 * Reserves FRAME_SIZE_SAVE_REFS_ONLY + ARG_SLOT_SIZE bytes on the stack
buzbee5bc5a7b2012-03-07 15:52:59 -080097 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +010098.macro SETUP_SAVE_REFS_ONLY_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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100103#if (FRAME_SIZE_SAVE_REFS_ONLY != 48)
104#error "FRAME_SIZE_SAVE_REFS_ONLY(MIPS) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700105#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)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100129 lw $t0, RUNTIME_SAVE_REFS_ONLY_METHOD_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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100136.macro RESTORE_SAVE_REFS_ONLY_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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100161.macro RESTORE_SAVE_REFS_ONLY_FRAME_AND_RETURN
162 RESTORE_SAVE_REFS_ONLY_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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100169 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs).
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 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100172.macro SETUP_SAVE_REFS_AND_ARGS_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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100177#if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 80)
178#error "FRAME_SIZE_SAVE_REFS_AND_ARGS(MIPS) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700179#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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100212 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). 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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100216 * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack
Douglas Leung735b8552014-10-31 12:21:40 -0700217 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100218.macro SETUP_SAVE_REFS_AND_ARGS_FRAME
219 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Douglas Leung4af77b72014-10-22 16:32:28 -0700220 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
221 lw $t0, 0($t0)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100222 lw $t0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100231 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). 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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100236 * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack
Douglas Leung735b8552014-10-31 12:21:40 -0700237 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100238.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
239 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Douglas Leung735b8552014-10-31 12:21:40 -0700240 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
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100246.macro RESTORE_SAVE_REFS_AND_ARGS_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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100286 * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack.
Vladimir Marko952dbb12016-07-28 12:01:51 +0100287 * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP.
288 */
Nicolas Geoffray0719b5b2016-09-12 22:05:33 +0000289.macro SETUP_SAVE_EVERYTHING_FRAME
290 addiu $sp, $sp, -256
291 .cfi_adjust_cfa_offset 256
292
Vladimir Marko952dbb12016-07-28 12:01:51 +0100293 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100294#if (FRAME_SIZE_SAVE_EVERYTHING != 256)
295#error "FRAME_SIZE_SAVE_EVERYTHING(MIPS) size not as expected."
Vladimir Marko952dbb12016-07-28 12:01:51 +0100296#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
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200355 .set push
356 .set noat
Vladimir Marko952dbb12016-07-28 12:01:51 +0100357 sw $at, 144($sp)
358 .cfi_rel_offset 1, 144
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200359 .set pop
Vladimir Marko952dbb12016-07-28 12:01:51 +01003601:
361 .cpload $ra
362
363 SDu $f30, $f31, 136, $sp, $t1
364 SDu $f28, $f29, 128, $sp, $t1
365 SDu $f26, $f27, 120, $sp, $t1
366 SDu $f24, $f25, 112, $sp, $t1
367 SDu $f22, $f23, 104, $sp, $t1
368 SDu $f20, $f21, 96, $sp, $t1
369 SDu $f18, $f19, 88, $sp, $t1
370 SDu $f16, $f17, 80, $sp, $t1
371 SDu $f14, $f15, 72, $sp, $t1
372 SDu $f12, $f13, 64, $sp, $t1
373 SDu $f10, $f11, 56, $sp, $t1
374 SDu $f8, $f9, 48, $sp, $t1
375 SDu $f6, $f7, 40, $sp, $t1
376 SDu $f4, $f5, 32, $sp, $t1
377 SDu $f2, $f3, 24, $sp, $t1
378 SDu $f0, $f1, 16, $sp, $t1
379
380 # 3 words padding and 1 word for holding Method*
381
382 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
383 lw $t0, 0($t0)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100384 lw $t0, RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET($t0)
Vladimir Marko952dbb12016-07-28 12:01:51 +0100385 sw $t0, 0($sp) # Place Method* at bottom of stack.
386 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
387 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
388 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
389.endm
390
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100391.macro RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +0100392 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
393 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
394
395 LDu $f30, $f31, 136, $sp, $t1
396 LDu $f28, $f29, 128, $sp, $t1
397 LDu $f26, $f27, 120, $sp, $t1
398 LDu $f24, $f25, 112, $sp, $t1
399 LDu $f22, $f23, 104, $sp, $t1
400 LDu $f20, $f21, 96, $sp, $t1
401 LDu $f18, $f19, 88, $sp, $t1
402 LDu $f16, $f17, 80, $sp, $t1
403 LDu $f14, $f15, 72, $sp, $t1
404 LDu $f12, $f13, 64, $sp, $t1
405 LDu $f10, $f11, 56, $sp, $t1
406 LDu $f8, $f9, 48, $sp, $t1
407 LDu $f6, $f7, 40, $sp, $t1
408 LDu $f4, $f5, 32, $sp, $t1
409 LDu $f2, $f3, 24, $sp, $t1
410 LDu $f0, $f1, 16, $sp, $t1
411
412 lw $ra, 252($sp)
413 .cfi_restore 31
414 lw $fp, 248($sp)
415 .cfi_restore 30
416 lw $gp, 244($sp)
417 .cfi_restore 28
418 lw $t9, 240($sp)
419 .cfi_restore 25
420 lw $t8, 236($sp)
421 .cfi_restore 24
422 lw $s7, 232($sp)
423 .cfi_restore 23
424 lw $s6, 228($sp)
425 .cfi_restore 22
426 lw $s5, 224($sp)
427 .cfi_restore 21
428 lw $s4, 220($sp)
429 .cfi_restore 20
430 lw $s3, 216($sp)
431 .cfi_restore 19
432 lw $s2, 212($sp)
433 .cfi_restore 18
434 lw $s1, 208($sp)
435 .cfi_restore 17
436 lw $s0, 204($sp)
437 .cfi_restore 16
438 lw $t7, 200($sp)
439 .cfi_restore 15
440 lw $t6, 196($sp)
441 .cfi_restore 14
442 lw $t5, 192($sp)
443 .cfi_restore 13
444 lw $t4, 188($sp)
445 .cfi_restore 12
446 lw $t3, 184($sp)
447 .cfi_restore 11
448 lw $t2, 180($sp)
449 .cfi_restore 10
450 lw $t1, 176($sp)
451 .cfi_restore 9
452 lw $t0, 172($sp)
453 .cfi_restore 8
454 lw $a3, 168($sp)
455 .cfi_restore 7
456 lw $a2, 164($sp)
457 .cfi_restore 6
458 lw $a1, 160($sp)
459 .cfi_restore 5
460 lw $a0, 156($sp)
461 .cfi_restore 4
462 lw $v1, 152($sp)
463 .cfi_restore 3
464 lw $v0, 148($sp)
465 .cfi_restore 2
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200466 .set push
467 .set noat
Vladimir Marko952dbb12016-07-28 12:01:51 +0100468 lw $at, 144($sp)
469 .cfi_restore 1
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200470 .set pop
Vladimir Marko952dbb12016-07-28 12:01:51 +0100471
472 addiu $sp, $sp, 256 # pop frame
473 .cfi_adjust_cfa_offset -256
474.endm
475
476 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800477 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
478 * exception is Thread::Current()->exception_
479 */
480.macro DELIVER_PENDING_EXCEPTION
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100481 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700482 la $t9, artDeliverPendingExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800483 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700484 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800485.endm
486
487.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700488 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100489 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700490 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800491 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800492 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800493 nop
4941:
495 DELIVER_PENDING_EXCEPTION
496.endm
497
498.macro RETURN_IF_ZERO
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100499 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700500 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800501 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800502 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800503 nop
5041:
505 DELIVER_PENDING_EXCEPTION
506.endm
507
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800508.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100509 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700510 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800511 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800512 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800513 nop
5141:
515 DELIVER_PENDING_EXCEPTION
516.endm
517
buzbee5bc5a7b2012-03-07 15:52:59 -0800518 /*
Goran Jakovljevic3bc13812016-03-22 17:16:05 +0100519 * On stack replacement stub.
520 * On entry:
521 * a0 = stack to copy
522 * a1 = size of stack
523 * a2 = pc to call
524 * a3 = JValue* result
525 * [sp + 16] = shorty
526 * [sp + 20] = thread
527 */
528ENTRY art_quick_osr_stub
529 // Save callee general purpose registers, RA and GP.
530 addiu $sp, $sp, -48
531 .cfi_adjust_cfa_offset 48
532 sw $ra, 44($sp)
533 .cfi_rel_offset 31, 44
534 sw $s8, 40($sp)
535 .cfi_rel_offset 30, 40
536 sw $gp, 36($sp)
537 .cfi_rel_offset 28, 36
538 sw $s7, 32($sp)
539 .cfi_rel_offset 23, 32
540 sw $s6, 28($sp)
541 .cfi_rel_offset 22, 28
542 sw $s5, 24($sp)
543 .cfi_rel_offset 21, 24
544 sw $s4, 20($sp)
545 .cfi_rel_offset 20, 20
546 sw $s3, 16($sp)
547 .cfi_rel_offset 19, 16
548 sw $s2, 12($sp)
549 .cfi_rel_offset 18, 12
550 sw $s1, 8($sp)
551 .cfi_rel_offset 17, 8
552 sw $s0, 4($sp)
553 .cfi_rel_offset 16, 4
554
555 move $s8, $sp # Save the stack pointer
556 move $s7, $a1 # Save size of stack
557 move $s6, $a2 # Save the pc to call
558 lw rSELF, 48+20($sp) # Save managed thread pointer into rSELF
559 addiu $t0, $sp, -12 # Reserve space for stack pointer,
560 # JValue* result, and ArtMethod* slot.
561 srl $t0, $t0, 4 # Align stack pointer to 16 bytes
562 sll $sp, $t0, 4 # Update stack pointer
563 sw $s8, 4($sp) # Save old stack pointer
564 sw $a3, 8($sp) # Save JValue* result
565 sw $zero, 0($sp) # Store null for ArtMethod* at bottom of frame
566 subu $sp, $a1 # Reserve space for callee stack
567 move $a2, $a1
568 move $a1, $a0
569 move $a0, $sp
570 la $t9, memcpy
571 jalr $t9 # memcpy (dest a0, src a1, bytes a2)
572 addiu $sp, $sp, -16 # make space for argument slots for memcpy
573 bal .Losr_entry # Call the method
574 addiu $sp, $sp, 16 # restore stack after memcpy
575 lw $a2, 8($sp) # Restore JValue* result
576 lw $sp, 4($sp) # Restore saved stack pointer
577 lw $a0, 48+16($sp) # load shorty
578 lbu $a0, 0($a0) # load return type
579 li $a1, 'D' # put char 'D' into a1
580 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'D'
581 li $a1, 'F' # put char 'F' into a1
582 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'F'
583 nop
584 sw $v0, 0($a2)
585 b .Losr_exit
586 sw $v1, 4($a2) # store v0/v1 into result
587.Losr_fp_result:
588 SDu $f0, $f1, 0, $a2, $t0 # store f0/f1 into result
589.Losr_exit:
590 lw $ra, 44($sp)
591 .cfi_restore 31
592 lw $s8, 40($sp)
593 .cfi_restore 30
594 lw $gp, 36($sp)
595 .cfi_restore 28
596 lw $s7, 32($sp)
597 .cfi_restore 23
598 lw $s6, 28($sp)
599 .cfi_restore 22
600 lw $s5, 24($sp)
601 .cfi_restore 21
602 lw $s4, 20($sp)
603 .cfi_restore 20
604 lw $s3, 16($sp)
605 .cfi_restore 19
606 lw $s2, 12($sp)
607 .cfi_restore 18
608 lw $s1, 8($sp)
609 .cfi_restore 17
610 lw $s0, 4($sp)
611 .cfi_restore 16
612 jalr $zero, $ra
613 addiu $sp, $sp, 48
614 .cfi_adjust_cfa_offset -48
615.Losr_entry:
616 addiu $s7, $s7, -4
617 addu $t0, $s7, $sp
618 move $t9, $s6
619 jalr $zero, $t9
620 sw $ra, 0($t0) # Store RA per the compiler ABI
621END art_quick_osr_stub
622
623 /*
jeffhao7fbee072012-08-24 17:56:54 -0700624 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800625 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
626 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800627ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800628 LDu $f0, $f1, 0*8, $a1, $t1
629 LDu $f2, $f3, 1*8, $a1, $t1
630 LDu $f4, $f5, 2*8, $a1, $t1
631 LDu $f6, $f7, 3*8, $a1, $t1
632 LDu $f8, $f9, 4*8, $a1, $t1
633 LDu $f10, $f11, 5*8, $a1, $t1
634 LDu $f12, $f13, 6*8, $a1, $t1
635 LDu $f14, $f15, 7*8, $a1, $t1
636 LDu $f16, $f17, 8*8, $a1, $t1
637 LDu $f18, $f19, 9*8, $a1, $t1
638 LDu $f20, $f21, 10*8, $a1, $t1
639 LDu $f22, $f23, 11*8, $a1, $t1
640 LDu $f24, $f25, 12*8, $a1, $t1
641 LDu $f26, $f27, 13*8, $a1, $t1
642 LDu $f28, $f29, 14*8, $a1, $t1
643 LDu $f30, $f31, 15*8, $a1, $t1
644
Chris Dearman748dd952014-05-23 10:47:01 -0700645 .set push
646 .set nomacro
647 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700648 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700649 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700650 lw $v0, 8($a0)
651 lw $v1, 12($a0)
652 lw $a1, 20($a0)
653 lw $a2, 24($a0)
654 lw $a3, 28($a0)
655 lw $t0, 32($a0)
656 lw $t1, 36($a0)
657 lw $t2, 40($a0)
658 lw $t3, 44($a0)
659 lw $t4, 48($a0)
660 lw $t5, 52($a0)
661 lw $t6, 56($a0)
662 lw $t7, 60($a0)
663 lw $s0, 64($a0)
664 lw $s1, 68($a0)
665 lw $s2, 72($a0)
666 lw $s3, 76($a0)
667 lw $s4, 80($a0)
668 lw $s5, 84($a0)
669 lw $s6, 88($a0)
670 lw $s7, 92($a0)
671 lw $t8, 96($a0)
672 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700673 lw $gp, 112($a0)
674 lw $sp, 116($a0)
675 lw $fp, 120($a0)
676 lw $ra, 124($a0)
677 lw $a0, 16($a0)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100678 move $v0, $zero # clear result registers v0 and v1 (in branch delay slot)
Goran Jakovljevic75969962015-10-27 12:29:07 +0100679 jalr $zero, $t9 # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700680 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800681END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800682
buzbee5bc5a7b2012-03-07 15:52:59 -0800683 /*
684 * Called by managed code, saves most registers (forms basis of long jump context) and passes
685 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
Lazar Trsic84bc06e2015-06-10 16:05:46 +0200686 * the bottom of the thread. On entry a0 holds Throwable*
buzbee5bc5a7b2012-03-07 15:52:59 -0800687 */
Ian Rogers468532e2013-08-05 10:56:33 -0700688ENTRY art_quick_deliver_exception
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100689 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700690 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800691 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700692 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700693END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800694
buzbee5bc5a7b2012-03-07 15:52:59 -0800695 /*
696 * Called by managed code to create and deliver a NullPointerException
697 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800698 .extern artThrowNullPointerExceptionFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700699ENTRY art_quick_throw_null_pointer_exception
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100700 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700701 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800702 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700703 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700704END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800705
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100706
707 /*
708 * Call installed by a signal handler to create and deliver a NullPointerException.
709 */
710 .extern artThrowNullPointerExceptionFromSignal
Nicolas Geoffray0719b5b2016-09-12 22:05:33 +0000711ENTRY art_quick_throw_null_pointer_exception_from_signal
712 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100713 la $t9, artThrowNullPointerExceptionFromSignal
714 jalr $zero, $t9 # artThrowNullPointerExceptionFromSignal(uintptr_t, Thread*)
715 move $a1, rSELF # pass Thread::Current
716END art_quick_throw_null_pointer_exception_from_signal
717
buzbee5bc5a7b2012-03-07 15:52:59 -0800718 /*
719 * Called by managed code to create and deliver an ArithmeticException
720 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800721 .extern artThrowDivZeroFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700722ENTRY art_quick_throw_div_zero
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100723 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700724 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800725 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700726 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700727END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800728
buzbee5bc5a7b2012-03-07 15:52:59 -0800729 /*
730 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
731 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800732 .extern artThrowArrayBoundsFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700733ENTRY art_quick_throw_array_bounds
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100734 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700735 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800736 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700737 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700738END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800739
Ian Rogers57b86d42012-03-27 16:05:41 -0700740 /*
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100741 * Called by managed code to create and deliver a StringIndexOutOfBoundsException
742 * as if thrown from a call to String.charAt().
743 */
744 .extern artThrowStringBoundsFromCode
745ENTRY art_quick_throw_string_bounds
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100746 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100747 la $t9, artThrowStringBoundsFromCode
748 jalr $zero, $t9 # artThrowStringBoundsFromCode(index, limit, Thread*)
749 move $a2, rSELF # pass Thread::Current
750END art_quick_throw_string_bounds
751
752 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700753 * Called by managed code to create and deliver a StackOverflowError.
754 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800755 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700756ENTRY art_quick_throw_stack_overflow
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100757 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700758 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800759 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700760 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700761END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800762
Ian Rogers57b86d42012-03-27 16:05:41 -0700763 /*
764 * Called by managed code to create and deliver a NoSuchMethodError.
765 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800766 .extern artThrowNoSuchMethodFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700767ENTRY art_quick_throw_no_such_method
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100768 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700769 la $t9, artThrowNoSuchMethodFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800770 jalr $zero, $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700771 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700772END art_quick_throw_no_such_method
buzbee5bc5a7b2012-03-07 15:52:59 -0800773
buzbee5bc5a7b2012-03-07 15:52:59 -0800774 /*
775 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700776 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100777 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700778 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800779 *
jeffhao7fbee072012-08-24 17:56:54 -0700780 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
781 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800782 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700783 * If unsuccessful, the helper will return null/null. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800784 * thread and we branch to another stub to deliver it.
785 *
786 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
787 * pointing back to the original caller.
788 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700789.macro INVOKE_TRAMPOLINE_BODY cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800790 .extern \cxx_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100791 SETUP_SAVE_REFS_AND_ARGS_FRAME # save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100792 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100793 la $t9, \cxx_name
794 jalr $t9 # (method_idx, this, Thread*, $sp)
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100795 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
796 move $a0, $v0 # save target Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100797 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700798 beqz $v0, 1f
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100799 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800800 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800801 nop
8021:
803 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700804.endm
805.macro INVOKE_TRAMPOLINE c_name, cxx_name
806ENTRY \c_name
807 INVOKE_TRAMPOLINE_BODY \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800808END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800809.endm
810
Logan Chien8dbb7082013-01-25 20:31:17 +0800811INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800812
Logan Chien8dbb7082013-01-25 20:31:17 +0800813INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
814INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
815INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
816INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800817
Goran Jakovljevicff734982015-08-24 12:58:55 +0000818.macro LOAD_WORD_TO_REG reg, next_arg, index, label
819 lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
820 b \label
821 addiu $\index, 1
822.endm
823
824.macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index, label
825 lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8)
826 lw $\reg2, -4($\next_arg)
827 b \label
828 li $\index, 4 # long can be loaded only to a2_a3 pair so index will be always 4
829.endm
830
831.macro LOAD_FLOAT_TO_REG reg, next_arg, index, label
832 lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
833 b \label
834 addiu $\index, 1
835.endm
836
837.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index, tmp, label
838 LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one
839 # (offset is 8)
840 b \label
841 addiu $\index, 1
842.endm
843
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100844#define SPILL_SIZE 32
845
Jeff Hao79fe5392013-04-24 18:41:58 -0700846 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800847 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800848 * On entry:
849 * a0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700850 * a1 = argument array or null for no argument methods
Jeff Hao5d917302013-02-27 17:57:33 -0800851 * a2 = size of argument array in bytes
852 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700853 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800854 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800855 */
856ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800857 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100858 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
859 .cfi_adjust_cfa_offset SPILL_SIZE
860 sw $gp, 16($sp)
Jeff Hao5d917302013-02-27 17:57:33 -0800861 sw $ra, 12($sp)
862 .cfi_rel_offset 31, 12
863 sw $fp, 8($sp)
864 .cfi_rel_offset 30, 8
865 sw $s1, 4($sp)
866 .cfi_rel_offset 17, 4
867 sw $s0, 0($sp)
868 .cfi_rel_offset 16, 0
869 move $fp, $sp # save sp in fp
870 .cfi_def_cfa_register 30
871 move $s1, $a3 # move managed thread pointer into s1
872 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Goran Jakovljevicff734982015-08-24 12:58:55 +0000873 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700874 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
Goran Jakovljevicff734982015-08-24 12:58:55 +0000875 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
876 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
877 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100878 la $t9, memcpy
879 jalr $t9 # (dest, src, bytes)
Jeff Hao5d917302013-02-27 17:57:33 -0800880 addiu $sp, $sp, -16 # make space for argument slots for memcpy
881 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100882 lw $gp, 16($fp) # restore $gp
883 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000884 lw $a1, 4($sp) # a1 = this*
885 addiu $t0, $sp, 8 # t0 = pointer to the current argument (skip ArtMethod* and this*)
886 li $t3, 2 # t3 = gpr_index = 2 (skip A0 and A1)
887 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100888 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
889 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000890 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
891loop:
892 lbu $t2, 0($t1) # t2 = shorty[i]
893 beqz $t2, loopEnd # finish getting args when shorty[i] == '\0'
894 addiu $t1, 1
895
896 li $t9, 'J' # put char 'J' into t9
897 beq $t9, $t2, isLong # branch if result type char == 'J'
898 li $t9, 'D' # put char 'D' into t9
899 beq $t9, $t2, isDouble # branch if result type char == 'D'
900 li $t9, 'F' # put char 'F' into t9
901 beq $t9, $t2, isSingle # branch if result type char == 'F'
902 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
903 # for both, int and single)
904
905 li $t5, 2 # skip a0 and a1 (ArtMethod* and this*)
906 bne $t5, $t3, 1f # if (gpr_index == 2)
907 addiu $t5, 1
908 LOAD_WORD_TO_REG a2, t0, t3, loop # a2 = current argument, gpr_index++
9091: bne $t5, $t3, loop # else if (gpr_index == 3)
910 nop
911 LOAD_WORD_TO_REG a3, t0, t3, loop # a3 = current argument, gpr_index++
912
913isLong:
914 addiu $t0, 8 # next_arg = curr_arg + 8
915 slti $t5, $t3, 3
916 beqz $t5, 2f # if (gpr_index < 3)
917 nop
918 LOAD_LONG_TO_REG a2, a3, t0, t3, loop # a2_a3 = curr_arg, gpr_index = 4
9192: b loop # else
920 li $t3, 4 # gpr_index = 4
921
922isDouble:
923 addiu $t0, 8 # next_arg = curr_arg + 8
924 li $t5, 0
925 bne $t5, $t4, 3f # if (fp_index == 0)
926 addiu $t5, 1
927 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loop # f12_f13 = curr_arg, fp_index++
9283: bne $t5, $t4, loop # else if (fp_index == 1)
929 nop
930 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loop # f14_f15 = curr_arg, fp_index++
931
932isSingle:
933 li $t5, 0
934 bne $t5, $t4, 4f # if (fp_index == 0)
935 addiu $t5, 1
936 LOAD_FLOAT_TO_REG f12, t0, t4, loop # f12 = curr_arg, fp_index++
9374: bne $t5, $t4, loop # else if (fp_index == 1)
938 nop
939 LOAD_FLOAT_TO_REG f14, t0, t4, loop # f14 = curr_arg, fp_index++
940
941loopEnd:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700942 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800943 jalr $t9 # call the method
Goran Jakovljevicff734982015-08-24 12:58:55 +0000944 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
Jeff Hao5d917302013-02-27 17:57:33 -0800945 move $sp, $fp # restore the stack
946 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800947 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -0800948 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800949 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -0800950 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800951 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -0800952 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800953 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100954 addiu $sp, $sp, SPILL_SIZE
955 .cfi_adjust_cfa_offset -SPILL_SIZE
Jeff Hao5d917302013-02-27 17:57:33 -0800956 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -0800957 lw $t1, 20($sp) # get shorty
958 lb $t1, 0($t1) # get result type char
Goran Jakovljevicff734982015-08-24 12:58:55 +0000959 li $t2, 'D' # put char 'D' into t2
960 beq $t1, $t2, 5f # branch if result type char == 'D'
961 li $t3, 'F' # put char 'F' into t3
962 beq $t1, $t3, 5f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -0800963 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -0800964 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -0800965 sw $v1, 4($t0) # store the other half of the result
Goran Jakovljevicff734982015-08-24 12:58:55 +00009665:
Duane Sande34652f2014-11-04 11:09:36 -0800967 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -0800968 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -0800969 nop
Jeff Hao5d917302013-02-27 17:57:33 -0800970END art_quick_invoke_stub
971
972 /*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000973 * Invocation static stub for quick code.
974 * On entry:
975 * a0 = method pointer
976 * a1 = argument array or null for no argument methods
977 * a2 = size of argument array in bytes
978 * a3 = (managed) thread pointer
979 * [sp + 16] = JValue* result
980 * [sp + 20] = shorty
981 */
982ENTRY art_quick_invoke_static_stub
983 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100984 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
985 .cfi_adjust_cfa_offset SPILL_SIZE
986 sw $gp, 16($sp)
Goran Jakovljevicff734982015-08-24 12:58:55 +0000987 sw $ra, 12($sp)
988 .cfi_rel_offset 31, 12
989 sw $fp, 8($sp)
990 .cfi_rel_offset 30, 8
991 sw $s1, 4($sp)
992 .cfi_rel_offset 17, 4
993 sw $s0, 0($sp)
994 .cfi_rel_offset 16, 0
995 move $fp, $sp # save sp in fp
996 .cfi_def_cfa_register 30
997 move $s1, $a3 # move managed thread pointer into s1
998 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
999 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
1000 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
1001 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
1002 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
1003 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001004 la $t9, memcpy
1005 jalr $t9 # (dest, src, bytes)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001006 addiu $sp, $sp, -16 # make space for argument slots for memcpy
1007 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001008 lw $gp, 16($fp) # restore $gp
1009 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +00001010 addiu $t0, $sp, 4 # t0 = pointer to the current argument (skip ArtMethod*)
1011 li $t3, 1 # t3 = gpr_index = 1 (skip A0)
1012 move $t4, $zero # t4 = fp_index = 0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001013 lw $t1, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
1014 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001015 addiu $t1, 1 # t1 = shorty + 1 (skip 1 for return type)
1016loopS:
1017 lbu $t2, 0($t1) # t2 = shorty[i]
1018 beqz $t2, loopEndS # finish getting args when shorty[i] == '\0'
1019 addiu $t1, 1
1020
1021 li $t9, 'J' # put char 'J' into t9
1022 beq $t9, $t2, isLongS # branch if result type char == 'J'
1023 li $t9, 'D' # put char 'D' into t9
1024 beq $t9, $t2, isDoubleS # branch if result type char == 'D'
1025 li $t9, 'F' # put char 'F' into t9
1026 beq $t9, $t2, isSingleS # branch if result type char == 'F'
1027 addiu $t0, 4 # next_arg = curr_arg + 4 (in branch delay slot,
1028 # for both, int and single)
1029
1030 li $t5, 1 # skip a0 (ArtMethod*)
1031 bne $t5, $t3, 1f # if (gpr_index == 1)
1032 addiu $t5, 1
1033 LOAD_WORD_TO_REG a1, t0, t3, loopS # a1 = current argument, gpr_index++
10341: bne $t5, $t3, 2f # else if (gpr_index == 2)
1035 addiu $t5, 1
1036 LOAD_WORD_TO_REG a2, t0, t3, loopS # a2 = current argument, gpr_index++
10372: bne $t5, $t3, loopS # else if (gpr_index == 3)
1038 nop
1039 LOAD_WORD_TO_REG a3, t0, t3, loopS # a3 = current argument, gpr_index++
1040
1041isLongS:
1042 addiu $t0, 8 # next_arg = curr_arg + 8
1043 slti $t5, $t3, 3
1044 beqz $t5, 3f # if (gpr_index < 3)
1045 nop
1046 LOAD_LONG_TO_REG a2, a3, t0, t3, loopS # a2_a3 = curr_arg, gpr_index = 4
10473: b loopS # else
1048 li $t3, 4 # gpr_index = 4
1049
1050isDoubleS:
1051 addiu $t0, 8 # next_arg = curr_arg + 8
1052 li $t5, 0
1053 bne $t5, $t4, 4f # if (fp_index == 0)
1054 addiu $t5, 1
1055 LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loopS # f12_f13 = curr_arg, fp_index++
10564: bne $t5, $t4, loopS # else if (fp_index == 1)
1057 nop
1058 LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loopS # f14_f15 = curr_arg, fp_index++
1059
1060isSingleS:
1061 li $t5, 0
1062 bne $t5, $t4, 5f # if (fp_index == 0)
1063 addiu $t5, 1
1064 LOAD_FLOAT_TO_REG f12, t0, t4, loopS # f12 = curr_arg, fp_index++
10655: bne $t5, $t4, loopS # else if (fp_index == 1)
1066 nop
1067 LOAD_FLOAT_TO_REG f14, t0, t4, loopS # f14 = curr_arg, fp_index++
1068
1069loopEndS:
1070 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
1071 jalr $t9 # call the method
1072 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
1073 move $sp, $fp # restore the stack
1074 lw $s0, 0($sp)
1075 .cfi_restore 16
1076 lw $s1, 4($sp)
1077 .cfi_restore 17
1078 lw $fp, 8($sp)
1079 .cfi_restore 30
1080 lw $ra, 12($sp)
1081 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001082 addiu $sp, $sp, SPILL_SIZE
1083 .cfi_adjust_cfa_offset -SPILL_SIZE
Goran Jakovljevicff734982015-08-24 12:58:55 +00001084 lw $t0, 16($sp) # get result pointer
1085 lw $t1, 20($sp) # get shorty
1086 lb $t1, 0($t1) # get result type char
1087 li $t2, 'D' # put char 'D' into t2
1088 beq $t1, $t2, 6f # branch if result type char == 'D'
1089 li $t3, 'F' # put char 'F' into t3
1090 beq $t1, $t3, 6f # branch if result type char == 'F'
1091 sw $v0, 0($t0) # store the result
1092 jalr $zero, $ra
1093 sw $v1, 4($t0) # store the other half of the result
10946:
1095 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
1096 jalr $zero, $ra
1097 nop
1098END art_quick_invoke_static_stub
1099
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001100#undef SPILL_SIZE
1101
Goran Jakovljevicff734982015-08-24 12:58:55 +00001102 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08001103 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
1104 * failure.
1105 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001106 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001107ENTRY art_quick_handle_fill_data
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001108 lw $a2, 0($sp) # pass referrer's Method*
1109 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001110 la $t9, artHandleFillArrayDataFromCode
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001111 jalr $t9 # (payload offset, Array*, method, Thread*)
1112 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -07001113 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001114END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -08001115
buzbee5bc5a7b2012-03-07 15:52:59 -08001116 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001117 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -08001118 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001119 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001120ENTRY art_quick_lock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -08001121 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001122 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001123 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001124 la $t9, artLockObjectFromCode
1125 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001126 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -07001127 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001128END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001129
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001130ENTRY art_quick_lock_object_no_inline
1131 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
1132 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001133 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001134 la $t9, artLockObjectFromCode
1135 jalr $t9 # (Object* obj, Thread*)
1136 move $a1, rSELF # pass Thread::Current
1137 RETURN_IF_ZERO
1138END art_quick_lock_object_no_inline
1139
buzbee5bc5a7b2012-03-07 15:52:59 -08001140 /*
1141 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
1142 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001143 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001144ENTRY art_quick_unlock_object
Ian Rogers86bcdc22014-02-21 22:06:38 -08001145 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001146 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001147 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001148 la $t9, artUnlockObjectFromCode
1149 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001150 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001151 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001152END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001153
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001154ENTRY art_quick_unlock_object_no_inline
1155 beqz $a0, .Lart_quick_throw_null_pointer_exception_gp_set
1156 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001157 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001158 la $t9, artUnlockObjectFromCode
1159 jalr $t9 # (Object* obj, Thread*)
1160 move $a1, rSELF # pass Thread::Current
1161 RETURN_IF_ZERO
1162END art_quick_unlock_object_no_inline
1163
buzbee5bc5a7b2012-03-07 15:52:59 -08001164 /*
1165 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
1166 */
Ian Rogersa9a82542013-10-04 11:17:26 -07001167 .extern artThrowClassCastException
Ian Rogers468532e2013-08-05 10:56:33 -07001168ENTRY art_quick_check_cast
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001169 addiu $sp, $sp, -32
1170 .cfi_adjust_cfa_offset 32
1171 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001172 sw $ra, 12($sp)
1173 .cfi_rel_offset 31, 12
1174 sw $t9, 8($sp)
1175 sw $a1, 4($sp)
1176 sw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001177 la $t9, artIsAssignableFromCode
1178 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001179 addiu $sp, $sp, -16 # reserve argument slots on the stack
1180 addiu $sp, $sp, 16
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001181 lw $gp, 16($sp)
Ian Rogers86bcdc22014-02-21 22:06:38 -08001182 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001183 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -08001184 jalr $zero, $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001185 addiu $sp, $sp, 32
1186 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001187.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -07001188 lw $t9, 8($sp)
1189 lw $a1, 4($sp)
1190 lw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001191 addiu $sp, $sp, 32
1192 .cfi_adjust_cfa_offset -32
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001193 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -07001194 la $t9, artThrowClassCastException
Andreas Gampe8d365912015-01-13 11:32:32 -08001195 jalr $zero, $t9 # artThrowClassCastException (Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001196 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -07001197END art_quick_check_cast
buzbee5bc5a7b2012-03-07 15:52:59 -08001198
buzbee5bc5a7b2012-03-07 15:52:59 -08001199 /*
Man Cao1aee9002015-07-14 22:31:42 -07001200 * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
1201 * nReg is the register number for rReg.
1202 */
1203.macro POP_REG_NE rReg, nReg, offset, rExclude
1204 .ifnc \rReg, \rExclude
1205 lw \rReg, \offset($sp) # restore rReg
1206 .cfi_restore \nReg
1207 .endif
1208.endm
1209
1210 /*
1211 * Macro to insert read barrier, only used in art_quick_aput_obj.
1212 * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
1213 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
1214 */
1215.macro READ_BARRIER rDest, rObj, offset
1216#ifdef USE_READ_BARRIER
1217 # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment.
1218 addiu $sp, $sp, -32
1219 .cfi_adjust_cfa_offset 32
1220 sw $ra, 28($sp)
1221 .cfi_rel_offset 31, 28
1222 sw $t9, 24($sp)
1223 .cfi_rel_offset 25, 24
1224 sw $t1, 20($sp)
1225 .cfi_rel_offset 9, 20
1226 sw $t0, 16($sp)
1227 .cfi_rel_offset 8, 16
1228 sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B)
1229 .cfi_rel_offset 6, 8
1230 sw $a1, 4($sp)
1231 .cfi_rel_offset 5, 4
1232 sw $a0, 0($sp)
1233 .cfi_rel_offset 4, 0
1234
Man Cao63069212015-08-21 15:51:39 -07001235 # move $a0, \rRef # pass ref in a0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -07001236 .ifnc \rObj, $a1
1237 move $a1, \rObj # pass rObj
1238 .endif
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001239 addiu $a2, $zero, \offset # pass offset
1240 la $t9, artReadBarrierSlow
1241 jalr $t9 # artReadBarrierSlow(ref, rObj, offset)
Man Cao1aee9002015-07-14 22:31:42 -07001242 addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack
1243 # before the call to artReadBarrierSlow.
1244 addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow
1245 # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
1246 move \rDest, $v0 # save return value in rDest
1247 # (rDest cannot be v0 in art_quick_aput_obj)
1248
1249 lw $a0, 0($sp) # restore registers except rDest
1250 # (rDest can only be t0 or t1 in art_quick_aput_obj)
1251 .cfi_restore 4
1252 lw $a1, 4($sp)
1253 .cfi_restore 5
1254 lw $a2, 8($sp)
1255 .cfi_restore 6
1256 POP_REG_NE $t0, 8, 16, \rDest
1257 POP_REG_NE $t1, 9, 20, \rDest
1258 lw $t9, 24($sp)
1259 .cfi_restore 25
1260 lw $ra, 28($sp) # restore $ra
1261 .cfi_restore 31
1262 addiu $sp, $sp, 32
1263 .cfi_adjust_cfa_offset -32
1264#else
1265 lw \rDest, \offset(\rObj)
1266 UNPOISON_HEAP_REF \rDest
1267#endif // USE_READ_BARRIER
1268.endm
1269
1270 /*
Ian Rogersa9a82542013-10-04 11:17:26 -07001271 * Entry from managed code for array put operations of objects where the value being stored
1272 * needs to be checked for compatibility.
1273 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -08001274 */
Ian Rogersa9a82542013-10-04 11:17:26 -07001275ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -08001276 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001277 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001278 b .Lart_quick_throw_null_pointer_exception_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001279 nop
1280END art_quick_aput_obj_with_null_and_bound_check
1281
1282ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001283 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001284 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -08001285 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001286 nop
1287 move $a0, $a1
Ian Rogers86bcdc22014-02-21 22:06:38 -08001288 b .Lart_quick_throw_array_bounds_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001289 move $a1, $t0
1290END art_quick_aput_obj_with_bound_check
1291
Man Cao1aee9002015-07-14 22:31:42 -07001292#ifdef USE_READ_BARRIER
1293 .extern artReadBarrierSlow
1294#endif
Ian Rogersa9a82542013-10-04 11:17:26 -07001295ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -08001296 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -07001297 nop
Man Cao1aee9002015-07-14 22:31:42 -07001298 READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
1299 READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
1300 READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogers86bcdc22014-02-21 22:06:38 -08001301 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -07001302 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001303.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -07001304 sll $a1, $a1, 2
1305 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001306 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001307 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001308 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
1309 srl $t1, $a0, 7
1310 add $t1, $t1, $t0
1311 sb $t0, ($t1)
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.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -07001315 sll $a1, $a1, 2
1316 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001317 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -08001318 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001319 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001320.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -07001321 addiu $sp, $sp, -32
1322 .cfi_adjust_cfa_offset 32
1323 sw $ra, 28($sp)
1324 .cfi_rel_offset 31, 28
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001325 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001326 sw $t9, 12($sp)
1327 sw $a2, 8($sp)
1328 sw $a1, 4($sp)
1329 sw $a0, 0($sp)
1330 move $a1, $t1
1331 move $a0, $t0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001332 la $t9, artIsAssignableFromCode
1333 jalr $t9 # (Class*, Class*)
1334 addiu $sp, $sp, -16 # reserve argument slots on the stack
1335 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -07001336 lw $ra, 28($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001337 lw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001338 lw $t9, 12($sp)
1339 lw $a2, 8($sp)
1340 lw $a1, 4($sp)
1341 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001342 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -07001343 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001344 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -07001345 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001346 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -07001347 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -07001348 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -08001349 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001350 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -07001351END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -08001352
buzbee5bc5a7b2012-03-07 15:52:59 -08001353 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001354 * Called by managed code to resolve a static field and load a boolean primitive value.
1355 */
1356 .extern artGetBooleanStaticFromCode
1357ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -07001358 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001359 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001360 la $t9, artGetBooleanStaticFromCode
1361 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001362 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001363 RETURN_IF_NO_EXCEPTION
1364END art_quick_get_boolean_static
1365 /*
1366 * Called by managed code to resolve a static field and load a byte primitive value.
1367 */
1368 .extern artGetByteStaticFromCode
1369ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -07001370 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001371 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001372 la $t9, artGetByteStaticFromCode
1373 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001374 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001375 RETURN_IF_NO_EXCEPTION
1376END art_quick_get_byte_static
1377
1378 /*
1379 * Called by managed code to resolve a static field and load a char primitive value.
1380 */
1381 .extern artGetCharStaticFromCode
1382ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -07001383 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001384 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001385 la $t9, artGetCharStaticFromCode
1386 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001387 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001388 RETURN_IF_NO_EXCEPTION
1389END art_quick_get_char_static
1390 /*
1391 * Called by managed code to resolve a static field and load a short primitive value.
1392 */
1393 .extern artGetShortStaticFromCode
1394ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -07001395 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001396 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001397 la $t9, artGetShortStaticFromCode
1398 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001399 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001400 RETURN_IF_NO_EXCEPTION
1401END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001402
buzbee5bc5a7b2012-03-07 15:52:59 -08001403 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001404 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001405 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001406 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001407ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001408 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001409 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001410 la $t9, artGet32StaticFromCode
1411 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001412 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001413 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001414END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001415
buzbee5bc5a7b2012-03-07 15:52:59 -08001416 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001417 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001418 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001419 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001420ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001421 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001422 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001423 la $t9, artGet64StaticFromCode
1424 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001425 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001426 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001427END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001428
buzbee5bc5a7b2012-03-07 15:52:59 -08001429 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001430 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001431 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001432 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001433ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001434 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001435 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001436 la $t9, artGetObjStaticFromCode
1437 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001438 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001439 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001440END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001441
buzbee5bc5a7b2012-03-07 15:52:59 -08001442 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001443 * Called by managed code to resolve an instance field and load a boolean primitive value.
1444 */
1445 .extern artGetBooleanInstanceFromCode
1446ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001447 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001448 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001449 la $t9, artGetBooleanInstanceFromCode
1450 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001451 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001452 RETURN_IF_NO_EXCEPTION
1453END art_quick_get_boolean_instance
1454 /*
1455 * Called by managed code to resolve an instance field and load a byte primitive value.
1456 */
1457 .extern artGetByteInstanceFromCode
1458ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001459 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001460 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001461 la $t9, artGetByteInstanceFromCode
1462 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001463 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001464 RETURN_IF_NO_EXCEPTION
1465END art_quick_get_byte_instance
1466
1467 /*
1468 * Called by managed code to resolve an instance field and load a char primitive value.
1469 */
1470 .extern artGetCharInstanceFromCode
1471ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001472 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001473 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001474 la $t9, artGetCharInstanceFromCode
1475 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001476 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001477 RETURN_IF_NO_EXCEPTION
1478END art_quick_get_char_instance
1479 /*
1480 * Called by managed code to resolve an instance field and load a short primitive value.
1481 */
1482 .extern artGetShortInstanceFromCode
1483ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001484 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001485 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001486 la $t9, artGetShortInstanceFromCode
1487 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001488 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001489 RETURN_IF_NO_EXCEPTION
1490END art_quick_get_short_instance
1491
1492 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001493 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001494 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001495 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001496ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001497 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001498 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001499 la $t9, artGet32InstanceFromCode
1500 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001501 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001502 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001503END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001504
buzbee5bc5a7b2012-03-07 15:52:59 -08001505 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001506 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001507 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001508 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001509ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001510 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001511 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001512 la $t9, artGet64InstanceFromCode
1513 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001514 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001515 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001516END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001517
buzbee5bc5a7b2012-03-07 15:52:59 -08001518 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001519 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001520 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001521 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001522ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001523 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001524 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001525 la $t9, artGetObjInstanceFromCode
1526 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001527 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001528 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001529END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001530
buzbee5bc5a7b2012-03-07 15:52:59 -08001531 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001532 * Called by managed code to resolve a static field and store a 8-bit primitive value.
1533 */
1534 .extern artSet8StaticFromCode
1535ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -07001536 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001537 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001538 la $t9, artSet8StaticFromCode
1539 jalr $t9 # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001540 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001541 RETURN_IF_ZERO
1542END art_quick_set8_static
1543
1544 /*
1545 * Called by managed code to resolve a static field and store a 16-bit primitive value.
1546 */
1547 .extern artSet16StaticFromCode
1548ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -07001549 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001550 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001551 la $t9, artSet16StaticFromCode
1552 jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001553 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001554 RETURN_IF_ZERO
1555END art_quick_set16_static
1556
1557 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001558 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001559 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001560 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001561ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001562 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001563 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001564 la $t9, artSet32StaticFromCode
1565 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001566 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001567 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001568END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001569
buzbee5bc5a7b2012-03-07 15:52:59 -08001570 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001571 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001572 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001573 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001574ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001575 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001576 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001577 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001578 la $t9, artSet64StaticFromCode
1579 jalr $t9 # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001580 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001581 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001582END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001583
buzbee5bc5a7b2012-03-07 15:52:59 -08001584 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001585 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001586 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001587 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001588ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001589 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001590 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001591 la $t9, artSetObjStaticFromCode
1592 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001593 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001594 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001595END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001596
buzbee5bc5a7b2012-03-07 15:52:59 -08001597 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001598 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1599 */
1600 .extern artSet8InstanceFromCode
1601ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001602 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001603 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001604 la $t9, artSet8InstanceFromCode
1605 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001606 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001607 RETURN_IF_ZERO
1608END art_quick_set8_instance
1609
1610 /*
1611 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1612 */
1613 .extern artSet16InstanceFromCode
1614ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001615 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001616 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001617 la $t9, artSet16InstanceFromCode
1618 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001619 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001620 RETURN_IF_ZERO
1621END art_quick_set16_instance
1622
1623 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001624 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001625 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001626 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001627ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001628 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001629 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001630 la $t9, artSet32InstanceFromCode
1631 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001632 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001633 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001634END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001635
buzbee5bc5a7b2012-03-07 15:52:59 -08001636 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001637 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001638 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001639 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001640ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001641 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001642 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001643 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001644 sw rSELF, 20($sp) # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001645 la $t9, artSet64InstanceFromCode
1646 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001647 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001648 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001649END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001650
buzbee5bc5a7b2012-03-07 15:52:59 -08001651 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001652 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001653 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001654 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001655ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001656 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001657 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001658 la $t9, artSetObjInstanceFromCode
1659 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001660 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001661 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001662END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001663
Vladimir Markoa3c38272015-04-28 12:37:09 +01001664// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001665.macro ONE_ARG_DOWNCALL name, entrypoint, return
1666 .extern \entrypoint
1667ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001668 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001669 la $t9, \entrypoint
1670 jalr $t9
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001671 move $a1, rSELF # pass Thread::Current
1672 \return
1673END \name
1674.endm
1675
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001676.macro TWO_ARG_DOWNCALL name, entrypoint, return
1677 .extern \entrypoint
1678ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001679 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001680 la $t9, \entrypoint
1681 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001682 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001683 \return
1684END \name
1685.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001686
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001687.macro THREE_ARG_DOWNCALL name, entrypoint, return
1688 .extern \entrypoint
1689ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001690 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001691 la $t9, \entrypoint
1692 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001693 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001694 \return
1695END \name
1696.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001697
Jeff Hao848f70a2014-01-15 13:49:50 -08001698.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1699 .extern \entrypoint
1700ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001701 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001702 la $t9, \entrypoint
1703 jalr $t9
Vladimir Markoa3c38272015-04-28 12:37:09 +01001704 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001705 \return
1706END \name
1707.endm
1708
Mathieu Chartier7410f292013-11-24 13:17:35 -08001709// Generate the allocation entrypoints for each allocator.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001710GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001711
Pavle Batuta712c59d2015-12-02 18:39:01 +01001712// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1713ENTRY art_quick_alloc_object_rosalloc
1714
1715 # Fast path rosalloc allocation
1716 # a0: type_idx
1717 # a1: ArtMethod*
1718 # s1: Thread::Current
1719 # -----------------------------
1720 # t0: class
1721 # t1: object size
1722 # t2: rosalloc run
1723 # t3: thread stack top offset
1724 # t4: thread stack bottom offset
1725 # v0: free list head
1726 #
1727 # t5, t6 : temps
1728
1729 lw $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_32($a1) # Load dex cache resolved types
1730 # array.
1731
1732 sll $t5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT # Shift the value.
1733 addu $t5, $t0, $t5 # Compute the index.
1734 lw $t0, 0($t5) # Load class (t0).
1735 beqz $t0, .Lart_quick_alloc_object_rosalloc_slow_path
1736
1737 li $t6, MIRROR_CLASS_STATUS_INITIALIZED
1738 lw $t5, MIRROR_CLASS_STATUS_OFFSET($t0) # Check class status.
1739 bne $t5, $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1740
1741 # Add a fake dependence from the following access flag and size loads to the status load. This
1742 # is to prevent those loads from being reordered above the status load and reading wrong values.
1743 xor $t5, $t5, $t5
1744 addu $t0, $t0, $t5
1745
1746 lw $t5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0) # Check if access flags has
1747 li $t6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE # kAccClassIsFinalizable.
1748 and $t6, $t5, $t6
1749 bnez $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1750
1751 lw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1) # Check if thread local allocation
1752 lw $t4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1) # stack has any room left.
1753 bgeu $t3, $t4, .Lart_quick_alloc_object_rosalloc_slow_path
1754
1755 lw $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0) # Load object size (t1).
1756 li $t5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE # Check if size is for a thread local
1757 # allocation.
1758 bgtu $t1, $t5, .Lart_quick_alloc_object_rosalloc_slow_path
1759
1760 # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket
1761 # quantum size and divide by the quantum size and subtract by 1.
1762
1763 addiu $t1, $t1, -1 # Decrease obj size and shift right
1764 srl $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT # by quantum.
1765
1766 sll $t2, $t1, POINTER_SIZE_SHIFT
1767 addu $t2, $t2, $s1
1768 lw $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2) # Load rosalloc run (t2).
1769
1770 # Load the free list head (v0).
1771 # NOTE: this will be the return val.
1772
1773 lw $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1774 beqz $v0, .Lart_quick_alloc_object_rosalloc_slow_path
1775 nop
1776
1777 # Load the next pointer of the head and update the list head with the next pointer.
1778
1779 lw $t5, ROSALLOC_SLOT_NEXT_OFFSET($v0)
1780 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1781
1782 # Store the class pointer in the header. This also overwrites the first pointer. The offsets are
1783 # asserted to match.
1784
1785#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1786#error "Class pointer needs to overwrite next pointer."
1787#endif
1788
1789 POISON_HEAP_REF $t0
1790 sw $t0, MIRROR_OBJECT_CLASS_OFFSET($v0)
1791
1792 # Push the new object onto the thread local allocation stack and increment the thread local
1793 # allocation stack top.
1794
1795 sw $v0, 0($t3)
1796 addiu $t3, $t3, COMPRESSED_REFERENCE_SIZE
1797 sw $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)
1798
1799 # Decrement the size of the free list.
1800
1801 lw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1802 addiu $t5, $t5, -1
1803 sw $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1804
1805 sync # Fence.
1806
1807 jalr $zero, $ra
1808 nop
1809
1810 .Lart_quick_alloc_object_rosalloc_slow_path:
1811
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001812 SETUP_SAVE_REFS_ONLY_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001813 la $t9, artAllocObjectFromCodeRosAlloc
1814 jalr $t9
Chris Larsencf283da2016-01-19 16:45:35 -08001815 move $a2, $s1 # Pass self as argument.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001816 RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1817
1818END art_quick_alloc_object_rosalloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001819
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001820GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB)
1821GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB)
1822
buzbee5bc5a7b2012-03-07 15:52:59 -08001823 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001824 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001825 * exception on error. On success the String is returned. A0 holds the string index. The fast
1826 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001827 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001828ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001829
1830 /*
1831 * Entry from managed code when uninitialized static storage, this stub will run the class
1832 * initializer and deliver the exception on error. On success the static storage base is
1833 * returned.
1834 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001835ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001836
1837 /*
1838 * Entry from managed code when dex cache misses for a type_idx.
1839 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001840ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001841
1842 /*
1843 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1844 * miss.
1845 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001846ONE_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 -08001847
1848 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001849 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001850 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001851 .extern artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001852ENTRY_NO_GP art_quick_test_suspend
1853 lh rSUSPEND, THREAD_FLAGS_OFFSET(rSELF)
1854 bnez rSUSPEND, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001855 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001856 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001857 nop
18581:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001859 SETUP_SAVE_EVERYTHING_FRAME # save everything for stack crawl
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001860 la $t9, artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001861 jalr $t9 # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001862 move $a0, rSELF
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001863 RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +01001864 jalr $zero, $ra
1865 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001866END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001867
buzbee5bc5a7b2012-03-07 15:52:59 -08001868 /*
1869 * Called by managed code that is attempting to call a method on a proxy class. On entry
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001870 * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001871 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001872 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001873ENTRY art_quick_proxy_invoke_handler
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001874 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001875 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001876 la $t9, artQuickProxyInvokeHandler
1877 jalr $t9 # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001878 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
jeffhao7fbee072012-08-24 17:56:54 -07001879 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001880 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhao7fbee072012-08-24 17:56:54 -07001881 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001882 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1883 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001884 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001885 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080018861:
1887 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001888END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001889
Jeff Hao88474b42013-10-23 16:24:40 -07001890 /*
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001891 * Called to resolve an imt conflict.
1892 * a0 is the conflict ArtMethod.
1893 * t0 is a hidden argument that holds the target interface method's dex method index.
1894 *
1895 * Note that this stub writes to a0, t0 and t1.
Jeff Hao88474b42013-10-23 16:24:40 -07001896 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001897ENTRY art_quick_imt_conflict_trampoline
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001898 lw $t1, 0($sp) # Load referrer.
1899 lw $t1, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t1) # Load dex cache methods array.
1900 sll $t0, $t0, POINTER_SIZE_SHIFT # Calculate offset.
1901 addu $t0, $t1, $t0 # Add offset to base.
1902 lw $t0, 0($t0) # Load interface method.
1903 lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable.
1904
1905.Limt_table_iterate:
1906 lw $t1, 0($a0) # Load next entry in ImtConflictTable.
1907 # Branch if found.
1908 beq $t1, $t0, .Limt_table_found
1909 nop
1910 # If the entry is null, the interface method is not in the ImtConflictTable.
1911 beqz $t1, .Lconflict_trampoline
1912 nop
1913 # Iterate over the entries of the ImtConflictTable.
1914 b .Limt_table_iterate
1915 addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry.
1916
1917.Limt_table_found:
1918 # We successfully hit an entry in the table. Load the target method and jump to it.
1919 lw $a0, __SIZEOF_POINTER__($a0)
1920 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
1921 jr $t9
1922 nop
1923
1924.Lconflict_trampoline:
1925 # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001926 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001927END art_quick_imt_conflict_trampoline
1928
Ian Rogers468532e2013-08-05 10:56:33 -07001929 .extern artQuickResolutionTrampoline
1930ENTRY art_quick_resolution_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001931 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001932 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001933 la $t9, artQuickResolutionTrampoline
1934 jalr $t9 # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001935 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001936 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001937 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001938 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001939 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001940 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001941 nop
Ian Rogers468532e2013-08-05 10:56:33 -070019421:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001943 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001944 DELIVER_PENDING_EXCEPTION
1945END art_quick_resolution_trampoline
1946
Douglas Leung735b8552014-10-31 12:21:40 -07001947 .extern artQuickGenericJniTrampoline
1948 .extern artQuickGenericJniEndTrampoline
1949ENTRY art_quick_generic_jni_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001950 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001951 move $s8, $sp # save $sp to $s8
1952 move $s3, $gp # save $gp to $s3
1953
1954 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1955 move $a0, rSELF # pass Thread::Current
1956 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001957 la $t9, artQuickGenericJniTrampoline
1958 jalr $t9 # (Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001959 addiu $sp, $sp, -5120 # reserve space on the stack
1960
1961 # The C call will have registered the complete save-frame on success.
1962 # The result of the call is:
1963 # v0: ptr to native code, 0 on error.
1964 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1965 beq $v0, $zero, 1f # check entry error
1966 move $t9, $v0 # save the code ptr
1967 move $sp, $v1 # release part of the alloca
1968
1969 # Load parameters from stack into registers
1970 lw $a0, 0($sp)
1971 lw $a1, 4($sp)
1972 lw $a2, 8($sp)
1973
1974 # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1975 jalr $t9 # native call
1976 lw $a3, 12($sp)
1977 addiu $sp, $sp, 16 # remove arg slots
1978
1979 move $gp, $s3 # restore $gp from $s3
1980
1981 # result sign extension is handled in C code
1982 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1983 move $a0, rSELF # pass Thread::Current
1984 move $a2, $v0 # pass result
1985 move $a3, $v1
1986 addiu $sp, $sp, -24 # reserve arg slots
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001987 la $t9, artQuickGenericJniEndTrampoline
1988 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001989 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001990
1991 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001992 bne $t0, $zero, 1f # check for pending exceptions
1993
Douglas Leung735b8552014-10-31 12:21:40 -07001994 move $sp, $s8 # tear down the alloca
1995
1996 # tear dpown the callee-save frame
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001997 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001998
Duane Sande34652f2014-11-04 11:09:36 -08001999 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002000 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002001 nop
Douglas Leung735b8552014-10-31 12:21:40 -07002002
20031:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002004 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
2005 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07002006 DELIVER_PENDING_EXCEPTION
2007END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08002008
Ian Rogers468532e2013-08-05 10:56:33 -07002009 .extern artQuickToInterpreterBridge
2010ENTRY art_quick_to_interpreter_bridge
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002011 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002012 move $a1, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002013 la $t9, artQuickToInterpreterBridge
2014 jalr $t9 # (Method* method, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07002015 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers7db619b2013-01-16 18:35:48 -08002016 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002017 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers7db619b2013-01-16 18:35:48 -08002018 bnez $t0, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002019 # don't care if $v0 and/or $v1 are modified, when exception branch taken
2020 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002021 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002022 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080020231:
2024 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07002025END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08002026
buzbee5bc5a7b2012-03-07 15:52:59 -08002027 /*
jeffhao725a9572012-11-13 18:20:12 -08002028 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08002029 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002030 .extern artInstrumentationMethodEntryFromCode
2031 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07002032ENTRY art_quick_instrumentation_entry
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002033 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002034 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002035 move $a3, $ra # pass $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002036 la $t9, artInstrumentationMethodEntryFromCode
2037 jalr $t9 # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08002038 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07002039 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07002040 lw $a0, 28($sp) # restore arg0 from free arg slot
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002041 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhao8161c032012-10-31 15:50:00 -07002042 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08002043 nop
Ian Rogers468532e2013-08-05 10:56:33 -07002044END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08002045 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07002046 .global art_quick_instrumentation_exit
2047art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002048 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08002049 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002050 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07002051 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07002052
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002053 SETUP_SAVE_REFS_ONLY_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002054 addiu $sp, $sp, -16 # allocate temp storage on the stack
2055 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002056 sw $v0, ARG_SLOT_SIZE+12($sp)
2057 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
2058 sw $v1, ARG_SLOT_SIZE+8($sp)
2059 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
2060 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08002061 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08002062 move $a2, $v0 # pass gpr result
2063 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002064 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002065 la $t9, artInstrumentationMethodExitFromCode
2066 jalr $t9 # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08002067 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002068 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08002069 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002070 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
2071 lw $v1, ARG_SLOT_SIZE+8($sp)
2072 l.d $f0, ARG_SLOT_SIZE($sp)
2073 jalr $zero, $t9 # return
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002074 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16 # restore stack
2075 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16)
Ian Rogers468532e2013-08-05 10:56:33 -07002076END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08002077
jeffhao12051ea2013-01-10 11:24:31 -08002078 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08002079 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
2080 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08002081 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002082 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002083ENTRY art_quick_deoptimize
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002084 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002085 la $t9, artDeoptimize
2086 jalr $t9 # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08002087 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002088 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002089END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08002090
buzbee5bc5a7b2012-03-07 15:52:59 -08002091 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00002092 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
2093 * will long jump to the upcall with a special exception of -1.
2094 */
2095 .extern artDeoptimizeFromCompiledCode
2096ENTRY art_quick_deoptimize_from_compiled_code
Vladimir Marko239d6ea2016-09-05 10:44:04 +01002097 SETUP_SAVE_EVERYTHING_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002098 la $t9, artDeoptimizeFromCompiledCode
2099 jalr $t9 # artDeoptimizeFromCompiledCode(Thread*)
Sebastien Hertz07474662015-08-25 15:12:33 +00002100 # Returns caller method's frame size.
2101 move $a0, rSELF # pass Thread::current
2102END art_quick_deoptimize_from_compiled_code
2103
2104 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08002105 * Long integer shift. This is different from the generic 32/64-bit
2106 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2107 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2108 * 6 bits.
2109 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002110 * $a0: low word
2111 * $a1: high word
2112 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002113 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002114ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002115 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07002116 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
2117 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
2118 srl $a0, 1
2119 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
2120 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002121 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002122 beqz $a2, 1f
2123 or $v1, $a0 # rhi<- rhi | alo
2124
2125 move $v1, $v0 # rhi<- rlo (if shift&0x20)
2126 move $v0, $zero # rlo<- 0 (if shift&0x20)
2127
Andreas Gampe8d365912015-01-13 11:32:32 -080021281: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002129 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002130END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002131
buzbee5bc5a7b2012-03-07 15:52:59 -08002132 /*
2133 * Long integer shift. This is different from the generic 32/64-bit
2134 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2135 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2136 * 6 bits.
2137 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002138 * $a0: low word
2139 * $a1: high word
2140 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002141 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002142ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07002143 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
2144 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
2145 sra $a3, $a1, 31 # $a3<- sign(ah)
2146 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2147 sll $a1, 1
2148 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002149 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08002150 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002151 or $v0, $a1 # rlo<- rlo | ahi
2152
2153 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2154 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
2155
Andreas Gampe8d365912015-01-13 11:32:32 -080021561: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002157 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002158END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002159
buzbee5bc5a7b2012-03-07 15:52:59 -08002160 /*
2161 * Long integer shift. This is different from the generic 32/64-bit
2162 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2163 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2164 * 6 bits.
2165 * On entry:
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002166 * $a0: low word
2167 * $a1: high word
2168 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002169 */
2170 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002171ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07002172 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002173 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002174 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2175 sll $a1, 1
2176 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002177 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002178 beqz $a2, 1f
2179 or $v0, $a1 # rlo<- rlo | ahi
2180
2181 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2182 move $v1, $zero # rhi<- 0 (if shift&0x20)
2183
Andreas Gampe8d365912015-01-13 11:32:32 -080021841: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002185 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002186END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07002187
Chris Larsencf283da2016-01-19 16:45:35 -08002188/* java.lang.String.indexOf(int ch, int fromIndex=0) */
2189ENTRY_NO_GP art_quick_indexof
2190/* $a0 holds address of "this" */
2191/* $a1 holds "ch" */
2192/* $a2 holds "fromIndex" */
2193 lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002194 slt $t1, $a2, $zero # if fromIndex < 0
Chris Larsencf283da2016-01-19 16:45:35 -08002195#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002196 seleqz $a2, $a2, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002197#else
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002198 movn $a2, $zero, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002199#endif
2200 subu $t0, $t0, $a2 # this.length() - fromIndex
2201 blez $t0, 6f # if this.length()-fromIndex <= 0
2202 li $v0, -1 # return -1;
2203
2204 sll $v0, $a2, 1 # $a0 += $a2 * 2
2205 addu $a0, $a0, $v0 # " " " " "
2206 move $v0, $a2 # Set i to fromIndex.
2207
22081:
2209 lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch
2210 beq $t3, $a1, 6f # return i;
2211 addu $a0, $a0, 2 # i++
2212 subu $t0, $t0, 1 # this.length() - i
2213 bnez $t0, 1b # while this.length() - i > 0
2214 addu $v0, $v0, 1 # i++
2215
2216 li $v0, -1 # if this.length() - i <= 0
2217 # return -1;
2218
22196:
2220 j $ra
2221 nop
2222END art_quick_indexof
2223
Chris Larsencf283da2016-01-19 16:45:35 -08002224/* java.lang.String.compareTo(String anotherString) */
2225ENTRY_NO_GP art_quick_string_compareto
2226/* $a0 holds address of "this" */
2227/* $a1 holds address of "anotherString" */
2228 beq $a0, $a1, 9f # this and anotherString are the same object
2229 move $v0, $zero
2230
2231 lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
2232 lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length()
2233 MINu $t2, $a2, $a3
2234# $t2 now holds min(this.length(),anotherString.length())
2235
2236 beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0
2237 subu $v0, $a2, $a3 # if $t2==0 return
2238 # (this.length() - anotherString.length())
22391:
2240 lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i)
2241 lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1)
2242 bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i)
2243 subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i))
2244 addiu $a0, $a0, 2 # point at this.charAt(i++)
2245 subu $t2, $t2, 1 # new value of
2246 # min(this.length(),anotherString.length())-i
2247 bnez $t2, 1b
2248 addiu $a1, $a1, 2 # point at anotherString.charAt(i++)
2249 subu $v0, $a2, $a3
2250
22519:
2252 j $ra
2253 nop
2254END art_quick_string_compareto