blob: 3acc0a9d5b3176446e79a16a36e99a0927c02a17 [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).
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800170 * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19
171 * (26 total + 1 word padding + method*)
buzbee5bc5a7b2012-03-07 15:52:59 -0800172 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100173.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800174 addiu $sp, $sp, -112
175 .cfi_adjust_cfa_offset 112
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700176
177 // Ugly compile-time check, but we only have the preprocessor.
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800178#if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 112)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100179#error "FRAME_SIZE_SAVE_REFS_AND_ARGS(MIPS) size not as expected."
Andreas Gampe5c1e4352014-04-21 19:28:24 -0700180#endif
181
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800182 sw $ra, 108($sp)
183 .cfi_rel_offset 31, 108
184 sw $s8, 104($sp)
185 .cfi_rel_offset 30, 104
186 sw $gp, 100($sp)
187 .cfi_rel_offset 28, 100
188 sw $s7, 96($sp)
189 .cfi_rel_offset 23, 96
190 sw $s6, 92($sp)
191 .cfi_rel_offset 22, 92
192 sw $s5, 88($sp)
193 .cfi_rel_offset 21, 88
194 sw $s4, 84($sp)
195 .cfi_rel_offset 20, 84
196 sw $s3, 80($sp)
197 .cfi_rel_offset 19, 80
198 sw $s2, 76($sp)
199 .cfi_rel_offset 18, 76
200 sw $t1, 72($sp)
201 .cfi_rel_offset 9, 72
202 sw $t0, 68($sp)
203 .cfi_rel_offset 8, 68
204 sw $a3, 64($sp)
205 .cfi_rel_offset 7, 64
206 sw $a2, 60($sp)
207 .cfi_rel_offset 6, 60
208 sw $a1, 56($sp)
209 .cfi_rel_offset 5, 56
210 SDu $f18, $f19, 48, $sp, $t8
211 SDu $f16, $f17, 40, $sp, $t8
212 SDu $f14, $f15, 32, $sp, $t8
213 SDu $f12, $f13, 24, $sp, $t8
214 SDu $f10, $f11, 16, $sp, $t8
215 SDu $f8, $f9, 8, $sp, $t8
jeffhaofa147e22012-10-12 17:03:32 -0700216 # bottom will hold Method*
Douglas Leung735b8552014-10-31 12:21:40 -0700217.endm
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700218
Douglas Leung735b8552014-10-31 12:21:40 -0700219 /*
220 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100221 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC.
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800222 * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19
223 * (26 total + 1 word padding + method*)
Douglas Leung735b8552014-10-31 12:21:40 -0700224 * Clobbers $t0 and $sp
225 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100226 * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack
Douglas Leung735b8552014-10-31 12:21:40 -0700227 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100228.macro SETUP_SAVE_REFS_AND_ARGS_FRAME
229 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Douglas Leung4af77b72014-10-22 16:32:28 -0700230 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
231 lw $t0, 0($t0)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100232 lw $t0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET($t0)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700233 sw $t0, 0($sp) # Place Method* at bottom of stack.
234 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700235 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
236 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
237.endm
238
239 /*
240 * Macro that sets up the callee save frame to conform with
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100241 * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs). Restoration assumes non-moving GC.
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800242 * callee-save: $a1-$a3, $t0-$t1, $s2-$s8, $gp, $ra, $f8-$f19
243 * (26 total + 1 word padding + method*)
Douglas Leung735b8552014-10-31 12:21:40 -0700244 * Clobbers $sp
245 * Use $a0 as the Method* and loads it into bottom of stack.
246 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100247 * Reserves FRAME_SIZE_SAVE_REFS_AND_ARGS + ARG_SLOT_SIZE bytes on the stack
Douglas Leung735b8552014-10-31 12:21:40 -0700248 */
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100249.macro SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
250 SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
Douglas Leung735b8552014-10-31 12:21:40 -0700251 sw $a0, 0($sp) # Place Method* at bottom of stack.
252 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
253 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
254 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
buzbee5bc5a7b2012-03-07 15:52:59 -0800255.endm
256
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100257.macro RESTORE_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -0700258 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
259 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800260 lw $ra, 108($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800261 .cfi_restore 31
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800262 lw $s8, 104($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800263 .cfi_restore 30
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800264 lw $gp, 100($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800265 .cfi_restore 28
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800266 lw $s7, 96($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800267 .cfi_restore 23
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800268 lw $s6, 92($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800269 .cfi_restore 22
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800270 lw $s5, 88($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800271 .cfi_restore 21
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800272 lw $s4, 84($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800273 .cfi_restore 20
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800274 lw $s3, 80($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800275 .cfi_restore 19
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800276 lw $s2, 76($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800277 .cfi_restore 18
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800278 lw $t1, 72($sp)
279 .cfi_restore 9
280 lw $t0, 68($sp)
281 .cfi_restore 8
282 lw $a3, 64($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800283 .cfi_restore 7
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800284 lw $a2, 60($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800285 .cfi_restore 6
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800286 lw $a1, 56($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -0800287 .cfi_restore 5
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800288 LDu $f18, $f19, 48, $sp, $t8
289 LDu $f16, $f17, 40, $sp, $t8
290 LDu $f14, $f15, 32, $sp, $t8
291 LDu $f12, $f13, 24, $sp, $t8
292 LDu $f10, $f11, 16, $sp, $t8
293 LDu $f8, $f9, 8, $sp, $t8
294 addiu $sp, $sp, 112 # pop frame
295 .cfi_adjust_cfa_offset -112
buzbee5bc5a7b2012-03-07 15:52:59 -0800296.endm
297
298 /*
Vladimir Marko952dbb12016-07-28 12:01:51 +0100299 * Macro that sets up the callee save frame to conform with
300 * Runtime::CreateCalleeSaveMethod(kSaveEverything).
Vladimir Marko3b7537b2016-09-13 11:56:01 +0000301 * when the $sp has already been decremented by FRAME_SIZE_SAVE_EVERYTHING.
Vladimir Marko952dbb12016-07-28 12:01:51 +0100302 * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31;
303 * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method*
304 * Clobbers $t0 and $t1.
305 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100306 * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack.
Vladimir Marko952dbb12016-07-28 12:01:51 +0100307 * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP.
308 */
Vladimir Marko3b7537b2016-09-13 11:56:01 +0000309.macro SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP
Vladimir Marko952dbb12016-07-28 12:01:51 +0100310 // Ugly compile-time check, but we only have the preprocessor.
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100311#if (FRAME_SIZE_SAVE_EVERYTHING != 256)
312#error "FRAME_SIZE_SAVE_EVERYTHING(MIPS) size not as expected."
Vladimir Marko952dbb12016-07-28 12:01:51 +0100313#endif
314
315 sw $ra, 252($sp)
316 .cfi_rel_offset 31, 252
317 sw $fp, 248($sp)
318 .cfi_rel_offset 30, 248
319 sw $gp, 244($sp)
320 .cfi_rel_offset 28, 244
321 sw $t9, 240($sp)
322 .cfi_rel_offset 25, 240
323 sw $t8, 236($sp)
324 .cfi_rel_offset 24, 236
325 sw $s7, 232($sp)
326 .cfi_rel_offset 23, 232
327 sw $s6, 228($sp)
328 .cfi_rel_offset 22, 228
329 sw $s5, 224($sp)
330 .cfi_rel_offset 21, 224
331 sw $s4, 220($sp)
332 .cfi_rel_offset 20, 220
333 sw $s3, 216($sp)
334 .cfi_rel_offset 19, 216
335 sw $s2, 212($sp)
336 .cfi_rel_offset 18, 212
337 sw $s1, 208($sp)
338 .cfi_rel_offset 17, 208
339 sw $s0, 204($sp)
340 .cfi_rel_offset 16, 204
341 sw $t7, 200($sp)
342 .cfi_rel_offset 15, 200
343 sw $t6, 196($sp)
344 .cfi_rel_offset 14, 196
345 sw $t5, 192($sp)
346 .cfi_rel_offset 13, 192
347 sw $t4, 188($sp)
348 .cfi_rel_offset 12, 188
349 sw $t3, 184($sp)
350 .cfi_rel_offset 11, 184
351 sw $t2, 180($sp)
352 .cfi_rel_offset 10, 180
353 sw $t1, 176($sp)
354 .cfi_rel_offset 9, 176
355 sw $t0, 172($sp)
356 .cfi_rel_offset 8, 172
357 sw $a3, 168($sp)
358 .cfi_rel_offset 7, 168
359 sw $a2, 164($sp)
360 .cfi_rel_offset 6, 164
361 sw $a1, 160($sp)
362 .cfi_rel_offset 5, 160
363 sw $a0, 156($sp)
364 .cfi_rel_offset 4, 156
365 sw $v1, 152($sp)
366 .cfi_rel_offset 3, 152
367 sw $v0, 148($sp)
368 .cfi_rel_offset 2, 148
369
370 // Set up $gp, clobbering $ra and using the branch delay slot for a useful instruction.
371 bal 1f
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200372 .set push
373 .set noat
Vladimir Marko952dbb12016-07-28 12:01:51 +0100374 sw $at, 144($sp)
375 .cfi_rel_offset 1, 144
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200376 .set pop
Vladimir Marko952dbb12016-07-28 12:01:51 +01003771:
378 .cpload $ra
379
380 SDu $f30, $f31, 136, $sp, $t1
381 SDu $f28, $f29, 128, $sp, $t1
382 SDu $f26, $f27, 120, $sp, $t1
383 SDu $f24, $f25, 112, $sp, $t1
384 SDu $f22, $f23, 104, $sp, $t1
385 SDu $f20, $f21, 96, $sp, $t1
386 SDu $f18, $f19, 88, $sp, $t1
387 SDu $f16, $f17, 80, $sp, $t1
388 SDu $f14, $f15, 72, $sp, $t1
389 SDu $f12, $f13, 64, $sp, $t1
390 SDu $f10, $f11, 56, $sp, $t1
391 SDu $f8, $f9, 48, $sp, $t1
392 SDu $f6, $f7, 40, $sp, $t1
393 SDu $f4, $f5, 32, $sp, $t1
394 SDu $f2, $f3, 24, $sp, $t1
395 SDu $f0, $f1, 16, $sp, $t1
396
397 # 3 words padding and 1 word for holding Method*
398
399 lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
400 lw $t0, 0($t0)
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100401 lw $t0, RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET($t0)
Vladimir Marko952dbb12016-07-28 12:01:51 +0100402 sw $t0, 0($sp) # Place Method* at bottom of stack.
403 sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF) # Place sp in Thread::Current()->top_quick_frame.
404 addiu $sp, $sp, -ARG_SLOT_SIZE # reserve argument slots on the stack
405 .cfi_adjust_cfa_offset ARG_SLOT_SIZE
406.endm
407
Vladimir Marko3b7537b2016-09-13 11:56:01 +0000408 /*
409 * Macro that sets up the callee save frame to conform with
410 * Runtime::CreateCalleeSaveMethod(kSaveEverything).
411 * Callee-save: $at, $v0-$v1, $a0-$a3, $t0-$t7, $s0-$s7, $t8-$t9, $gp, $fp $ra, $f0-$f31;
412 * 28(GPR)+ 32(FPR) + 3 words for padding and 1 word for Method*
413 * Clobbers $t0 and $t1.
414 * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
415 * Reserves FRAME_SIZE_SAVE_EVERYTHING + ARG_SLOT_SIZE bytes on the stack.
416 * This macro sets up $gp; entrypoints using it should start with ENTRY_NO_GP.
417 */
418.macro SETUP_SAVE_EVERYTHING_FRAME
419 addiu $sp, $sp, -(FRAME_SIZE_SAVE_EVERYTHING)
420 .cfi_adjust_cfa_offset (FRAME_SIZE_SAVE_EVERYTHING)
421 SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP
422.endm
423
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100424.macro RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +0100425 addiu $sp, $sp, ARG_SLOT_SIZE # remove argument slots on the stack
426 .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
427
428 LDu $f30, $f31, 136, $sp, $t1
429 LDu $f28, $f29, 128, $sp, $t1
430 LDu $f26, $f27, 120, $sp, $t1
431 LDu $f24, $f25, 112, $sp, $t1
432 LDu $f22, $f23, 104, $sp, $t1
433 LDu $f20, $f21, 96, $sp, $t1
434 LDu $f18, $f19, 88, $sp, $t1
435 LDu $f16, $f17, 80, $sp, $t1
436 LDu $f14, $f15, 72, $sp, $t1
437 LDu $f12, $f13, 64, $sp, $t1
438 LDu $f10, $f11, 56, $sp, $t1
439 LDu $f8, $f9, 48, $sp, $t1
440 LDu $f6, $f7, 40, $sp, $t1
441 LDu $f4, $f5, 32, $sp, $t1
442 LDu $f2, $f3, 24, $sp, $t1
443 LDu $f0, $f1, 16, $sp, $t1
444
445 lw $ra, 252($sp)
446 .cfi_restore 31
447 lw $fp, 248($sp)
448 .cfi_restore 30
449 lw $gp, 244($sp)
450 .cfi_restore 28
451 lw $t9, 240($sp)
452 .cfi_restore 25
453 lw $t8, 236($sp)
454 .cfi_restore 24
455 lw $s7, 232($sp)
456 .cfi_restore 23
457 lw $s6, 228($sp)
458 .cfi_restore 22
459 lw $s5, 224($sp)
460 .cfi_restore 21
461 lw $s4, 220($sp)
462 .cfi_restore 20
463 lw $s3, 216($sp)
464 .cfi_restore 19
465 lw $s2, 212($sp)
466 .cfi_restore 18
467 lw $s1, 208($sp)
468 .cfi_restore 17
469 lw $s0, 204($sp)
470 .cfi_restore 16
471 lw $t7, 200($sp)
472 .cfi_restore 15
473 lw $t6, 196($sp)
474 .cfi_restore 14
475 lw $t5, 192($sp)
476 .cfi_restore 13
477 lw $t4, 188($sp)
478 .cfi_restore 12
479 lw $t3, 184($sp)
480 .cfi_restore 11
481 lw $t2, 180($sp)
482 .cfi_restore 10
483 lw $t1, 176($sp)
484 .cfi_restore 9
485 lw $t0, 172($sp)
486 .cfi_restore 8
487 lw $a3, 168($sp)
488 .cfi_restore 7
489 lw $a2, 164($sp)
490 .cfi_restore 6
491 lw $a1, 160($sp)
492 .cfi_restore 5
493 lw $a0, 156($sp)
494 .cfi_restore 4
495 lw $v1, 152($sp)
496 .cfi_restore 3
497 lw $v0, 148($sp)
498 .cfi_restore 2
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200499 .set push
500 .set noat
Vladimir Marko952dbb12016-07-28 12:01:51 +0100501 lw $at, 144($sp)
502 .cfi_restore 1
Goran Jakovljevic2e42cf12016-08-09 15:15:39 +0200503 .set pop
Vladimir Marko952dbb12016-07-28 12:01:51 +0100504
505 addiu $sp, $sp, 256 # pop frame
506 .cfi_adjust_cfa_offset -256
507.endm
508
509 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800510 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
511 * exception is Thread::Current()->exception_
512 */
513.macro DELIVER_PENDING_EXCEPTION
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100514 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME # save callee saves for throw
jeffhao8161c032012-10-31 15:50:00 -0700515 la $t9, artDeliverPendingExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800516 jalr $zero, $t9 # artDeliverPendingExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700517 move $a0, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -0800518.endm
519
520.macro RETURN_IF_NO_EXCEPTION
jeffhao7fbee072012-08-24 17:56:54 -0700521 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100522 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700523 bnez $t0, 1f # success if no exception is pending
buzbee5bc5a7b2012-03-07 15:52:59 -0800524 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800525 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -0800526 nop
5271:
528 DELIVER_PENDING_EXCEPTION
529.endm
530
531.macro RETURN_IF_ZERO
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100532 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700533 bnez $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800534 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800535 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800536 nop
5371:
538 DELIVER_PENDING_EXCEPTION
539.endm
540
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800541.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100542 RESTORE_SAVE_REFS_ONLY_FRAME
jeffhao7fbee072012-08-24 17:56:54 -0700543 beqz $v0, 1f # success?
buzbee5bc5a7b2012-03-07 15:52:59 -0800544 nop
Andreas Gampe8d365912015-01-13 11:32:32 -0800545 jalr $zero, $ra # return on success
buzbee5bc5a7b2012-03-07 15:52:59 -0800546 nop
5471:
548 DELIVER_PENDING_EXCEPTION
549.endm
550
buzbee5bc5a7b2012-03-07 15:52:59 -0800551 /*
Goran Jakovljevic3bc13812016-03-22 17:16:05 +0100552 * On stack replacement stub.
553 * On entry:
554 * a0 = stack to copy
555 * a1 = size of stack
556 * a2 = pc to call
557 * a3 = JValue* result
558 * [sp + 16] = shorty
559 * [sp + 20] = thread
560 */
561ENTRY art_quick_osr_stub
562 // Save callee general purpose registers, RA and GP.
563 addiu $sp, $sp, -48
564 .cfi_adjust_cfa_offset 48
565 sw $ra, 44($sp)
566 .cfi_rel_offset 31, 44
567 sw $s8, 40($sp)
568 .cfi_rel_offset 30, 40
569 sw $gp, 36($sp)
570 .cfi_rel_offset 28, 36
571 sw $s7, 32($sp)
572 .cfi_rel_offset 23, 32
573 sw $s6, 28($sp)
574 .cfi_rel_offset 22, 28
575 sw $s5, 24($sp)
576 .cfi_rel_offset 21, 24
577 sw $s4, 20($sp)
578 .cfi_rel_offset 20, 20
579 sw $s3, 16($sp)
580 .cfi_rel_offset 19, 16
581 sw $s2, 12($sp)
582 .cfi_rel_offset 18, 12
583 sw $s1, 8($sp)
584 .cfi_rel_offset 17, 8
585 sw $s0, 4($sp)
586 .cfi_rel_offset 16, 4
587
588 move $s8, $sp # Save the stack pointer
589 move $s7, $a1 # Save size of stack
590 move $s6, $a2 # Save the pc to call
591 lw rSELF, 48+20($sp) # Save managed thread pointer into rSELF
592 addiu $t0, $sp, -12 # Reserve space for stack pointer,
593 # JValue* result, and ArtMethod* slot.
594 srl $t0, $t0, 4 # Align stack pointer to 16 bytes
595 sll $sp, $t0, 4 # Update stack pointer
596 sw $s8, 4($sp) # Save old stack pointer
597 sw $a3, 8($sp) # Save JValue* result
598 sw $zero, 0($sp) # Store null for ArtMethod* at bottom of frame
599 subu $sp, $a1 # Reserve space for callee stack
600 move $a2, $a1
601 move $a1, $a0
602 move $a0, $sp
603 la $t9, memcpy
604 jalr $t9 # memcpy (dest a0, src a1, bytes a2)
605 addiu $sp, $sp, -16 # make space for argument slots for memcpy
606 bal .Losr_entry # Call the method
607 addiu $sp, $sp, 16 # restore stack after memcpy
608 lw $a2, 8($sp) # Restore JValue* result
609 lw $sp, 4($sp) # Restore saved stack pointer
610 lw $a0, 48+16($sp) # load shorty
611 lbu $a0, 0($a0) # load return type
612 li $a1, 'D' # put char 'D' into a1
613 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'D'
614 li $a1, 'F' # put char 'F' into a1
615 beq $a0, $a1, .Losr_fp_result # Test if result type char == 'F'
616 nop
617 sw $v0, 0($a2)
618 b .Losr_exit
619 sw $v1, 4($a2) # store v0/v1 into result
620.Losr_fp_result:
621 SDu $f0, $f1, 0, $a2, $t0 # store f0/f1 into result
622.Losr_exit:
623 lw $ra, 44($sp)
624 .cfi_restore 31
625 lw $s8, 40($sp)
626 .cfi_restore 30
627 lw $gp, 36($sp)
628 .cfi_restore 28
629 lw $s7, 32($sp)
630 .cfi_restore 23
631 lw $s6, 28($sp)
632 .cfi_restore 22
633 lw $s5, 24($sp)
634 .cfi_restore 21
635 lw $s4, 20($sp)
636 .cfi_restore 20
637 lw $s3, 16($sp)
638 .cfi_restore 19
639 lw $s2, 12($sp)
640 .cfi_restore 18
641 lw $s1, 8($sp)
642 .cfi_restore 17
643 lw $s0, 4($sp)
644 .cfi_restore 16
645 jalr $zero, $ra
646 addiu $sp, $sp, 48
647 .cfi_adjust_cfa_offset -48
648.Losr_entry:
649 addiu $s7, $s7, -4
650 addu $t0, $s7, $sp
651 move $t9, $s6
652 jalr $zero, $t9
653 sw $ra, 0($t0) # Store RA per the compiler ABI
654END art_quick_osr_stub
655
656 /*
jeffhao7fbee072012-08-24 17:56:54 -0700657 * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
buzbee5bc5a7b2012-03-07 15:52:59 -0800658 * FIXME: just guessing about the shape of the jmpbuf. Where will pc be?
659 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800660ENTRY art_quick_do_long_jump
Duane Sande34652f2014-11-04 11:09:36 -0800661 LDu $f0, $f1, 0*8, $a1, $t1
662 LDu $f2, $f3, 1*8, $a1, $t1
663 LDu $f4, $f5, 2*8, $a1, $t1
664 LDu $f6, $f7, 3*8, $a1, $t1
665 LDu $f8, $f9, 4*8, $a1, $t1
666 LDu $f10, $f11, 5*8, $a1, $t1
667 LDu $f12, $f13, 6*8, $a1, $t1
668 LDu $f14, $f15, 7*8, $a1, $t1
669 LDu $f16, $f17, 8*8, $a1, $t1
670 LDu $f18, $f19, 9*8, $a1, $t1
671 LDu $f20, $f21, 10*8, $a1, $t1
672 LDu $f22, $f23, 11*8, $a1, $t1
673 LDu $f24, $f25, 12*8, $a1, $t1
674 LDu $f26, $f27, 13*8, $a1, $t1
675 LDu $f28, $f29, 14*8, $a1, $t1
676 LDu $f30, $f31, 15*8, $a1, $t1
677
Chris Dearman748dd952014-05-23 10:47:01 -0700678 .set push
679 .set nomacro
680 .set noat
jeffhao7fbee072012-08-24 17:56:54 -0700681 lw $at, 4($a0)
Chris Dearman748dd952014-05-23 10:47:01 -0700682 .set pop
jeffhao7fbee072012-08-24 17:56:54 -0700683 lw $v0, 8($a0)
684 lw $v1, 12($a0)
685 lw $a1, 20($a0)
686 lw $a2, 24($a0)
687 lw $a3, 28($a0)
688 lw $t0, 32($a0)
689 lw $t1, 36($a0)
690 lw $t2, 40($a0)
691 lw $t3, 44($a0)
692 lw $t4, 48($a0)
693 lw $t5, 52($a0)
694 lw $t6, 56($a0)
695 lw $t7, 60($a0)
696 lw $s0, 64($a0)
697 lw $s1, 68($a0)
698 lw $s2, 72($a0)
699 lw $s3, 76($a0)
700 lw $s4, 80($a0)
701 lw $s5, 84($a0)
702 lw $s6, 88($a0)
703 lw $s7, 92($a0)
704 lw $t8, 96($a0)
705 lw $t9, 100($a0)
jeffhao7fbee072012-08-24 17:56:54 -0700706 lw $gp, 112($a0)
707 lw $sp, 116($a0)
708 lw $fp, 120($a0)
709 lw $ra, 124($a0)
710 lw $a0, 16($a0)
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100711 move $v0, $zero # clear result registers v0 and v1 (in branch delay slot)
Goran Jakovljevic75969962015-10-27 12:29:07 +0100712 jalr $zero, $t9 # do long jump
jeffhao7fbee072012-08-24 17:56:54 -0700713 move $v1, $zero
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800714END art_quick_do_long_jump
buzbee5bc5a7b2012-03-07 15:52:59 -0800715
buzbee5bc5a7b2012-03-07 15:52:59 -0800716 /*
717 * Called by managed code, saves most registers (forms basis of long jump context) and passes
718 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
Lazar Trsic84bc06e2015-06-10 16:05:46 +0200719 * the bottom of the thread. On entry a0 holds Throwable*
buzbee5bc5a7b2012-03-07 15:52:59 -0800720 */
Ian Rogers468532e2013-08-05 10:56:33 -0700721ENTRY art_quick_deliver_exception
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100722 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700723 la $t9, artDeliverExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800724 jalr $zero, $t9 # artDeliverExceptionFromCode(Throwable*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700725 move $a1, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700726END art_quick_deliver_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800727
buzbee5bc5a7b2012-03-07 15:52:59 -0800728 /*
729 * Called by managed code to create and deliver a NullPointerException
730 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800731 .extern artThrowNullPointerExceptionFromCode
Vladimir Marko804b03f2016-09-14 16:26:36 +0100732ENTRY_NO_GP art_quick_throw_null_pointer_exception
733 // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK,
734 // even after clobbering any registers we don't need to preserve, such as $gp or $t0.
735 SETUP_SAVE_EVERYTHING_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700736 la $t9, artThrowNullPointerExceptionFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800737 jalr $zero, $t9 # artThrowNullPointerExceptionFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700738 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700739END art_quick_throw_null_pointer_exception
buzbee5bc5a7b2012-03-07 15:52:59 -0800740
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100741
742 /*
743 * Call installed by a signal handler to create and deliver a NullPointerException.
744 */
745 .extern artThrowNullPointerExceptionFromSignal
Vladimir Marko3b7537b2016-09-13 11:56:01 +0000746ENTRY_NO_GP_CUSTOM_CFA art_quick_throw_null_pointer_exception_from_signal, FRAME_SIZE_SAVE_EVERYTHING
747 SETUP_SAVE_EVERYTHING_FRAME_DECREMENTED_SP
748 # Retrieve the fault address from the padding where the signal handler stores it.
749 lw $a0, (ARG_SLOT_SIZE + __SIZEOF_POINTER__)($sp)
Nicolas Geoffraye8e11272016-06-28 18:08:46 +0100750 la $t9, artThrowNullPointerExceptionFromSignal
751 jalr $zero, $t9 # artThrowNullPointerExceptionFromSignal(uintptr_t, Thread*)
752 move $a1, rSELF # pass Thread::Current
753END art_quick_throw_null_pointer_exception_from_signal
754
buzbee5bc5a7b2012-03-07 15:52:59 -0800755 /*
756 * Called by managed code to create and deliver an ArithmeticException
757 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800758 .extern artThrowDivZeroFromCode
Vladimir Marko804b03f2016-09-14 16:26:36 +0100759ENTRY_NO_GP art_quick_throw_div_zero
760 SETUP_SAVE_EVERYTHING_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700761 la $t9, artThrowDivZeroFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800762 jalr $zero, $t9 # artThrowDivZeroFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700763 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700764END art_quick_throw_div_zero
buzbee5bc5a7b2012-03-07 15:52:59 -0800765
buzbee5bc5a7b2012-03-07 15:52:59 -0800766 /*
767 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
768 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800769 .extern artThrowArrayBoundsFromCode
Vladimir Marko804b03f2016-09-14 16:26:36 +0100770ENTRY_NO_GP art_quick_throw_array_bounds
771 // Note that setting up $gp does not rely on $t9 here, so branching here directly is OK,
772 // even after clobbering any registers we don't need to preserve, such as $gp or $t0.
773 SETUP_SAVE_EVERYTHING_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700774 la $t9, artThrowArrayBoundsFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800775 jalr $zero, $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700776 move $a2, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700777END art_quick_throw_array_bounds
buzbee5bc5a7b2012-03-07 15:52:59 -0800778
Ian Rogers57b86d42012-03-27 16:05:41 -0700779 /*
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100780 * Called by managed code to create and deliver a StringIndexOutOfBoundsException
781 * as if thrown from a call to String.charAt().
782 */
783 .extern artThrowStringBoundsFromCode
Vladimir Marko804b03f2016-09-14 16:26:36 +0100784ENTRY_NO_GP art_quick_throw_string_bounds
785 SETUP_SAVE_EVERYTHING_FRAME
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100786 la $t9, artThrowStringBoundsFromCode
787 jalr $zero, $t9 # artThrowStringBoundsFromCode(index, limit, Thread*)
788 move $a2, rSELF # pass Thread::Current
789END art_quick_throw_string_bounds
790
791 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700792 * Called by managed code to create and deliver a StackOverflowError.
793 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800794 .extern artThrowStackOverflowFromCode
Ian Rogers468532e2013-08-05 10:56:33 -0700795ENTRY art_quick_throw_stack_overflow
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100796 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
jeffhao8161c032012-10-31 15:50:00 -0700797 la $t9, artThrowStackOverflowFromCode
Andreas Gampe8d365912015-01-13 11:32:32 -0800798 jalr $zero, $t9 # artThrowStackOverflowFromCode(Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700799 move $a0, rSELF # pass Thread::Current
Ian Rogers468532e2013-08-05 10:56:33 -0700800END art_quick_throw_stack_overflow
buzbee5bc5a7b2012-03-07 15:52:59 -0800801
Ian Rogers57b86d42012-03-27 16:05:41 -0700802 /*
buzbee5bc5a7b2012-03-07 15:52:59 -0800803 * All generated callsites for interface invokes and invocation slow paths will load arguments
jeffhao7fbee072012-08-24 17:56:54 -0700804 * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100805 * the method_idx. This wrapper will save arg1-arg3, and call the appropriate C helper.
jeffhao7fbee072012-08-24 17:56:54 -0700806 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800807 *
jeffhao7fbee072012-08-24 17:56:54 -0700808 * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
809 * of the target Method* in $v0 and method->code_ in $v1.
buzbee5bc5a7b2012-03-07 15:52:59 -0800810 *
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700811 * If unsuccessful, the helper will return null/null. There will be a pending exception in the
buzbee5bc5a7b2012-03-07 15:52:59 -0800812 * thread and we branch to another stub to deliver it.
813 *
814 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
815 * pointing back to the original caller.
816 */
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700817.macro INVOKE_TRAMPOLINE_BODY cxx_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800818 .extern \cxx_name
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100819 SETUP_SAVE_REFS_AND_ARGS_FRAME # save callee saves in case allocation triggers GC
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100820 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100821 la $t9, \cxx_name
822 jalr $t9 # (method_idx, this, Thread*, $sp)
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100823 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
824 move $a0, $v0 # save target Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100825 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhaofa147e22012-10-12 17:03:32 -0700826 beqz $v0, 1f
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +0100827 move $t9, $v1 # save $v0->code_
Andreas Gampe8d365912015-01-13 11:32:32 -0800828 jalr $zero, $t9
buzbee5bc5a7b2012-03-07 15:52:59 -0800829 nop
8301:
831 DELIVER_PENDING_EXCEPTION
Andreas Gampe3031c8d2015-07-13 20:11:06 -0700832.endm
833.macro INVOKE_TRAMPOLINE c_name, cxx_name
834ENTRY \c_name
835 INVOKE_TRAMPOLINE_BODY \cxx_name
Jeff Haod4c3f7d2013-02-14 14:14:44 -0800836END \c_name
buzbee5bc5a7b2012-03-07 15:52:59 -0800837.endm
838
Logan Chien8dbb7082013-01-25 20:31:17 +0800839INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800840
Logan Chien8dbb7082013-01-25 20:31:17 +0800841INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
842INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
843INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
844INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
buzbee5bc5a7b2012-03-07 15:52:59 -0800845
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800846// Each of the following macros expands into four instructions or 16 bytes.
847// They are used to build indexable "tables" of code.
848
849.macro LOAD_WORD_TO_REG reg, next_arg, index_reg, label
Goran Jakovljevicff734982015-08-24 12:58:55 +0000850 lw $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
851 b \label
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800852 addiu $\index_reg, 16
853 .balign 16
Goran Jakovljevicff734982015-08-24 12:58:55 +0000854.endm
855
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800856.macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index_reg, next_index, label
Goran Jakovljevicff734982015-08-24 12:58:55 +0000857 lw $\reg1, -8($\next_arg) # next_arg points to argument after the current one (offset is 8)
858 lw $\reg2, -4($\next_arg)
859 b \label
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800860 li $\index_reg, \next_index
861 .balign 16
Goran Jakovljevicff734982015-08-24 12:58:55 +0000862.endm
863
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800864.macro LOAD_FLOAT_TO_REG reg, next_arg, index_reg, label
Goran Jakovljevicff734982015-08-24 12:58:55 +0000865 lwc1 $\reg, -4($\next_arg) # next_arg points to argument after the current one (offset is 4)
866 b \label
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800867 addiu $\index_reg, 16
868 .balign 16
Goran Jakovljevicff734982015-08-24 12:58:55 +0000869.endm
870
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800871#if defined(__mips_isa_rev) && __mips_isa_rev > 2
872// LDu expands into 3 instructions for 64-bit FPU, so index_reg cannot be updated here.
873.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label
874 .set reorder # force use of the branch delay slot
Goran Jakovljevicff734982015-08-24 12:58:55 +0000875 LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one
876 # (offset is 8)
877 b \label
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800878 .set noreorder
879 .balign 16
880.endm
881#else
882// LDu expands into 2 instructions for 32-bit FPU, so index_reg is updated here.
883.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index_reg, tmp, label
884 LDu $\reg1, $\reg2, -8, $\next_arg, $\tmp # next_arg points to argument after the current one
885 # (offset is 8)
886 b \label
887 addiu $\index_reg, 16
888 .balign 16
889.endm
890#endif
891
892.macro LOAD_END index_reg, next_index, label
893 b \label
894 li $\index_reg, \next_index
895 .balign 16
Goran Jakovljevicff734982015-08-24 12:58:55 +0000896.endm
897
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100898#define SPILL_SIZE 32
899
Jeff Hao79fe5392013-04-24 18:41:58 -0700900 /*
Ian Rogersef7d42f2014-01-06 12:55:46 -0800901 * Invocation stub for quick code.
Jeff Hao5d917302013-02-27 17:57:33 -0800902 * On entry:
903 * a0 = method pointer
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700904 * a1 = argument array or null for no argument methods
Jeff Hao5d917302013-02-27 17:57:33 -0800905 * a2 = size of argument array in bytes
906 * a3 = (managed) thread pointer
Jeff Hao6474d192013-03-26 14:08:09 -0700907 * [sp + 16] = JValue* result
Ian Rogers0177e532014-02-11 16:30:46 -0800908 * [sp + 20] = shorty
Jeff Hao5d917302013-02-27 17:57:33 -0800909 */
910ENTRY art_quick_invoke_stub
Jeff Hao5d917302013-02-27 17:57:33 -0800911 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100912 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
913 .cfi_adjust_cfa_offset SPILL_SIZE
914 sw $gp, 16($sp)
Jeff Hao5d917302013-02-27 17:57:33 -0800915 sw $ra, 12($sp)
916 .cfi_rel_offset 31, 12
917 sw $fp, 8($sp)
918 .cfi_rel_offset 30, 8
919 sw $s1, 4($sp)
920 .cfi_rel_offset 17, 4
921 sw $s0, 0($sp)
922 .cfi_rel_offset 16, 0
923 move $fp, $sp # save sp in fp
924 .cfi_def_cfa_register 30
925 move $s1, $a3 # move managed thread pointer into s1
926 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
Goran Jakovljevicff734982015-08-24 12:58:55 +0000927 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
Douglas Leung735b8552014-10-31 12:21:40 -0700928 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
Goran Jakovljevicff734982015-08-24 12:58:55 +0000929 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
930 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
931 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100932 la $t9, memcpy
933 jalr $t9 # (dest, src, bytes)
Jeff Hao5d917302013-02-27 17:57:33 -0800934 addiu $sp, $sp, -16 # make space for argument slots for memcpy
935 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100936 lw $gp, 16($fp) # restore $gp
937 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Goran Jakovljevicff734982015-08-24 12:58:55 +0000938 lw $a1, 4($sp) # a1 = this*
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800939 addiu $t8, $sp, 8 # t8 = pointer to the current argument (skip ArtMethod* and this*)
940 li $t6, 0 # t6 = gpr_index = 0 (corresponds to A2; A0 and A1 are skipped)
941 li $t7, 0 # t7 = fp_index = 0
942 lw $t9, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
Goran Jakovljevic590b1362016-03-21 14:24:43 +0100943 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800944 addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type)
945
946 // Load the base addresses of tabInt ... tabDouble.
947 // We will use the register indices (gpr_index, fp_index) to branch.
948 // Note that the indices are scaled by 16, so they can be added to the bases directly.
949#if defined(__mips_isa_rev) && __mips_isa_rev >= 6
950 lapc $t2, tabInt
951 lapc $t3, tabLong
952 lapc $t4, tabSingle
953 lapc $t5, tabDouble
954#else
955 bltzal $zero, tabBase # nal
956 addiu $t2, $ra, %lo(tabInt - tabBase)
957tabBase:
958 addiu $t3, $ra, %lo(tabLong - tabBase)
959 addiu $t4, $ra, %lo(tabSingle - tabBase)
960 addiu $t5, $ra, %lo(tabDouble - tabBase)
961#endif
962
Goran Jakovljevicff734982015-08-24 12:58:55 +0000963loop:
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800964 lbu $ra, 0($t9) # ra = shorty[i]
965 beqz $ra, loopEnd # finish getting args when shorty[i] == '\0'
966 addiu $t9, 1
Goran Jakovljevicff734982015-08-24 12:58:55 +0000967
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800968 addiu $ra, -'J'
969 beqz $ra, isLong # branch if result type char == 'J'
970 addiu $ra, 'J' - 'D'
971 beqz $ra, isDouble # branch if result type char == 'D'
972 addiu $ra, 'D' - 'F'
973 beqz $ra, isSingle # branch if result type char == 'F'
Goran Jakovljevicff734982015-08-24 12:58:55 +0000974
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800975 addu $ra, $t2, $t6
976 jalr $zero, $ra
977 addiu $t8, 4 # next_arg = curr_arg + 4
Goran Jakovljevicff734982015-08-24 12:58:55 +0000978
979isLong:
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800980 addu $ra, $t3, $t6
981 jalr $zero, $ra
982 addiu $t8, 8 # next_arg = curr_arg + 8
Goran Jakovljevicff734982015-08-24 12:58:55 +0000983
984isSingle:
Alexey Frunze1b8464d2016-11-12 17:22:05 -0800985 addu $ra, $t4, $t7
986 jalr $zero, $ra
987 addiu $t8, 4 # next_arg = curr_arg + 4
988
989isDouble:
990 addu $ra, $t5, $t7
991#if defined(__mips_isa_rev) && __mips_isa_rev > 2
992 addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG
993#endif
994 jalr $zero, $ra
995 addiu $t8, 8 # next_arg = curr_arg + 8
Goran Jakovljevicff734982015-08-24 12:58:55 +0000996
997loopEnd:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700998 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
Jeff Hao5d917302013-02-27 17:57:33 -0800999 jalr $t9 # call the method
Goran Jakovljevicff734982015-08-24 12:58:55 +00001000 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
Jeff Hao5d917302013-02-27 17:57:33 -08001001 move $sp, $fp # restore the stack
1002 lw $s0, 0($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -08001003 .cfi_restore 16
Jeff Hao5d917302013-02-27 17:57:33 -08001004 lw $s1, 4($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -08001005 .cfi_restore 17
Jeff Hao5d917302013-02-27 17:57:33 -08001006 lw $fp, 8($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -08001007 .cfi_restore 30
Jeff Hao5d917302013-02-27 17:57:33 -08001008 lw $ra, 12($sp)
Dave Allisonbbb32c22013-11-05 18:25:18 -08001009 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001010 addiu $sp, $sp, SPILL_SIZE
1011 .cfi_adjust_cfa_offset -SPILL_SIZE
Jeff Hao5d917302013-02-27 17:57:33 -08001012 lw $t0, 16($sp) # get result pointer
Ian Rogers0177e532014-02-11 16:30:46 -08001013 lw $t1, 20($sp) # get shorty
1014 lb $t1, 0($t1) # get result type char
Goran Jakovljevicff734982015-08-24 12:58:55 +00001015 li $t2, 'D' # put char 'D' into t2
1016 beq $t1, $t2, 5f # branch if result type char == 'D'
1017 li $t3, 'F' # put char 'F' into t3
1018 beq $t1, $t3, 5f # branch if result type char == 'F'
Jeff Hao5d917302013-02-27 17:57:33 -08001019 sw $v0, 0($t0) # store the result
Andreas Gampe8d365912015-01-13 11:32:32 -08001020 jalr $zero, $ra
Jeff Hao5d917302013-02-27 17:57:33 -08001021 sw $v1, 4($t0) # store the other half of the result
Goran Jakovljevicff734982015-08-24 12:58:55 +000010225:
Duane Sande34652f2014-11-04 11:09:36 -08001023 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
Andreas Gampe8d365912015-01-13 11:32:32 -08001024 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001025 nop
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001026
1027 // Note that gpr_index is kept within the range of tabInt and tabLong
1028 // and fp_index is kept within the range of tabSingle and tabDouble.
1029 .balign 16
1030tabInt:
1031 LOAD_WORD_TO_REG a2, t8, t6, loop # a2 = current argument, gpr_index += 16
1032 LOAD_WORD_TO_REG a3, t8, t6, loop # a3 = current argument, gpr_index += 16
1033 LOAD_WORD_TO_REG t0, t8, t6, loop # t0 = current argument, gpr_index += 16
1034 LOAD_WORD_TO_REG t1, t8, t6, loop # t1 = current argument, gpr_index += 16
1035 LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16
1036tabLong:
1037 LOAD_LONG_TO_REG a2, a3, t8, t6, 2*16, loop # a2_a3 = curr_arg, gpr_index = 2*16
1038 LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16
1039 LOAD_LONG_TO_REG t0, t1, t8, t6, 4*16, loop # t0_t1 = curr_arg, gpr_index = 4*16
1040 LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16
1041 LOAD_END t6, 4*16, loop # no more GPR args, gpr_index = 4*16
1042tabSingle:
1043 LOAD_FLOAT_TO_REG f8, t8, t7, loop # f8 = curr_arg, fp_index += 16
1044 LOAD_FLOAT_TO_REG f10, t8, t7, loop # f10 = curr_arg, fp_index += 16
1045 LOAD_FLOAT_TO_REG f12, t8, t7, loop # f12 = curr_arg, fp_index += 16
1046 LOAD_FLOAT_TO_REG f14, t8, t7, loop # f14 = curr_arg, fp_index += 16
1047 LOAD_FLOAT_TO_REG f16, t8, t7, loop # f16 = curr_arg, fp_index += 16
1048 LOAD_FLOAT_TO_REG f18, t8, t7, loop # f18 = curr_arg, fp_index += 16
1049 LOAD_END t7, 6*16, loop # no more FPR args, fp_index = 6*16
1050tabDouble:
1051 LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loop # f8_f9 = curr_arg; if FPU32, fp_index += 16
1052 LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loop # f10_f11 = curr_arg; if FPU32, fp_index += 16
1053 LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loop # f12_f13 = curr_arg; if FPU32, fp_index += 16
1054 LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loop # f14_f15 = curr_arg; if FPU32, fp_index += 16
1055 LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loop # f16_f17 = curr_arg; if FPU32, fp_index += 16
1056 LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loop # f18_f19 = curr_arg; if FPU32, fp_index += 16
1057 LOAD_END t7, 6*16, loop # no more FPR args, fp_index = 6*16
Jeff Hao5d917302013-02-27 17:57:33 -08001058END art_quick_invoke_stub
1059
1060 /*
Goran Jakovljevicff734982015-08-24 12:58:55 +00001061 * Invocation static stub for quick code.
1062 * On entry:
1063 * a0 = method pointer
1064 * a1 = argument array or null for no argument methods
1065 * a2 = size of argument array in bytes
1066 * a3 = (managed) thread pointer
1067 * [sp + 16] = JValue* result
1068 * [sp + 20] = shorty
1069 */
1070ENTRY art_quick_invoke_static_stub
1071 sw $a0, 0($sp) # save out a0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001072 addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
1073 .cfi_adjust_cfa_offset SPILL_SIZE
1074 sw $gp, 16($sp)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001075 sw $ra, 12($sp)
1076 .cfi_rel_offset 31, 12
1077 sw $fp, 8($sp)
1078 .cfi_rel_offset 30, 8
1079 sw $s1, 4($sp)
1080 .cfi_rel_offset 17, 4
1081 sw $s0, 0($sp)
1082 .cfi_rel_offset 16, 0
1083 move $fp, $sp # save sp in fp
1084 .cfi_def_cfa_register 30
1085 move $s1, $a3 # move managed thread pointer into s1
1086 addiu $s0, $zero, SUSPEND_CHECK_INTERVAL # reset s0 to suspend check interval
1087 addiu $t0, $a2, 4 # create space for ArtMethod* in frame.
1088 subu $t0, $sp, $t0 # reserve & align *stack* to 16 bytes:
1089 srl $t0, $t0, 4 # native calling convention only aligns to 8B,
1090 sll $sp, $t0, 4 # so we have to ensure ART 16B alignment ourselves.
1091 addiu $a0, $sp, 4 # pass stack pointer + ArtMethod* as dest for memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001092 la $t9, memcpy
1093 jalr $t9 # (dest, src, bytes)
Goran Jakovljevicff734982015-08-24 12:58:55 +00001094 addiu $sp, $sp, -16 # make space for argument slots for memcpy
1095 addiu $sp, $sp, 16 # restore stack after memcpy
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001096 lw $gp, 16($fp) # restore $gp
1097 lw $a0, SPILL_SIZE($fp) # restore ArtMethod*
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001098 addiu $t8, $sp, 4 # t8 = pointer to the current argument (skip ArtMethod*)
1099 li $t6, 0 # t6 = gpr_index = 0 (corresponds to A1; A0 is skipped)
1100 li $t7, 0 # t7 = fp_index = 0
1101 lw $t9, 20 + SPILL_SIZE($fp) # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001102 # as the $fp is SPILL_SIZE bytes below the $sp on entry)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001103 addiu $t9, 1 # t9 = shorty + 1 (skip 1 for return type)
1104
1105 // Load the base addresses of tabIntS ... tabDoubleS.
1106 // We will use the register indices (gpr_index, fp_index) to branch.
1107 // Note that the indices are scaled by 16, so they can be added to the bases directly.
1108#if defined(__mips_isa_rev) && __mips_isa_rev >= 6
1109 lapc $t2, tabIntS
1110 lapc $t3, tabLongS
1111 lapc $t4, tabSingleS
1112 lapc $t5, tabDoubleS
1113#else
1114 bltzal $zero, tabBaseS # nal
1115 addiu $t2, $ra, %lo(tabIntS - tabBaseS)
1116tabBaseS:
1117 addiu $t3, $ra, %lo(tabLongS - tabBaseS)
1118 addiu $t4, $ra, %lo(tabSingleS - tabBaseS)
1119 addiu $t5, $ra, %lo(tabDoubleS - tabBaseS)
1120#endif
1121
Goran Jakovljevicff734982015-08-24 12:58:55 +00001122loopS:
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001123 lbu $ra, 0($t9) # ra = shorty[i]
1124 beqz $ra, loopEndS # finish getting args when shorty[i] == '\0'
1125 addiu $t9, 1
Goran Jakovljevicff734982015-08-24 12:58:55 +00001126
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001127 addiu $ra, -'J'
1128 beqz $ra, isLongS # branch if result type char == 'J'
1129 addiu $ra, 'J' - 'D'
1130 beqz $ra, isDoubleS # branch if result type char == 'D'
1131 addiu $ra, 'D' - 'F'
1132 beqz $ra, isSingleS # branch if result type char == 'F'
Goran Jakovljevicff734982015-08-24 12:58:55 +00001133
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001134 addu $ra, $t2, $t6
1135 jalr $zero, $ra
1136 addiu $t8, 4 # next_arg = curr_arg + 4
Goran Jakovljevicff734982015-08-24 12:58:55 +00001137
1138isLongS:
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001139 addu $ra, $t3, $t6
1140 jalr $zero, $ra
1141 addiu $t8, 8 # next_arg = curr_arg + 8
Goran Jakovljevicff734982015-08-24 12:58:55 +00001142
1143isSingleS:
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001144 addu $ra, $t4, $t7
1145 jalr $zero, $ra
1146 addiu $t8, 4 # next_arg = curr_arg + 4
1147
1148isDoubleS:
1149 addu $ra, $t5, $t7
1150#if defined(__mips_isa_rev) && __mips_isa_rev > 2
1151 addiu $t7, 16 # fp_index += 16 didn't fit into LOAD_DOUBLE_TO_REG
1152#endif
1153 jalr $zero, $ra
1154 addiu $t8, 8 # next_arg = curr_arg + 8
Goran Jakovljevicff734982015-08-24 12:58:55 +00001155
1156loopEndS:
1157 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0) # get pointer to the code
1158 jalr $t9 # call the method
1159 sw $zero, 0($sp) # store null for ArtMethod* at bottom of frame
1160 move $sp, $fp # restore the stack
1161 lw $s0, 0($sp)
1162 .cfi_restore 16
1163 lw $s1, 4($sp)
1164 .cfi_restore 17
1165 lw $fp, 8($sp)
1166 .cfi_restore 30
1167 lw $ra, 12($sp)
1168 .cfi_restore 31
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001169 addiu $sp, $sp, SPILL_SIZE
1170 .cfi_adjust_cfa_offset -SPILL_SIZE
Goran Jakovljevicff734982015-08-24 12:58:55 +00001171 lw $t0, 16($sp) # get result pointer
1172 lw $t1, 20($sp) # get shorty
1173 lb $t1, 0($t1) # get result type char
1174 li $t2, 'D' # put char 'D' into t2
1175 beq $t1, $t2, 6f # branch if result type char == 'D'
1176 li $t3, 'F' # put char 'F' into t3
1177 beq $t1, $t3, 6f # branch if result type char == 'F'
1178 sw $v0, 0($t0) # store the result
1179 jalr $zero, $ra
1180 sw $v1, 4($t0) # store the other half of the result
11816:
1182 SDu $f0, $f1, 0, $t0, $t1 # store floating point result
1183 jalr $zero, $ra
1184 nop
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001185
1186 // Note that gpr_index is kept within the range of tabIntS and tabLongS
1187 // and fp_index is kept within the range of tabSingleS and tabDoubleS.
1188 .balign 16
1189tabIntS:
1190 LOAD_WORD_TO_REG a1, t8, t6, loopS # a1 = current argument, gpr_index += 16
1191 LOAD_WORD_TO_REG a2, t8, t6, loopS # a2 = current argument, gpr_index += 16
1192 LOAD_WORD_TO_REG a3, t8, t6, loopS # a3 = current argument, gpr_index += 16
1193 LOAD_WORD_TO_REG t0, t8, t6, loopS # t0 = current argument, gpr_index += 16
1194 LOAD_WORD_TO_REG t1, t8, t6, loopS # t1 = current argument, gpr_index += 16
1195 LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16
1196tabLongS:
1197 LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16
1198 LOAD_LONG_TO_REG a2, a3, t8, t6, 3*16, loopS # a2_a3 = curr_arg, gpr_index = 3*16
1199 LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16
1200 LOAD_LONG_TO_REG t0, t1, t8, t6, 5*16, loopS # t0_t1 = curr_arg, gpr_index = 5*16
1201 LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16
1202 LOAD_END t6, 5*16, loopS # no more GPR args, gpr_index = 5*16
1203tabSingleS:
1204 LOAD_FLOAT_TO_REG f8, t8, t7, loopS # f8 = curr_arg, fp_index += 16
1205 LOAD_FLOAT_TO_REG f10, t8, t7, loopS # f10 = curr_arg, fp_index += 16
1206 LOAD_FLOAT_TO_REG f12, t8, t7, loopS # f12 = curr_arg, fp_index += 16
1207 LOAD_FLOAT_TO_REG f14, t8, t7, loopS # f14 = curr_arg, fp_index += 16
1208 LOAD_FLOAT_TO_REG f16, t8, t7, loopS # f16 = curr_arg, fp_index += 16
1209 LOAD_FLOAT_TO_REG f18, t8, t7, loopS # f18 = curr_arg, fp_index += 16
1210 LOAD_END t7, 6*16, loopS # no more FPR args, fp_index = 6*16
1211tabDoubleS:
1212 LOAD_DOUBLE_TO_REG f8, f9, t8, t7, ra, loopS # f8_f9 = curr_arg; if FPU32, fp_index += 16
1213 LOAD_DOUBLE_TO_REG f10, f11, t8, t7, ra, loopS # f10_f11 = curr_arg; if FPU32, fp_index += 16
1214 LOAD_DOUBLE_TO_REG f12, f13, t8, t7, ra, loopS # f12_f13 = curr_arg; if FPU32, fp_index += 16
1215 LOAD_DOUBLE_TO_REG f14, f15, t8, t7, ra, loopS # f14_f15 = curr_arg; if FPU32, fp_index += 16
1216 LOAD_DOUBLE_TO_REG f16, f17, t8, t7, ra, loopS # f16_f17 = curr_arg; if FPU32, fp_index += 16
1217 LOAD_DOUBLE_TO_REG f18, f19, t8, t7, ra, loopS # f18_f19 = curr_arg; if FPU32, fp_index += 16
1218 LOAD_END t7, 6*16, loopS # no more FPR args, fp_index = 6*16
Goran Jakovljevicff734982015-08-24 12:58:55 +00001219END art_quick_invoke_static_stub
1220
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001221#undef SPILL_SIZE
1222
Goran Jakovljevicff734982015-08-24 12:58:55 +00001223 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08001224 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
1225 * failure.
1226 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001227 .extern artHandleFillArrayDataFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001228ENTRY art_quick_handle_fill_data
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001229 lw $a2, 0($sp) # pass referrer's Method*
1230 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001231 la $t9, artHandleFillArrayDataFromCode
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001232 jalr $t9 # (payload offset, Array*, method, Thread*)
1233 move $a3, rSELF # pass Thread::Current
jeffhaofc6a30e2012-10-18 18:24:15 -07001234 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001235END art_quick_handle_fill_data
buzbee5bc5a7b2012-03-07 15:52:59 -08001236
buzbee5bc5a7b2012-03-07 15:52:59 -08001237 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001238 * Entry from managed code that calls artLockObjectFromCode, may block for GC.
buzbee5bc5a7b2012-03-07 15:52:59 -08001239 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001240 .extern artLockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001241ENTRY art_quick_lock_object
Vladimir Marko804b03f2016-09-14 16:26:36 +01001242 beqz $a0, art_quick_throw_null_pointer_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001243 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001244 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001245 la $t9, artLockObjectFromCode
1246 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001247 move $a1, rSELF # pass Thread::Current
Ian Rogers6bcd1632013-10-08 18:50:47 -07001248 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001249END art_quick_lock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001250
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001251ENTRY art_quick_lock_object_no_inline
Vladimir Marko804b03f2016-09-14 16:26:36 +01001252 beqz $a0, art_quick_throw_null_pointer_exception
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001253 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001254 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case we block
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001255 la $t9, artLockObjectFromCode
1256 jalr $t9 # (Object* obj, Thread*)
1257 move $a1, rSELF # pass Thread::Current
1258 RETURN_IF_ZERO
1259END art_quick_lock_object_no_inline
1260
buzbee5bc5a7b2012-03-07 15:52:59 -08001261 /*
1262 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
1263 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001264 .extern artUnlockObjectFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001265ENTRY art_quick_unlock_object
Vladimir Marko804b03f2016-09-14 16:26:36 +01001266 beqz $a0, art_quick_throw_null_pointer_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001267 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001268 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001269 la $t9, artUnlockObjectFromCode
1270 jalr $t9 # (Object* obj, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001271 move $a1, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001272 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001273END art_quick_unlock_object
buzbee5bc5a7b2012-03-07 15:52:59 -08001274
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001275ENTRY art_quick_unlock_object_no_inline
Vladimir Marko804b03f2016-09-14 16:26:36 +01001276 beqz $a0, art_quick_throw_null_pointer_exception
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001277 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001278 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case exception allocation triggers GC
Andreas Gampec7ed09b2016-04-25 20:08:55 -07001279 la $t9, artUnlockObjectFromCode
1280 jalr $t9 # (Object* obj, Thread*)
1281 move $a1, rSELF # pass Thread::Current
1282 RETURN_IF_ZERO
1283END art_quick_unlock_object_no_inline
1284
buzbee5bc5a7b2012-03-07 15:52:59 -08001285 /*
Mathieu Chartierb99f4d62016-11-07 16:17:26 -08001286 * Entry from managed code that calls artInstanceOfFromCode and delivers exception on failure.
buzbee5bc5a7b2012-03-07 15:52:59 -08001287 */
Mathieu Chartierb99f4d62016-11-07 16:17:26 -08001288 .extern artInstanceOfFromCode
1289 .extern artThrowClassCastExceptionForObject
1290ENTRY art_quick_check_instance_of
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001291 addiu $sp, $sp, -32
1292 .cfi_adjust_cfa_offset 32
1293 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001294 sw $ra, 12($sp)
1295 .cfi_rel_offset 31, 12
1296 sw $t9, 8($sp)
1297 sw $a1, 4($sp)
1298 sw $a0, 0($sp)
Mathieu Chartierb99f4d62016-11-07 16:17:26 -08001299 la $t9, artInstanceOfFromCode
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001300 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001301 addiu $sp, $sp, -16 # reserve argument slots on the stack
1302 addiu $sp, $sp, 16
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001303 lw $gp, 16($sp)
Ian Rogers86bcdc22014-02-21 22:06:38 -08001304 beqz $v0, .Lthrow_class_cast_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001305 lw $ra, 12($sp)
Andreas Gampe8d365912015-01-13 11:32:32 -08001306 jalr $zero, $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001307 addiu $sp, $sp, 32
1308 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001309.Lthrow_class_cast_exception:
Ian Rogersa9a82542013-10-04 11:17:26 -07001310 lw $t9, 8($sp)
1311 lw $a1, 4($sp)
1312 lw $a0, 0($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001313 addiu $sp, $sp, 32
1314 .cfi_adjust_cfa_offset -32
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001315 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Mathieu Chartierb99f4d62016-11-07 16:17:26 -08001316 la $t9, artThrowClassCastExceptionForObject
1317 jalr $zero, $t9 # artThrowClassCastException (Object*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001318 move $a2, rSELF # pass Thread::Current
Mathieu Chartierb99f4d62016-11-07 16:17:26 -08001319END art_quick_check_instance_of
buzbee5bc5a7b2012-03-07 15:52:59 -08001320
buzbee5bc5a7b2012-03-07 15:52:59 -08001321 /*
Man Cao1aee9002015-07-14 22:31:42 -07001322 * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
1323 * nReg is the register number for rReg.
1324 */
1325.macro POP_REG_NE rReg, nReg, offset, rExclude
1326 .ifnc \rReg, \rExclude
1327 lw \rReg, \offset($sp) # restore rReg
1328 .cfi_restore \nReg
1329 .endif
1330.endm
1331
1332 /*
1333 * Macro to insert read barrier, only used in art_quick_aput_obj.
1334 * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
1335 * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
1336 */
1337.macro READ_BARRIER rDest, rObj, offset
1338#ifdef USE_READ_BARRIER
1339 # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment.
1340 addiu $sp, $sp, -32
1341 .cfi_adjust_cfa_offset 32
1342 sw $ra, 28($sp)
1343 .cfi_rel_offset 31, 28
1344 sw $t9, 24($sp)
1345 .cfi_rel_offset 25, 24
1346 sw $t1, 20($sp)
1347 .cfi_rel_offset 9, 20
1348 sw $t0, 16($sp)
1349 .cfi_rel_offset 8, 16
1350 sw $a2, 8($sp) # padding slot at offset 12 (padding can be any slot in the 32B)
1351 .cfi_rel_offset 6, 8
1352 sw $a1, 4($sp)
1353 .cfi_rel_offset 5, 4
1354 sw $a0, 0($sp)
1355 .cfi_rel_offset 4, 0
1356
Man Cao63069212015-08-21 15:51:39 -07001357 # move $a0, \rRef # pass ref in a0 (no-op for now since parameter ref is unused)
Man Cao1aee9002015-07-14 22:31:42 -07001358 .ifnc \rObj, $a1
1359 move $a1, \rObj # pass rObj
1360 .endif
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001361 addiu $a2, $zero, \offset # pass offset
1362 la $t9, artReadBarrierSlow
1363 jalr $t9 # artReadBarrierSlow(ref, rObj, offset)
Man Cao1aee9002015-07-14 22:31:42 -07001364 addiu $sp, $sp, -16 # Use branch delay slot to reserve argument slots on the stack
1365 # before the call to artReadBarrierSlow.
1366 addiu $sp, $sp, 16 # restore stack after call to artReadBarrierSlow
1367 # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
1368 move \rDest, $v0 # save return value in rDest
1369 # (rDest cannot be v0 in art_quick_aput_obj)
1370
1371 lw $a0, 0($sp) # restore registers except rDest
1372 # (rDest can only be t0 or t1 in art_quick_aput_obj)
1373 .cfi_restore 4
1374 lw $a1, 4($sp)
1375 .cfi_restore 5
1376 lw $a2, 8($sp)
1377 .cfi_restore 6
1378 POP_REG_NE $t0, 8, 16, \rDest
1379 POP_REG_NE $t1, 9, 20, \rDest
1380 lw $t9, 24($sp)
1381 .cfi_restore 25
1382 lw $ra, 28($sp) # restore $ra
1383 .cfi_restore 31
1384 addiu $sp, $sp, 32
1385 .cfi_adjust_cfa_offset -32
1386#else
1387 lw \rDest, \offset(\rObj)
1388 UNPOISON_HEAP_REF \rDest
1389#endif // USE_READ_BARRIER
1390.endm
1391
1392 /*
Ian Rogersa9a82542013-10-04 11:17:26 -07001393 * Entry from managed code for array put operations of objects where the value being stored
1394 * needs to be checked for compatibility.
1395 * a0 = array, a1 = index, a2 = value
buzbee5bc5a7b2012-03-07 15:52:59 -08001396 */
Ian Rogersa9a82542013-10-04 11:17:26 -07001397ENTRY art_quick_aput_obj_with_null_and_bound_check
Ian Rogers86bcdc22014-02-21 22:06:38 -08001398 bnez $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001399 nop
Vladimir Marko804b03f2016-09-14 16:26:36 +01001400 b art_quick_throw_null_pointer_exception
Ian Rogersa9a82542013-10-04 11:17:26 -07001401 nop
1402END art_quick_aput_obj_with_null_and_bound_check
1403
1404ENTRY art_quick_aput_obj_with_bound_check
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001405 lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001406 sltu $t1, $a1, $t0
Ian Rogers86bcdc22014-02-21 22:06:38 -08001407 bnez $t1, .Lart_quick_aput_obj_gp_set
Ian Rogersa9a82542013-10-04 11:17:26 -07001408 nop
1409 move $a0, $a1
Vladimir Marko804b03f2016-09-14 16:26:36 +01001410 b art_quick_throw_array_bounds
Ian Rogersa9a82542013-10-04 11:17:26 -07001411 move $a1, $t0
1412END art_quick_aput_obj_with_bound_check
1413
Man Cao1aee9002015-07-14 22:31:42 -07001414#ifdef USE_READ_BARRIER
1415 .extern artReadBarrierSlow
1416#endif
Ian Rogersa9a82542013-10-04 11:17:26 -07001417ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -08001418 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -07001419 nop
Man Cao1aee9002015-07-14 22:31:42 -07001420 READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
1421 READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
1422 READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogers86bcdc22014-02-21 22:06:38 -08001423 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -07001424 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001425.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -07001426 sll $a1, $a1, 2
1427 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001428 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001429 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001430 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
1431 srl $t1, $a0, 7
1432 add $t1, $t1, $t0
1433 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -08001434 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001435 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001436.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -07001437 sll $a1, $a1, 2
1438 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001439 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -08001440 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001441 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001442.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -07001443 addiu $sp, $sp, -32
1444 .cfi_adjust_cfa_offset 32
1445 sw $ra, 28($sp)
1446 .cfi_rel_offset 31, 28
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001447 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001448 sw $t9, 12($sp)
1449 sw $a2, 8($sp)
1450 sw $a1, 4($sp)
1451 sw $a0, 0($sp)
1452 move $a1, $t1
1453 move $a0, $t0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001454 la $t9, artIsAssignableFromCode
1455 jalr $t9 # (Class*, Class*)
1456 addiu $sp, $sp, -16 # reserve argument slots on the stack
1457 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -07001458 lw $ra, 28($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001459 lw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001460 lw $t9, 12($sp)
1461 lw $a2, 8($sp)
1462 lw $a1, 4($sp)
1463 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001464 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -07001465 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001466 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -07001467 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001468 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -07001469 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -07001470 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -08001471 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001472 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -07001473END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -08001474
buzbee5bc5a7b2012-03-07 15:52:59 -08001475 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001476 * Called by managed code to resolve a static field and load a boolean primitive value.
1477 */
1478 .extern artGetBooleanStaticFromCode
1479ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -07001480 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001481 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001482 la $t9, artGetBooleanStaticFromCode
1483 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001484 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001485 RETURN_IF_NO_EXCEPTION
1486END art_quick_get_boolean_static
1487 /*
1488 * Called by managed code to resolve a static field and load a byte primitive value.
1489 */
1490 .extern artGetByteStaticFromCode
1491ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -07001492 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001493 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001494 la $t9, artGetByteStaticFromCode
1495 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001496 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001497 RETURN_IF_NO_EXCEPTION
1498END art_quick_get_byte_static
1499
1500 /*
1501 * Called by managed code to resolve a static field and load a char primitive value.
1502 */
1503 .extern artGetCharStaticFromCode
1504ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -07001505 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001506 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001507 la $t9, artGetCharStaticFromCode
1508 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001509 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001510 RETURN_IF_NO_EXCEPTION
1511END art_quick_get_char_static
1512 /*
1513 * Called by managed code to resolve a static field and load a short primitive value.
1514 */
1515 .extern artGetShortStaticFromCode
1516ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -07001517 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001518 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001519 la $t9, artGetShortStaticFromCode
1520 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001521 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001522 RETURN_IF_NO_EXCEPTION
1523END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001524
buzbee5bc5a7b2012-03-07 15:52:59 -08001525 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001526 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001527 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001528 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001529ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001530 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001531 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001532 la $t9, artGet32StaticFromCode
1533 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001534 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001535 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001536END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001537
buzbee5bc5a7b2012-03-07 15:52:59 -08001538 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001539 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001540 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001541 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001542ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001543 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001544 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001545 la $t9, artGet64StaticFromCode
1546 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001547 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001548 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001549END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001550
buzbee5bc5a7b2012-03-07 15:52:59 -08001551 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001552 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001553 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001554 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001555ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001556 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001557 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001558 la $t9, artGetObjStaticFromCode
1559 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001560 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001561 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001562END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001563
buzbee5bc5a7b2012-03-07 15:52:59 -08001564 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001565 * Called by managed code to resolve an instance field and load a boolean primitive value.
1566 */
1567 .extern artGetBooleanInstanceFromCode
1568ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001569 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001570 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001571 la $t9, artGetBooleanInstanceFromCode
1572 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001573 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001574 RETURN_IF_NO_EXCEPTION
1575END art_quick_get_boolean_instance
1576 /*
1577 * Called by managed code to resolve an instance field and load a byte primitive value.
1578 */
1579 .extern artGetByteInstanceFromCode
1580ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001581 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001582 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001583 la $t9, artGetByteInstanceFromCode
1584 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001585 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001586 RETURN_IF_NO_EXCEPTION
1587END art_quick_get_byte_instance
1588
1589 /*
1590 * Called by managed code to resolve an instance field and load a char primitive value.
1591 */
1592 .extern artGetCharInstanceFromCode
1593ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001594 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001595 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001596 la $t9, artGetCharInstanceFromCode
1597 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001598 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001599 RETURN_IF_NO_EXCEPTION
1600END art_quick_get_char_instance
1601 /*
1602 * Called by managed code to resolve an instance field and load a short primitive value.
1603 */
1604 .extern artGetShortInstanceFromCode
1605ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001606 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001607 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001608 la $t9, artGetShortInstanceFromCode
1609 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001610 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001611 RETURN_IF_NO_EXCEPTION
1612END art_quick_get_short_instance
1613
1614 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001615 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001616 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001617 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001618ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001619 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001620 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001621 la $t9, artGet32InstanceFromCode
1622 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001623 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001624 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001625END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001626
buzbee5bc5a7b2012-03-07 15:52:59 -08001627 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001628 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001629 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001630 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001631ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001632 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001633 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001634 la $t9, artGet64InstanceFromCode
1635 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001636 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001637 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001638END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001639
buzbee5bc5a7b2012-03-07 15:52:59 -08001640 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001641 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001642 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001643 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001644ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001645 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001646 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001647 la $t9, artGetObjInstanceFromCode
1648 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001649 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001650 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001651END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001652
buzbee5bc5a7b2012-03-07 15:52:59 -08001653 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001654 * Called by managed code to resolve a static field and store a 8-bit primitive value.
1655 */
1656 .extern artSet8StaticFromCode
1657ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -07001658 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001659 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001660 la $t9, artSet8StaticFromCode
1661 jalr $t9 # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001662 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001663 RETURN_IF_ZERO
1664END art_quick_set8_static
1665
1666 /*
1667 * Called by managed code to resolve a static field and store a 16-bit primitive value.
1668 */
1669 .extern artSet16StaticFromCode
1670ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -07001671 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001672 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001673 la $t9, artSet16StaticFromCode
1674 jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001675 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001676 RETURN_IF_ZERO
1677END art_quick_set16_static
1678
1679 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001680 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001681 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001682 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001683ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001684 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001685 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001686 la $t9, artSet32StaticFromCode
1687 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001688 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001689 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001690END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001691
buzbee5bc5a7b2012-03-07 15:52:59 -08001692 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001693 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001694 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001695 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001696ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001697 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001698 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001699 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001700 la $t9, artSet64StaticFromCode
1701 jalr $t9 # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001702 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001703 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001704END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001705
buzbee5bc5a7b2012-03-07 15:52:59 -08001706 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001707 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001708 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001709 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001710ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001711 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001712 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001713 la $t9, artSetObjStaticFromCode
1714 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001715 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001716 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001717END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001718
buzbee5bc5a7b2012-03-07 15:52:59 -08001719 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001720 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1721 */
1722 .extern artSet8InstanceFromCode
1723ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001724 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001725 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001726 la $t9, artSet8InstanceFromCode
1727 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001728 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001729 RETURN_IF_ZERO
1730END art_quick_set8_instance
1731
1732 /*
1733 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1734 */
1735 .extern artSet16InstanceFromCode
1736ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001737 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001738 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001739 la $t9, artSet16InstanceFromCode
1740 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001741 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001742 RETURN_IF_ZERO
1743END art_quick_set16_instance
1744
1745 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001746 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001747 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001748 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001749ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001750 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001751 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001752 la $t9, artSet32InstanceFromCode
1753 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001754 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001755 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001756END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001757
buzbee5bc5a7b2012-03-07 15:52:59 -08001758 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001759 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001760 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001761 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001762ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001763 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001764 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001765 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001766 sw rSELF, 20($sp) # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001767 la $t9, artSet64InstanceFromCode
1768 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001769 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001770 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001771END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001772
buzbee5bc5a7b2012-03-07 15:52:59 -08001773 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001774 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001775 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001776 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001777ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001778 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001779 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001780 la $t9, artSetObjInstanceFromCode
1781 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001782 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001783 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001784END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001785
Vladimir Markoa3c38272015-04-28 12:37:09 +01001786// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001787.macro ONE_ARG_DOWNCALL name, entrypoint, return
1788 .extern \entrypoint
1789ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001790 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001791 la $t9, \entrypoint
1792 jalr $t9
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001793 move $a1, rSELF # pass Thread::Current
1794 \return
1795END \name
1796.endm
1797
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001798.macro TWO_ARG_DOWNCALL name, entrypoint, return
1799 .extern \entrypoint
1800ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001801 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001802 la $t9, \entrypoint
1803 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001804 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001805 \return
1806END \name
1807.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001808
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001809.macro THREE_ARG_DOWNCALL name, entrypoint, return
1810 .extern \entrypoint
1811ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001812 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001813 la $t9, \entrypoint
1814 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001815 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001816 \return
1817END \name
1818.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001819
Jeff Hao848f70a2014-01-15 13:49:50 -08001820.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1821 .extern \entrypoint
1822ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001823 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001824 la $t9, \entrypoint
1825 jalr $t9
Vladimir Markoa3c38272015-04-28 12:37:09 +01001826 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001827 \return
1828END \name
1829.endm
1830
Mathieu Chartier7410f292013-11-24 13:17:35 -08001831// Generate the allocation entrypoints for each allocator.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001832GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001833
Pavle Batuta712c59d2015-12-02 18:39:01 +01001834
Nicolas Geoffray0d3998b2017-01-12 15:35:12 +00001835GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc, RosAlloc)
1836GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB)
1837GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB)
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001838
buzbee5bc5a7b2012-03-07 15:52:59 -08001839 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001840 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001841 * exception on error. On success the String is returned. A0 holds the string index. The fast
1842 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001843 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001844ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001845
1846 /*
1847 * Entry from managed code when uninitialized static storage, this stub will run the class
1848 * initializer and deliver the exception on error. On success the static storage base is
1849 * returned.
1850 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001851ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001852
1853 /*
1854 * Entry from managed code when dex cache misses for a type_idx.
1855 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001856ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001857
1858 /*
1859 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1860 * miss.
1861 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001862ONE_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 -08001863
1864 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001865 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001866 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001867 .extern artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001868ENTRY_NO_GP art_quick_test_suspend
1869 lh rSUSPEND, THREAD_FLAGS_OFFSET(rSELF)
1870 bnez rSUSPEND, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001871 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001872 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001873 nop
18741:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001875 SETUP_SAVE_EVERYTHING_FRAME # save everything for stack crawl
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001876 la $t9, artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001877 jalr $t9 # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001878 move $a0, rSELF
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001879 RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +01001880 jalr $zero, $ra
1881 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001882END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001883
buzbee5bc5a7b2012-03-07 15:52:59 -08001884 /*
1885 * Called by managed code that is attempting to call a method on a proxy class. On entry
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001886 * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001887 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001888 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001889ENTRY art_quick_proxy_invoke_handler
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001890 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001891 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001892 la $t9, artQuickProxyInvokeHandler
1893 jalr $t9 # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001894 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001895 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001896 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001897 bnez $t7, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001898 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1899 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001900 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001901 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080019021:
1903 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001904END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001905
Jeff Hao88474b42013-10-23 16:24:40 -07001906 /*
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001907 * Called to resolve an imt conflict.
1908 * a0 is the conflict ArtMethod.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001909 * t7 is a hidden argument that holds the target interface method's dex method index.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001910 *
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001911 * Note that this stub writes to a0, t7 and t8.
Jeff Hao88474b42013-10-23 16:24:40 -07001912 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001913ENTRY art_quick_imt_conflict_trampoline
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001914 lw $t8, 0($sp) # Load referrer.
1915 lw $t8, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t8) # Load dex cache methods array.
1916 sll $t7, $t7, POINTER_SIZE_SHIFT # Calculate offset.
1917 addu $t7, $t8, $t7 # Add offset to base.
1918 lw $t7, 0($t7) # Load interface method.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001919 lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable.
1920
1921.Limt_table_iterate:
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001922 lw $t8, 0($a0) # Load next entry in ImtConflictTable.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001923 # Branch if found.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001924 beq $t8, $t7, .Limt_table_found
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001925 nop
1926 # If the entry is null, the interface method is not in the ImtConflictTable.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001927 beqz $t8, .Lconflict_trampoline
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001928 nop
1929 # Iterate over the entries of the ImtConflictTable.
1930 b .Limt_table_iterate
1931 addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry.
1932
1933.Limt_table_found:
1934 # We successfully hit an entry in the table. Load the target method and jump to it.
1935 lw $a0, __SIZEOF_POINTER__($a0)
1936 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001937 jalr $zero, $t9
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001938 nop
1939
1940.Lconflict_trampoline:
1941 # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001942 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001943END art_quick_imt_conflict_trampoline
1944
Ian Rogers468532e2013-08-05 10:56:33 -07001945 .extern artQuickResolutionTrampoline
1946ENTRY art_quick_resolution_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001947 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001948 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001949 la $t9, artQuickResolutionTrampoline
1950 jalr $t9 # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001951 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001952 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001953 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001954 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001955 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001956 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001957 nop
Ian Rogers468532e2013-08-05 10:56:33 -070019581:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001959 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001960 DELIVER_PENDING_EXCEPTION
1961END art_quick_resolution_trampoline
1962
Douglas Leung735b8552014-10-31 12:21:40 -07001963 .extern artQuickGenericJniTrampoline
1964 .extern artQuickGenericJniEndTrampoline
1965ENTRY art_quick_generic_jni_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001966 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001967 move $s8, $sp # save $sp to $s8
1968 move $s3, $gp # save $gp to $s3
1969
1970 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1971 move $a0, rSELF # pass Thread::Current
1972 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001973 la $t9, artQuickGenericJniTrampoline
1974 jalr $t9 # (Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001975 addiu $sp, $sp, -5120 # reserve space on the stack
1976
1977 # The C call will have registered the complete save-frame on success.
1978 # The result of the call is:
1979 # v0: ptr to native code, 0 on error.
1980 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001981 beq $v0, $zero, 2f # check entry error
Douglas Leung735b8552014-10-31 12:21:40 -07001982 move $t9, $v0 # save the code ptr
1983 move $sp, $v1 # release part of the alloca
1984
1985 # Load parameters from stack into registers
1986 lw $a0, 0($sp)
1987 lw $a1, 4($sp)
1988 lw $a2, 8($sp)
Douglas Leung735b8552014-10-31 12:21:40 -07001989 lw $a3, 12($sp)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001990
1991 # artQuickGenericJniTrampoline sets bit 0 of the native code address to 1
1992 # when the first two arguments are both single precision floats. This lets
1993 # us extract them properly from the stack and load into floating point
1994 # registers.
1995 MTD $a0, $a1, $f12, $f13
1996 andi $t0, $t9, 1
1997 xor $t9, $t9, $t0
1998 bnez $t0, 1f
1999 mtc1 $a1, $f14
2000 MTD $a2, $a3, $f14, $f15
2001
20021:
2003 jalr $t9 # native call
2004 nop
Douglas Leung735b8552014-10-31 12:21:40 -07002005 addiu $sp, $sp, 16 # remove arg slots
2006
2007 move $gp, $s3 # restore $gp from $s3
2008
2009 # result sign extension is handled in C code
2010 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
2011 move $a0, rSELF # pass Thread::Current
2012 move $a2, $v0 # pass result
2013 move $a3, $v1
2014 addiu $sp, $sp, -24 # reserve arg slots
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002015 la $t9, artQuickGenericJniEndTrampoline
2016 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07002017 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07002018
2019 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002020 bne $t0, $zero, 2f # check for pending exceptions
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002021
Douglas Leung735b8552014-10-31 12:21:40 -07002022 move $sp, $s8 # tear down the alloca
2023
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002024 # tear down the callee-save frame
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002025 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002026
Duane Sande34652f2014-11-04 11:09:36 -08002027 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002028 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002029 nop
Douglas Leung735b8552014-10-31 12:21:40 -07002030
Alexey Frunze1b8464d2016-11-12 17:22:05 -080020312:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002032 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
2033 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07002034 DELIVER_PENDING_EXCEPTION
2035END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08002036
Ian Rogers468532e2013-08-05 10:56:33 -07002037 .extern artQuickToInterpreterBridge
2038ENTRY art_quick_to_interpreter_bridge
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002039 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002040 move $a1, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002041 la $t9, artQuickToInterpreterBridge
2042 jalr $t9 # (Method* method, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07002043 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002044 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002045 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002046 bnez $t7, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002047 # don't care if $v0 and/or $v1 are modified, when exception branch taken
2048 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002049 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002050 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080020511:
2052 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07002053END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08002054
buzbee5bc5a7b2012-03-07 15:52:59 -08002055 /*
jeffhao725a9572012-11-13 18:20:12 -08002056 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08002057 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002058 .extern artInstrumentationMethodEntryFromCode
2059 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07002060ENTRY art_quick_instrumentation_entry
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002061 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002062 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002063 move $a3, $ra # pass $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002064 la $t9, artInstrumentationMethodEntryFromCode
2065 jalr $t9 # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08002066 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07002067 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07002068 lw $a0, 28($sp) # restore arg0 from free arg slot
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002069 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhao8161c032012-10-31 15:50:00 -07002070 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08002071 nop
Ian Rogers468532e2013-08-05 10:56:33 -07002072END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08002073 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07002074 .global art_quick_instrumentation_exit
2075art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002076 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08002077 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002078 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07002079 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07002080
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002081 SETUP_SAVE_REFS_ONLY_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002082 addiu $sp, $sp, -16 # allocate temp storage on the stack
2083 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002084 sw $v0, ARG_SLOT_SIZE+12($sp)
2085 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
2086 sw $v1, ARG_SLOT_SIZE+8($sp)
2087 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
2088 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08002089 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08002090 move $a2, $v0 # pass gpr result
2091 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002092 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002093 la $t9, artInstrumentationMethodExitFromCode
2094 jalr $t9 # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08002095 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002096 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08002097 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002098 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
2099 lw $v1, ARG_SLOT_SIZE+8($sp)
2100 l.d $f0, ARG_SLOT_SIZE($sp)
2101 jalr $zero, $t9 # return
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002102 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16 # restore stack
2103 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16)
Ian Rogers468532e2013-08-05 10:56:33 -07002104END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08002105
jeffhao12051ea2013-01-10 11:24:31 -08002106 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08002107 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
2108 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08002109 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002110 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002111ENTRY art_quick_deoptimize
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002112 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002113 la $t9, artDeoptimize
2114 jalr $t9 # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08002115 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002116 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002117END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08002118
buzbee5bc5a7b2012-03-07 15:52:59 -08002119 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00002120 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
2121 * will long jump to the upcall with a special exception of -1.
2122 */
2123 .extern artDeoptimizeFromCompiledCode
2124ENTRY art_quick_deoptimize_from_compiled_code
Vladimir Marko239d6ea2016-09-05 10:44:04 +01002125 SETUP_SAVE_EVERYTHING_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002126 la $t9, artDeoptimizeFromCompiledCode
2127 jalr $t9 # artDeoptimizeFromCompiledCode(Thread*)
Sebastien Hertz07474662015-08-25 15:12:33 +00002128 # Returns caller method's frame size.
2129 move $a0, rSELF # pass Thread::current
2130END art_quick_deoptimize_from_compiled_code
2131
2132 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08002133 * 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_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002143 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07002144 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
2145 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
2146 srl $a0, 1
2147 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
2148 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002149 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002150 beqz $a2, 1f
2151 or $v1, $a0 # rhi<- rhi | alo
2152
2153 move $v1, $v0 # rhi<- rlo (if shift&0x20)
2154 move $v0, $zero # rlo<- 0 (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_shl_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:
jeffhao7fbee072012-08-24 17:56:54 -07002166 * $a0: low word
2167 * $a1: high word
2168 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002169 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002170ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07002171 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
2172 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
2173 sra $a3, $a1, 31 # $a3<- sign(ah)
2174 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
Douglas Leung475cfd82014-12-16 20:15:41 -08002178 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002179 or $v0, $a1 # rlo<- rlo | ahi
2180
2181 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2182 move $v1, $a3 # rhi<- sign(ahi) (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_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002187
buzbee5bc5a7b2012-03-07 15:52:59 -08002188 /*
2189 * Long integer shift. This is different from the generic 32/64-bit
2190 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2191 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2192 * 6 bits.
2193 * On entry:
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002194 * $a0: low word
2195 * $a1: high word
2196 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002197 */
2198 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002199ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07002200 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002201 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002202 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2203 sll $a1, 1
2204 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002205 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002206 beqz $a2, 1f
2207 or $v0, $a1 # rlo<- rlo | ahi
2208
2209 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2210 move $v1, $zero # rhi<- 0 (if shift&0x20)
2211
Andreas Gampe8d365912015-01-13 11:32:32 -080022121: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002213 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002214END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07002215
Chris Larsencf283da2016-01-19 16:45:35 -08002216/* java.lang.String.indexOf(int ch, int fromIndex=0) */
2217ENTRY_NO_GP art_quick_indexof
2218/* $a0 holds address of "this" */
2219/* $a1 holds "ch" */
2220/* $a2 holds "fromIndex" */
2221 lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002222 slt $t1, $a2, $zero # if fromIndex < 0
Chris Larsencf283da2016-01-19 16:45:35 -08002223#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002224 seleqz $a2, $a2, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002225#else
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002226 movn $a2, $zero, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002227#endif
2228 subu $t0, $t0, $a2 # this.length() - fromIndex
2229 blez $t0, 6f # if this.length()-fromIndex <= 0
2230 li $v0, -1 # return -1;
2231
2232 sll $v0, $a2, 1 # $a0 += $a2 * 2
Orion Hodsonac141392017-01-13 11:53:47 +00002233 addu $a0, $a0, $v0 # " ditto "
Chris Larsencf283da2016-01-19 16:45:35 -08002234 move $v0, $a2 # Set i to fromIndex.
2235
22361:
2237 lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch
2238 beq $t3, $a1, 6f # return i;
2239 addu $a0, $a0, 2 # i++
2240 subu $t0, $t0, 1 # this.length() - i
2241 bnez $t0, 1b # while this.length() - i > 0
2242 addu $v0, $v0, 1 # i++
2243
2244 li $v0, -1 # if this.length() - i <= 0
2245 # return -1;
2246
22476:
2248 j $ra
2249 nop
2250END art_quick_indexof
2251
Chris Larsencf283da2016-01-19 16:45:35 -08002252/* java.lang.String.compareTo(String anotherString) */
2253ENTRY_NO_GP art_quick_string_compareto
2254/* $a0 holds address of "this" */
2255/* $a1 holds address of "anotherString" */
2256 beq $a0, $a1, 9f # this and anotherString are the same object
2257 move $v0, $zero
2258
2259 lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
2260 lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length()
2261 MINu $t2, $a2, $a3
2262# $t2 now holds min(this.length(),anotherString.length())
2263
2264 beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0
2265 subu $v0, $a2, $a3 # if $t2==0 return
2266 # (this.length() - anotherString.length())
22671:
2268 lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i)
2269 lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1)
2270 bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i)
2271 subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i))
2272 addiu $a0, $a0, 2 # point at this.charAt(i++)
2273 subu $t2, $t2, 1 # new value of
2274 # min(this.length(),anotherString.length())-i
2275 bnez $t2, 1b
2276 addiu $a1, $a1, 2 # point at anotherString.charAt(i++)
2277 subu $v0, $a2, $a3
2278
22799:
2280 j $ra
2281 nop
2282END art_quick_string_compareto
Orion Hodsonac141392017-01-13 11:53:47 +00002283
2284.extern artInvokePolymorphic
2285ENTRY art_quick_invoke_polymorphic
2286 SETUP_SAVE_REFS_AND_ARGS_FRAME
2287 move $a2, rSELF # Make $a2 an alias for the current Thread.
2288 move $a3, $sp # Make $a3 a pointer to the saved frame context.
2289 addiu $sp, $sp, -24 # Reserve space for JValue result and 4 words for callee.
2290 .cfi_adjust_cfa_offset 24
2291 sw $zero, 20($sp) # Initialize JValue result.
2292 sw $zero, 16($sp)
2293 addiu $a0, $sp, 16 # Make $a0 a pointer to the JValue result
2294 la $t9, artInvokePolymorphic
2295 jalr $t9 # (result, receiver, Thread*, context)
2296 nop
2297.macro MATCH_RETURN_TYPE c, handler
2298 li $t0, \c
2299 beq $v0, $t0, \handler
2300.endm
2301 MATCH_RETURN_TYPE 'V', .Lcleanup_and_return
2302 MATCH_RETURN_TYPE 'L', .Lstore_int_result
2303 MATCH_RETURN_TYPE 'I', .Lstore_int_result
2304 MATCH_RETURN_TYPE 'J', .Lstore_long_result
2305 MATCH_RETURN_TYPE 'B', .Lstore_int_result
2306 MATCH_RETURN_TYPE 'C', .Lstore_char_result
2307 MATCH_RETURN_TYPE 'D', .Lstore_double_result
2308 MATCH_RETURN_TYPE 'F', .Lstore_float_result
2309 MATCH_RETURN_TYPE 'S', .Lstore_int_result
2310.purgem MATCH_RETURN_TYPE
2311 nop
2312 b .Lcleanup_and_return
2313 nop
2314.Lstore_boolean_result:
2315 lbu $v0, 16($sp) # Move byte from JValue result to return value register.
2316 b .Lcleanup_and_return
2317 nop
2318.Lstore_char_result:
2319 lhu $v0, 16($sp) # Move char from JValue result to return value register.
2320 b .Lcleanup_and_return
2321 nop
2322.Lstore_double_result:
2323.Lstore_float_result:
2324 LDu $f0, $f1, 16, $sp, $t0 # Move double/float from JValue result to return value register.
2325 b .Lcleanup_and_return
2326 nop
2327.Lstore_long_result:
2328 lw $v1, 20($sp) # Move upper bits from JValue result to return value register.
2329 // Fall-through for lower bits.
2330.Lstore_int_result:
2331 lw $v0, 16($sp) # Move lower bits from JValue result to return value register.
2332 // Fall-through to clean up and return.
2333.Lcleanup_and_return:
2334 addiu $sp, $sp, 24 # Remove space for JValue result and the 4 words for the callee.
2335 .cfi_adjust_cfa_offset -24
2336 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # Load Thread::Current()->exception_
2337 RESTORE_SAVE_REFS_AND_ARGS_FRAME
2338 bnez $t7, 1f # Success if no exception is pending.
2339 nop
2340 jalr $zero, $ra
2341 nop
23421:
2343 DELIVER_PENDING_EXCEPTION
2344END art_quick_invoke_polymorphic