blob: 76218fb542d3444de5e7c5038951f1a354a0ddd7 [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
Man Cao1aee9002015-07-14 22:31:42 -07001392#ifdef USE_READ_BARRIER
1393 .extern artReadBarrierSlow
1394#endif
Ian Rogersa9a82542013-10-04 11:17:26 -07001395ENTRY art_quick_aput_obj
Ian Rogers86bcdc22014-02-21 22:06:38 -08001396 beqz $a2, .Ldo_aput_null
Ian Rogersa9a82542013-10-04 11:17:26 -07001397 nop
Man Cao1aee9002015-07-14 22:31:42 -07001398 READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
1399 READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
1400 READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
Ian Rogers86bcdc22014-02-21 22:06:38 -08001401 bne $t1, $t0, .Lcheck_assignability # value's type == array's component type - trivial assignability
Ian Rogersa9a82542013-10-04 11:17:26 -07001402 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001403.Ldo_aput:
Ian Rogersa9a82542013-10-04 11:17:26 -07001404 sll $a1, $a1, 2
1405 add $t0, $a0, $a1
Hiroshi Yamauchibfa5eb62015-05-29 15:04:41 -07001406 POISON_HEAP_REF $a2
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001407 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Ian Rogersa9a82542013-10-04 11:17:26 -07001408 lw $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
1409 srl $t1, $a0, 7
1410 add $t1, $t1, $t0
1411 sb $t0, ($t1)
Andreas Gampe8d365912015-01-13 11:32:32 -08001412 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001413 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001414.Ldo_aput_null:
Ian Rogersa9a82542013-10-04 11:17:26 -07001415 sll $a1, $a1, 2
1416 add $t0, $a0, $a1
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001417 sw $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
Andreas Gampe8d365912015-01-13 11:32:32 -08001418 jalr $zero, $ra
Ian Rogersa9a82542013-10-04 11:17:26 -07001419 nop
Ian Rogers86bcdc22014-02-21 22:06:38 -08001420.Lcheck_assignability:
Ian Rogersa9a82542013-10-04 11:17:26 -07001421 addiu $sp, $sp, -32
1422 .cfi_adjust_cfa_offset 32
1423 sw $ra, 28($sp)
1424 .cfi_rel_offset 31, 28
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001425 sw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001426 sw $t9, 12($sp)
1427 sw $a2, 8($sp)
1428 sw $a1, 4($sp)
1429 sw $a0, 0($sp)
1430 move $a1, $t1
1431 move $a0, $t0
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001432 la $t9, artIsAssignableFromCode
1433 jalr $t9 # (Class*, Class*)
1434 addiu $sp, $sp, -16 # reserve argument slots on the stack
1435 addiu $sp, $sp, 16
Ian Rogersa9a82542013-10-04 11:17:26 -07001436 lw $ra, 28($sp)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001437 lw $gp, 16($sp)
Ian Rogersa9a82542013-10-04 11:17:26 -07001438 lw $t9, 12($sp)
1439 lw $a2, 8($sp)
1440 lw $a1, 4($sp)
1441 lw $a0, 0($sp)
Duane Sande34652f2014-11-04 11:09:36 -08001442 addiu $sp, 32
Ian Rogersa9a82542013-10-04 11:17:26 -07001443 .cfi_adjust_cfa_offset -32
Ian Rogers86bcdc22014-02-21 22:06:38 -08001444 bnez $v0, .Ldo_aput
Ian Rogersa9a82542013-10-04 11:17:26 -07001445 nop
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001446 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Ian Rogersa9a82542013-10-04 11:17:26 -07001447 move $a1, $a2
Ian Rogersa9a82542013-10-04 11:17:26 -07001448 la $t9, artThrowArrayStoreException
Andreas Gampe8d365912015-01-13 11:32:32 -08001449 jalr $zero, $t9 # artThrowArrayStoreException(Class*, Class*, Thread*)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001450 move $a2, rSELF # pass Thread::Current
Ian Rogersa9a82542013-10-04 11:17:26 -07001451END art_quick_aput_obj
buzbee5bc5a7b2012-03-07 15:52:59 -08001452
buzbee5bc5a7b2012-03-07 15:52:59 -08001453 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001454 * Called by managed code to resolve a static field and load a boolean primitive value.
1455 */
1456 .extern artGetBooleanStaticFromCode
1457ENTRY art_quick_get_boolean_static
Douglas Leung735b8552014-10-31 12:21:40 -07001458 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001459 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001460 la $t9, artGetBooleanStaticFromCode
1461 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001462 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001463 RETURN_IF_NO_EXCEPTION
1464END art_quick_get_boolean_static
1465 /*
1466 * Called by managed code to resolve a static field and load a byte primitive value.
1467 */
1468 .extern artGetByteStaticFromCode
1469ENTRY art_quick_get_byte_static
Douglas Leung735b8552014-10-31 12:21:40 -07001470 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001471 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001472 la $t9, artGetByteStaticFromCode
1473 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001474 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001475 RETURN_IF_NO_EXCEPTION
1476END art_quick_get_byte_static
1477
1478 /*
1479 * Called by managed code to resolve a static field and load a char primitive value.
1480 */
1481 .extern artGetCharStaticFromCode
1482ENTRY art_quick_get_char_static
Douglas Leung735b8552014-10-31 12:21:40 -07001483 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001484 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001485 la $t9, artGetCharStaticFromCode
1486 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001487 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001488 RETURN_IF_NO_EXCEPTION
1489END art_quick_get_char_static
1490 /*
1491 * Called by managed code to resolve a static field and load a short primitive value.
1492 */
1493 .extern artGetShortStaticFromCode
1494ENTRY art_quick_get_short_static
Douglas Leung735b8552014-10-31 12:21:40 -07001495 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001496 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001497 la $t9, artGetShortStaticFromCode
1498 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001499 move $a2, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001500 RETURN_IF_NO_EXCEPTION
1501END art_quick_get_short_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001502
buzbee5bc5a7b2012-03-07 15:52:59 -08001503 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001504 * Called by managed code to resolve a static field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001505 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001506 .extern artGet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001507ENTRY art_quick_get32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001508 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001509 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001510 la $t9, artGet32StaticFromCode
1511 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001512 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001513 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001514END art_quick_get32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001515
buzbee5bc5a7b2012-03-07 15:52:59 -08001516 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001517 * Called by managed code to resolve a static field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001518 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001519 .extern artGet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001520ENTRY art_quick_get64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001521 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001522 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001523 la $t9, artGet64StaticFromCode
1524 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001525 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001526 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001527END art_quick_get64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001528
buzbee5bc5a7b2012-03-07 15:52:59 -08001529 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001530 * Called by managed code to resolve a static field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001531 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001532 .extern artGetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001533ENTRY art_quick_get_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001534 lw $a1, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001535 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001536 la $t9, artGetObjStaticFromCode
1537 jalr $t9 # (uint32_t field_idx, const Method* referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001538 move $a2, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001539 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001540END art_quick_get_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001541
buzbee5bc5a7b2012-03-07 15:52:59 -08001542 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001543 * Called by managed code to resolve an instance field and load a boolean primitive value.
1544 */
1545 .extern artGetBooleanInstanceFromCode
1546ENTRY art_quick_get_boolean_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001547 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001548 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001549 la $t9, artGetBooleanInstanceFromCode
1550 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001551 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001552 RETURN_IF_NO_EXCEPTION
1553END art_quick_get_boolean_instance
1554 /*
1555 * Called by managed code to resolve an instance field and load a byte primitive value.
1556 */
1557 .extern artGetByteInstanceFromCode
1558ENTRY art_quick_get_byte_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001559 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001560 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001561 la $t9, artGetByteInstanceFromCode
1562 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001563 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001564 RETURN_IF_NO_EXCEPTION
1565END art_quick_get_byte_instance
1566
1567 /*
1568 * Called by managed code to resolve an instance field and load a char primitive value.
1569 */
1570 .extern artGetCharInstanceFromCode
1571ENTRY art_quick_get_char_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001572 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001573 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001574 la $t9, artGetCharInstanceFromCode
1575 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001576 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001577 RETURN_IF_NO_EXCEPTION
1578END art_quick_get_char_instance
1579 /*
1580 * Called by managed code to resolve an instance field and load a short primitive value.
1581 */
1582 .extern artGetShortInstanceFromCode
1583ENTRY art_quick_get_short_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001584 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001585 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001586 la $t9, artGetShortInstanceFromCode
1587 jalr $t9 # (field_idx, Object*, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001588 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001589 RETURN_IF_NO_EXCEPTION
1590END art_quick_get_short_instance
1591
1592 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001593 * Called by managed code to resolve an instance field and load a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001594 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001595 .extern artGet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001596ENTRY art_quick_get32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001597 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001598 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001599 la $t9, artGet32InstanceFromCode
1600 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001601 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001602 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001603END art_quick_get32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001604
buzbee5bc5a7b2012-03-07 15:52:59 -08001605 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001606 * Called by managed code to resolve an instance field and load a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001607 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001608 .extern artGet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001609ENTRY art_quick_get64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001610 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001611 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001612 la $t9, artGet64InstanceFromCode
1613 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001614 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001615 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001616END art_quick_get64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001617
buzbee5bc5a7b2012-03-07 15:52:59 -08001618 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001619 * Called by managed code to resolve an instance field and load an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001620 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001621 .extern artGetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001622ENTRY art_quick_get_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001623 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001624 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001625 la $t9, artGetObjInstanceFromCode
1626 jalr $t9 # (field_idx, Object*, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001627 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001628 RETURN_IF_NO_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07001629END art_quick_get_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001630
buzbee5bc5a7b2012-03-07 15:52:59 -08001631 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001632 * Called by managed code to resolve a static field and store a 8-bit primitive value.
1633 */
1634 .extern artSet8StaticFromCode
1635ENTRY art_quick_set8_static
Douglas Leung735b8552014-10-31 12:21:40 -07001636 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001637 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001638 la $t9, artSet8StaticFromCode
1639 jalr $t9 # (field_idx, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001640 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001641 RETURN_IF_ZERO
1642END art_quick_set8_static
1643
1644 /*
1645 * Called by managed code to resolve a static field and store a 16-bit primitive value.
1646 */
1647 .extern artSet16StaticFromCode
1648ENTRY art_quick_set16_static
Douglas Leung735b8552014-10-31 12:21:40 -07001649 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001650 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001651 la $t9, artSet16StaticFromCode
1652 jalr $t9 # (field_idx, new_val, referrer, Thread*, $sp)
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001653 move $a3, rSELF # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001654 RETURN_IF_ZERO
1655END art_quick_set16_static
1656
1657 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001658 * Called by managed code to resolve a static field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001659 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001660 .extern artSet32StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001661ENTRY art_quick_set32_static
Douglas Leung735b8552014-10-31 12:21:40 -07001662 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001663 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001664 la $t9, artSet32StaticFromCode
1665 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001666 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001667 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001668END art_quick_set32_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001669
buzbee5bc5a7b2012-03-07 15:52:59 -08001670 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001671 * Called by managed code to resolve a static field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001672 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001673 .extern artSet64StaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001674ENTRY art_quick_set64_static
Douglas Leung735b8552014-10-31 12:21:40 -07001675 lw $a1, 0($sp) # pass referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001676 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001677 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001678 la $t9, artSet64StaticFromCode
1679 jalr $t9 # (field_idx, referrer, new_val, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001680 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001681 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001682END art_quick_set64_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001683
buzbee5bc5a7b2012-03-07 15:52:59 -08001684 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001685 * Called by managed code to resolve a static field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001686 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001687 .extern artSetObjStaticFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001688ENTRY art_quick_set_obj_static
Douglas Leung735b8552014-10-31 12:21:40 -07001689 lw $a2, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001690 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001691 la $t9, artSetObjStaticFromCode
1692 jalr $t9 # (field_idx, new_val, referrer, Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001693 move $a3, rSELF # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001694 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001695END art_quick_set_obj_static
buzbee5bc5a7b2012-03-07 15:52:59 -08001696
buzbee5bc5a7b2012-03-07 15:52:59 -08001697 /*
Fred Shih37f05ef2014-07-16 18:38:08 -07001698 * Called by managed code to resolve an instance field and store a 8-bit primitive value.
1699 */
1700 .extern artSet8InstanceFromCode
1701ENTRY art_quick_set8_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001702 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001703 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001704 la $t9, artSet8InstanceFromCode
1705 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001706 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001707 RETURN_IF_ZERO
1708END art_quick_set8_instance
1709
1710 /*
1711 * Called by managed code to resolve an instance field and store a 16-bit primitive value.
1712 */
1713 .extern artSet16InstanceFromCode
1714ENTRY art_quick_set16_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001715 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001716 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001717 la $t9, artSet16InstanceFromCode
1718 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Fred Shih37f05ef2014-07-16 18:38:08 -07001719 sw rSELF, 16($sp) # pass Thread::Current
Fred Shih37f05ef2014-07-16 18:38:08 -07001720 RETURN_IF_ZERO
1721END art_quick_set16_instance
1722
1723 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001724 * Called by managed code to resolve an instance field and store a 32-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001725 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001726 .extern artSet32InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001727ENTRY art_quick_set32_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001728 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001729 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001730 la $t9, artSet32InstanceFromCode
1731 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001732 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001733 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001734END art_quick_set32_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001735
buzbee5bc5a7b2012-03-07 15:52:59 -08001736 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001737 * Called by managed code to resolve an instance field and store a 64-bit primitive value.
buzbee5bc5a7b2012-03-07 15:52:59 -08001738 */
Fred Shih37f05ef2014-07-16 18:38:08 -07001739 .extern artSet64InstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001740ENTRY art_quick_set64_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001741 lw $t1, 0($sp) # load referrer's Method*
Andreas Gampe8d365912015-01-13 11:32:32 -08001742 # 64 bit new_val is in a2:a3 pair
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001743 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001744 sw rSELF, 20($sp) # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001745 la $t9, artSet64InstanceFromCode
1746 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
Douglas Leung735b8552014-10-31 12:21:40 -07001747 sw $t1, 16($sp) # pass referrer's Method*
buzbee5bc5a7b2012-03-07 15:52:59 -08001748 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001749END art_quick_set64_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001750
buzbee5bc5a7b2012-03-07 15:52:59 -08001751 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001752 * Called by managed code to resolve an instance field and store an object reference.
buzbee5bc5a7b2012-03-07 15:52:59 -08001753 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001754 .extern artSetObjInstanceFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07001755ENTRY art_quick_set_obj_instance
Douglas Leung735b8552014-10-31 12:21:40 -07001756 lw $a3, 0($sp) # pass referrer's Method*
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001757 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001758 la $t9, artSetObjInstanceFromCode
1759 jalr $t9 # (field_idx, Object*, new_val, referrer, Thread*)
jeffhaofa147e22012-10-12 17:03:32 -07001760 sw rSELF, 16($sp) # pass Thread::Current
buzbee5bc5a7b2012-03-07 15:52:59 -08001761 RETURN_IF_ZERO
Ian Rogers468532e2013-08-05 10:56:33 -07001762END art_quick_set_obj_instance
buzbee5bc5a7b2012-03-07 15:52:59 -08001763
Vladimir Markoa3c38272015-04-28 12:37:09 +01001764// Macro to facilitate adding new allocation entrypoints.
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001765.macro ONE_ARG_DOWNCALL name, entrypoint, return
1766 .extern \entrypoint
1767ENTRY \name
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001768 SETUP_SAVE_REFS_ONLY_FRAME # save callee saves in case of GC
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001769 la $t9, \entrypoint
1770 jalr $t9
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001771 move $a1, rSELF # pass Thread::Current
1772 \return
1773END \name
1774.endm
1775
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001776.macro TWO_ARG_DOWNCALL name, entrypoint, return
1777 .extern \entrypoint
1778ENTRY \name
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, \entrypoint
1781 jalr $t9
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001782 move $a2, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001783 \return
1784END \name
1785.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001786
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001787.macro THREE_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
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07001793 move $a3, rSELF # pass Thread::Current
Mathieu Chartiercbb2d202013-11-14 17:45:16 -08001794 \return
1795END \name
1796.endm
buzbee5bc5a7b2012-03-07 15:52:59 -08001797
Jeff Hao848f70a2014-01-15 13:49:50 -08001798.macro FOUR_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
Vladimir Markoa3c38272015-04-28 12:37:09 +01001804 sw rSELF, 16($sp) # pass Thread::Current
Jeff Hao848f70a2014-01-15 13:49:50 -08001805 \return
1806END \name
1807.endm
1808
Mathieu Chartier7410f292013-11-24 13:17:35 -08001809// Generate the allocation entrypoints for each allocator.
Pavle Batuta712c59d2015-12-02 18:39:01 +01001810GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001811
Pavle Batuta712c59d2015-12-02 18:39:01 +01001812
Nicolas Geoffray0d3998b2017-01-12 15:35:12 +00001813GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc, RosAlloc)
1814GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB)
1815GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_region_tlab, RegionTLAB)
Hiroshi Yamauchi10d4c082016-02-24 12:51:18 -08001816
buzbee5bc5a7b2012-03-07 15:52:59 -08001817 /*
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001818 * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001819 * exception on error. On success the String is returned. A0 holds the string index. The fast
1820 * path check for hit in strings cache has already been performed.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001821 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001822ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001823
1824 /*
1825 * Entry from managed code when uninitialized static storage, this stub will run the class
1826 * initializer and deliver the exception on error. On success the static storage base is
1827 * returned.
1828 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001829ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001830
1831 /*
1832 * Entry from managed code when dex cache misses for a type_idx.
1833 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001834ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001835
1836 /*
1837 * Entry from managed code when type_idx needs to be checked for access and dex cache may also
1838 * miss.
1839 */
Vladimir Marko5ea536a2015-04-20 20:11:30 +01001840ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
Andreas Gampe1cc7dba2014-12-17 18:43:01 -08001841
1842 /*
Ian Rogers57b86d42012-03-27 16:05:41 -07001843 * Called by managed code when the value in rSUSPEND has been decremented to 0.
buzbee5bc5a7b2012-03-07 15:52:59 -08001844 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001845 .extern artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001846ENTRY_NO_GP art_quick_test_suspend
1847 lh rSUSPEND, THREAD_FLAGS_OFFSET(rSELF)
1848 bnez rSUSPEND, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001849 addiu rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
Andreas Gampe8d365912015-01-13 11:32:32 -08001850 jalr $zero, $ra
buzbee5bc5a7b2012-03-07 15:52:59 -08001851 nop
18521:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001853 SETUP_SAVE_EVERYTHING_FRAME # save everything for stack crawl
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001854 la $t9, artTestSuspendFromCode
Vladimir Marko952dbb12016-07-28 12:01:51 +01001855 jalr $t9 # (Thread*)
jeffhao7fbee072012-08-24 17:56:54 -07001856 move $a0, rSELF
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001857 RESTORE_SAVE_EVERYTHING_FRAME
Vladimir Marko952dbb12016-07-28 12:01:51 +01001858 jalr $zero, $ra
1859 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001860END art_quick_test_suspend
buzbee5bc5a7b2012-03-07 15:52:59 -08001861
buzbee5bc5a7b2012-03-07 15:52:59 -08001862 /*
1863 * Called by managed code that is attempting to call a method on a proxy class. On entry
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001864 * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
buzbee5bc5a7b2012-03-07 15:52:59 -08001865 */
Jeff Hao5fa60c32013-04-04 17:57:01 -07001866 .extern artQuickProxyInvokeHandler
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001867ENTRY art_quick_proxy_invoke_handler
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001868 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001869 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001870 la $t9, artQuickProxyInvokeHandler
1871 jalr $t9 # (Method* proxy method, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001872 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001873 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001874 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001875 bnez $t7, 1f
Duane Sande34652f2014-11-04 11:09:36 -08001876 # don't care if $v0 and/or $v1 are modified, when exception branch taken
1877 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08001878 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08001879 nop
buzbee5bc5a7b2012-03-07 15:52:59 -080018801:
1881 DELIVER_PENDING_EXCEPTION
Jeff Haod4c3f7d2013-02-14 14:14:44 -08001882END art_quick_proxy_invoke_handler
buzbee5bc5a7b2012-03-07 15:52:59 -08001883
Jeff Hao88474b42013-10-23 16:24:40 -07001884 /*
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001885 * Called to resolve an imt conflict.
1886 * a0 is the conflict ArtMethod.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001887 * t7 is a hidden argument that holds the target interface method's dex method index.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001888 *
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001889 * Note that this stub writes to a0, t7 and t8.
Jeff Hao88474b42013-10-23 16:24:40 -07001890 */
Douglas Leung13738bf2014-10-27 14:44:47 -07001891ENTRY art_quick_imt_conflict_trampoline
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001892 lw $t8, 0($sp) # Load referrer.
1893 lw $t8, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t8) # Load dex cache methods array.
1894 sll $t7, $t7, POINTER_SIZE_SHIFT # Calculate offset.
1895 addu $t7, $t8, $t7 # Add offset to base.
1896 lw $t7, 0($t7) # Load interface method.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001897 lw $a0, ART_METHOD_JNI_OFFSET_32($a0) # Load ImtConflictTable.
1898
1899.Limt_table_iterate:
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001900 lw $t8, 0($a0) # Load next entry in ImtConflictTable.
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001901 # Branch if found.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001902 beq $t8, $t7, .Limt_table_found
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001903 nop
1904 # If the entry is null, the interface method is not in the ImtConflictTable.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001905 beqz $t8, .Lconflict_trampoline
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001906 nop
1907 # Iterate over the entries of the ImtConflictTable.
1908 b .Limt_table_iterate
1909 addiu $a0, $a0, 2 * __SIZEOF_POINTER__ # Iterate to the next entry.
1910
1911.Limt_table_found:
1912 # We successfully hit an entry in the table. Load the target method and jump to it.
1913 lw $a0, __SIZEOF_POINTER__($a0)
1914 lw $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001915 jalr $zero, $t9
Goran Jakovljevic59028d92016-03-29 18:05:03 +02001916 nop
1917
1918.Lconflict_trampoline:
1919 # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
Andreas Gampe3031c8d2015-07-13 20:11:06 -07001920 INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
Jeff Hao88474b42013-10-23 16:24:40 -07001921END art_quick_imt_conflict_trampoline
1922
Ian Rogers468532e2013-08-05 10:56:33 -07001923 .extern artQuickResolutionTrampoline
1924ENTRY art_quick_resolution_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001925 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07001926 move $a2, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001927 la $t9, artQuickResolutionTrampoline
1928 jalr $t9 # (Method* called, receiver, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001929 addiu $a3, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Ian Rogers468532e2013-08-05 10:56:33 -07001930 beqz $v0, 1f
Douglas Leung735b8552014-10-31 12:21:40 -07001931 lw $a0, ARG_SLOT_SIZE($sp) # load resolved method to $a0
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001932 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers65d1b222013-09-27 10:59:41 -07001933 move $t9, $v0 # code pointer must be in $t9 to generate the global pointer
Douglas Leungf96e8bd2015-03-27 15:38:30 -07001934 jalr $zero, $t9 # tail call to method
Mathieu Chartier19841522013-10-22 11:29:00 -07001935 nop
Ian Rogers468532e2013-08-05 10:56:33 -070019361:
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001937 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Ian Rogers468532e2013-08-05 10:56:33 -07001938 DELIVER_PENDING_EXCEPTION
1939END art_quick_resolution_trampoline
1940
Douglas Leung735b8552014-10-31 12:21:40 -07001941 .extern artQuickGenericJniTrampoline
1942 .extern artQuickGenericJniEndTrampoline
1943ENTRY art_quick_generic_jni_trampoline
Vladimir Markofd36f1f2016-08-03 18:49:58 +01001944 SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_A0
Douglas Leung735b8552014-10-31 12:21:40 -07001945 move $s8, $sp # save $sp to $s8
1946 move $s3, $gp # save $gp to $s3
1947
1948 # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1949 move $a0, rSELF # pass Thread::Current
1950 addiu $a1, $sp, ARG_SLOT_SIZE # save $sp (remove arg slots)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001951 la $t9, artQuickGenericJniTrampoline
1952 jalr $t9 # (Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07001953 addiu $sp, $sp, -5120 # reserve space on the stack
1954
1955 # The C call will have registered the complete save-frame on success.
1956 # The result of the call is:
1957 # v0: ptr to native code, 0 on error.
1958 # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001959 beq $v0, $zero, 2f # check entry error
Douglas Leung735b8552014-10-31 12:21:40 -07001960 move $t9, $v0 # save the code ptr
1961 move $sp, $v1 # release part of the alloca
1962
1963 # Load parameters from stack into registers
1964 lw $a0, 0($sp)
1965 lw $a1, 4($sp)
1966 lw $a2, 8($sp)
Douglas Leung735b8552014-10-31 12:21:40 -07001967 lw $a3, 12($sp)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001968
1969 # artQuickGenericJniTrampoline sets bit 0 of the native code address to 1
1970 # when the first two arguments are both single precision floats. This lets
1971 # us extract them properly from the stack and load into floating point
1972 # registers.
1973 MTD $a0, $a1, $f12, $f13
1974 andi $t0, $t9, 1
1975 xor $t9, $t9, $t0
1976 bnez $t0, 1f
1977 mtc1 $a1, $f14
1978 MTD $a2, $a3, $f14, $f15
1979
19801:
1981 jalr $t9 # native call
1982 nop
Douglas Leung735b8552014-10-31 12:21:40 -07001983 addiu $sp, $sp, 16 # remove arg slots
1984
1985 move $gp, $s3 # restore $gp from $s3
1986
1987 # result sign extension is handled in C code
1988 # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1989 move $a0, rSELF # pass Thread::Current
1990 move $a2, $v0 # pass result
1991 move $a3, $v1
1992 addiu $sp, $sp, -24 # reserve arg slots
Goran Jakovljevic590b1362016-03-21 14:24:43 +01001993 la $t9, artQuickGenericJniEndTrampoline
1994 jalr $t9
Douglas Leung735b8552014-10-31 12:21:40 -07001995 s.d $f0, 16($sp) # pass result_f
Douglas Leung735b8552014-10-31 12:21:40 -07001996
1997 lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Alexey Frunze1b8464d2016-11-12 17:22:05 -08001998 bne $t0, $zero, 2f # check for pending exceptions
Nicolas Geoffray126d6592015-03-03 14:28:35 +00001999
Douglas Leung735b8552014-10-31 12:21:40 -07002000 move $sp, $s8 # tear down the alloca
2001
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002002 # tear down the callee-save frame
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002003 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002004
Duane Sande34652f2014-11-04 11:09:36 -08002005 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002006 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002007 nop
Douglas Leung735b8552014-10-31 12:21:40 -07002008
Alexey Frunze1b8464d2016-11-12 17:22:05 -080020092:
Nicolas Geoffray126d6592015-03-03 14:28:35 +00002010 lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
2011 # This will create a new save-all frame, required by the runtime.
Douglas Leung735b8552014-10-31 12:21:40 -07002012 DELIVER_PENDING_EXCEPTION
2013END art_quick_generic_jni_trampoline
Andreas Gampe2da88232014-02-27 12:26:20 -08002014
Ian Rogers468532e2013-08-05 10:56:33 -07002015 .extern artQuickToInterpreterBridge
2016ENTRY art_quick_to_interpreter_bridge
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002017 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002018 move $a1, rSELF # pass Thread::Current
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002019 la $t9, artQuickToInterpreterBridge
2020 jalr $t9 # (Method* method, Thread*, SP)
Douglas Leung735b8552014-10-31 12:21:40 -07002021 addiu $a2, $sp, ARG_SLOT_SIZE # pass $sp (remove arg slots)
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002022 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002023 RESTORE_SAVE_REFS_AND_ARGS_FRAME
Alexey Frunze1b8464d2016-11-12 17:22:05 -08002024 bnez $t7, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002025 # don't care if $v0 and/or $v1 are modified, when exception branch taken
2026 MTD $v0, $v1, $f0, $f1 # move float value to return value
Andreas Gampe8d365912015-01-13 11:32:32 -08002027 jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002028 nop
Ian Rogers7db619b2013-01-16 18:35:48 -080020291:
2030 DELIVER_PENDING_EXCEPTION
Ian Rogers468532e2013-08-05 10:56:33 -07002031END art_quick_to_interpreter_bridge
Ian Rogers7db619b2013-01-16 18:35:48 -08002032
buzbee5bc5a7b2012-03-07 15:52:59 -08002033 /*
jeffhao725a9572012-11-13 18:20:12 -08002034 * Routine that intercepts method calls and returns.
buzbee5bc5a7b2012-03-07 15:52:59 -08002035 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002036 .extern artInstrumentationMethodEntryFromCode
2037 .extern artInstrumentationMethodExitFromCode
Ian Rogers468532e2013-08-05 10:56:33 -07002038ENTRY art_quick_instrumentation_entry
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002039 SETUP_SAVE_REFS_AND_ARGS_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002040 sw $a0, 28($sp) # save arg0 in free arg slot
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002041 move $a3, $ra # pass $ra
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002042 la $t9, artInstrumentationMethodEntryFromCode
2043 jalr $t9 # (Method*, Object*, Thread*, LR)
Ian Rogers62d6c772013-02-27 08:32:07 -08002044 move $a2, rSELF # pass Thread::Current
jeffhao8161c032012-10-31 15:50:00 -07002045 move $t9, $v0 # $t9 holds reference to code
Douglas Leung735b8552014-10-31 12:21:40 -07002046 lw $a0, 28($sp) # restore arg0 from free arg slot
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002047 RESTORE_SAVE_REFS_AND_ARGS_FRAME
jeffhao8161c032012-10-31 15:50:00 -07002048 jalr $t9 # call method
Ian Rogers62d6c772013-02-27 08:32:07 -08002049 nop
Ian Rogers468532e2013-08-05 10:56:33 -07002050END art_quick_instrumentation_entry
buzbee5bc5a7b2012-03-07 15:52:59 -08002051 /* intentional fallthrough */
Ian Rogers468532e2013-08-05 10:56:33 -07002052 .global art_quick_instrumentation_exit
2053art_quick_instrumentation_exit:
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002054 .cfi_startproc
jeffhao12051ea2013-01-10 11:24:31 -08002055 addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002056 .cpload $t9
Douglas Leungc3d131e2014-07-16 17:32:41 -07002057 move $ra, $zero # link register is to here, so clobber with 0 for later checks
Douglas Leung735b8552014-10-31 12:21:40 -07002058
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002059 SETUP_SAVE_REFS_ONLY_FRAME
Douglas Leung735b8552014-10-31 12:21:40 -07002060 addiu $sp, $sp, -16 # allocate temp storage on the stack
2061 .cfi_adjust_cfa_offset 16
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002062 sw $v0, ARG_SLOT_SIZE+12($sp)
2063 .cfi_rel_offset 2, ARG_SLOT_SIZE+12
2064 sw $v1, ARG_SLOT_SIZE+8($sp)
2065 .cfi_rel_offset 3, ARG_SLOT_SIZE+8
2066 s.d $f0, ARG_SLOT_SIZE($sp)
Duane Sande34652f2014-11-04 11:09:36 -08002067 s.d $f0, 16($sp) # pass fpr result
Ian Rogers62d6c772013-02-27 08:32:07 -08002068 move $a2, $v0 # pass gpr result
2069 move $a3, $v1
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002070 addiu $a1, $sp, ARG_SLOT_SIZE+16 # pass $sp (remove arg slots and temp storage)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002071 la $t9, artInstrumentationMethodExitFromCode
2072 jalr $t9 # (Thread*, SP, gpr_res, fpr_res)
jeffhao12051ea2013-01-10 11:24:31 -08002073 move $a0, rSELF # pass Thread::Current
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002074 move $t9, $v0 # set aside returned link register
jeffhao12051ea2013-01-10 11:24:31 -08002075 move $ra, $v1 # set link register for deoptimization
Douglas Leungf96e8bd2015-03-27 15:38:30 -07002076 lw $v0, ARG_SLOT_SIZE+12($sp) # restore return values
2077 lw $v1, ARG_SLOT_SIZE+8($sp)
2078 l.d $f0, ARG_SLOT_SIZE($sp)
2079 jalr $zero, $t9 # return
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002080 addiu $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16 # restore stack
2081 .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_SAVE_REFS_ONLY+16)
Ian Rogers468532e2013-08-05 10:56:33 -07002082END art_quick_instrumentation_exit
buzbee5bc5a7b2012-03-07 15:52:59 -08002083
jeffhao12051ea2013-01-10 11:24:31 -08002084 /*
Ian Rogers62d6c772013-02-27 08:32:07 -08002085 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
2086 * will long jump to the upcall with a special exception of -1.
jeffhao12051ea2013-01-10 11:24:31 -08002087 */
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002088 .extern artDeoptimize
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002089ENTRY art_quick_deoptimize
Vladimir Markofd36f1f2016-08-03 18:49:58 +01002090 SETUP_SAVE_ALL_CALLEE_SAVES_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002091 la $t9, artDeoptimize
2092 jalr $t9 # artDeoptimize(Thread*)
jeffhao12051ea2013-01-10 11:24:31 -08002093 # Returns caller method's frame size.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002094 move $a0, rSELF # pass Thread::current
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002095END art_quick_deoptimize
jeffhao12051ea2013-01-10 11:24:31 -08002096
buzbee5bc5a7b2012-03-07 15:52:59 -08002097 /*
Sebastien Hertz07474662015-08-25 15:12:33 +00002098 * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
2099 * will long jump to the upcall with a special exception of -1.
2100 */
2101 .extern artDeoptimizeFromCompiledCode
2102ENTRY art_quick_deoptimize_from_compiled_code
Vladimir Marko239d6ea2016-09-05 10:44:04 +01002103 SETUP_SAVE_EVERYTHING_FRAME
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002104 la $t9, artDeoptimizeFromCompiledCode
2105 jalr $t9 # artDeoptimizeFromCompiledCode(Thread*)
Sebastien Hertz07474662015-08-25 15:12:33 +00002106 # Returns caller method's frame size.
2107 move $a0, rSELF # pass Thread::current
2108END art_quick_deoptimize_from_compiled_code
2109
2110 /*
buzbee5bc5a7b2012-03-07 15:52:59 -08002111 * Long integer shift. This is different from the generic 32/64-bit
2112 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2113 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2114 * 6 bits.
2115 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002116 * $a0: low word
2117 * $a1: high word
2118 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002119 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002120ENTRY_NO_GP art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002121 /* shl-long vAA, vBB, vCC */
jeffhao7fbee072012-08-24 17:56:54 -07002122 sll $v0, $a0, $a2 # rlo<- alo << (shift&31)
2123 not $v1, $a2 # rhi<- 31-shift (shift is 5b)
2124 srl $a0, 1
2125 srl $a0, $v1 # alo<- alo >> (32-(shift&31))
2126 sll $v1, $a1, $a2 # rhi<- ahi << (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002127 andi $a2, 0x20 # shift< shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002128 beqz $a2, 1f
2129 or $v1, $a0 # rhi<- rhi | alo
2130
2131 move $v1, $v0 # rhi<- rlo (if shift&0x20)
2132 move $v0, $zero # rlo<- 0 (if shift&0x20)
2133
Andreas Gampe8d365912015-01-13 11:32:32 -080021341: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002135 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002136END art_quick_shl_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002137
buzbee5bc5a7b2012-03-07 15:52:59 -08002138 /*
2139 * Long integer shift. This is different from the generic 32/64-bit
2140 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2141 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2142 * 6 bits.
2143 * On entry:
jeffhao7fbee072012-08-24 17:56:54 -07002144 * $a0: low word
2145 * $a1: high word
2146 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002147 */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002148ENTRY_NO_GP art_quick_shr_long
jeffhao7fbee072012-08-24 17:56:54 -07002149 sra $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
2150 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
2151 sra $a3, $a1, 31 # $a3<- sign(ah)
2152 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2153 sll $a1, 1
2154 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002155 andi $a2, 0x20 # shift & 0x20
Douglas Leung475cfd82014-12-16 20:15:41 -08002156 beqz $a2, 1f
Duane Sande34652f2014-11-04 11:09:36 -08002157 or $v0, $a1 # rlo<- rlo | ahi
2158
2159 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2160 move $v1, $a3 # rhi<- sign(ahi) (if shift&0x20)
2161
Andreas Gampe8d365912015-01-13 11:32:32 -080021621: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002163 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002164END art_quick_shr_long
buzbee5bc5a7b2012-03-07 15:52:59 -08002165
buzbee5bc5a7b2012-03-07 15:52:59 -08002166 /*
2167 * Long integer shift. This is different from the generic 32/64-bit
2168 * binary operations because vAA/vBB are 64-bit but vCC (the shift
2169 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
2170 * 6 bits.
2171 * On entry:
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002172 * $a0: low word
2173 * $a1: high word
2174 * $a2: shift count
buzbee5bc5a7b2012-03-07 15:52:59 -08002175 */
2176 /* ushr-long vAA, vBB, vCC */
Ian Rogers1d8cdbc2014-09-22 22:51:09 -07002177ENTRY_NO_GP art_quick_ushr_long
jeffhaofc6a30e2012-10-18 18:24:15 -07002178 srl $v1, $a1, $a2 # rhi<- ahi >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002179 srl $v0, $a0, $a2 # rlo<- alo >> (shift&31)
jeffhao7fbee072012-08-24 17:56:54 -07002180 not $a0, $a2 # alo<- 31-shift (shift is 5b)
2181 sll $a1, 1
2182 sll $a1, $a0 # ahi<- ahi << (32-(shift&31))
jeffhao7fbee072012-08-24 17:56:54 -07002183 andi $a2, 0x20 # shift & 0x20
Duane Sande34652f2014-11-04 11:09:36 -08002184 beqz $a2, 1f
2185 or $v0, $a1 # rlo<- rlo | ahi
2186
2187 move $v0, $v1 # rlo<- rhi (if shift&0x20)
2188 move $v1, $zero # rhi<- 0 (if shift&0x20)
2189
Andreas Gampe8d365912015-01-13 11:32:32 -080021901: jalr $zero, $ra
Duane Sande34652f2014-11-04 11:09:36 -08002191 nop
Jeff Haod4c3f7d2013-02-14 14:14:44 -08002192END art_quick_ushr_long
jeffhao7fbee072012-08-24 17:56:54 -07002193
Chris Larsencf283da2016-01-19 16:45:35 -08002194/* java.lang.String.indexOf(int ch, int fromIndex=0) */
2195ENTRY_NO_GP art_quick_indexof
2196/* $a0 holds address of "this" */
2197/* $a1 holds "ch" */
2198/* $a2 holds "fromIndex" */
2199 lw $t0, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002200 slt $t1, $a2, $zero # if fromIndex < 0
Chris Larsencf283da2016-01-19 16:45:35 -08002201#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002202 seleqz $a2, $a2, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002203#else
Goran Jakovljevic590b1362016-03-21 14:24:43 +01002204 movn $a2, $zero, $t1 # fromIndex = 0;
Chris Larsencf283da2016-01-19 16:45:35 -08002205#endif
2206 subu $t0, $t0, $a2 # this.length() - fromIndex
2207 blez $t0, 6f # if this.length()-fromIndex <= 0
2208 li $v0, -1 # return -1;
2209
2210 sll $v0, $a2, 1 # $a0 += $a2 * 2
Orion Hodsonac141392017-01-13 11:53:47 +00002211 addu $a0, $a0, $v0 # " ditto "
Chris Larsencf283da2016-01-19 16:45:35 -08002212 move $v0, $a2 # Set i to fromIndex.
2213
22141:
2215 lhu $t3, MIRROR_STRING_VALUE_OFFSET($a0) # if this.charAt(i) == ch
2216 beq $t3, $a1, 6f # return i;
2217 addu $a0, $a0, 2 # i++
2218 subu $t0, $t0, 1 # this.length() - i
2219 bnez $t0, 1b # while this.length() - i > 0
2220 addu $v0, $v0, 1 # i++
2221
2222 li $v0, -1 # if this.length() - i <= 0
2223 # return -1;
2224
22256:
2226 j $ra
2227 nop
2228END art_quick_indexof
2229
Chris Larsencf283da2016-01-19 16:45:35 -08002230/* java.lang.String.compareTo(String anotherString) */
2231ENTRY_NO_GP art_quick_string_compareto
2232/* $a0 holds address of "this" */
2233/* $a1 holds address of "anotherString" */
2234 beq $a0, $a1, 9f # this and anotherString are the same object
2235 move $v0, $zero
2236
2237 lw $a2, MIRROR_STRING_COUNT_OFFSET($a0) # this.length()
2238 lw $a3, MIRROR_STRING_COUNT_OFFSET($a1) # anotherString.length()
2239 MINu $t2, $a2, $a3
2240# $t2 now holds min(this.length(),anotherString.length())
2241
2242 beqz $t2, 9f # while min(this.length(),anotherString.length())-i != 0
2243 subu $v0, $a2, $a3 # if $t2==0 return
2244 # (this.length() - anotherString.length())
22451:
2246 lhu $t0, MIRROR_STRING_VALUE_OFFSET($a0) # while this.charAt(i) == anotherString.charAt(i)
2247 lhu $t1, MIRROR_STRING_VALUE_OFFSET($a1)
2248 bne $t0, $t1, 9f # if this.charAt(i) != anotherString.charAt(i)
2249 subu $v0, $t0, $t1 # return (this.charAt(i) - anotherString.charAt(i))
2250 addiu $a0, $a0, 2 # point at this.charAt(i++)
2251 subu $t2, $t2, 1 # new value of
2252 # min(this.length(),anotherString.length())-i
2253 bnez $t2, 1b
2254 addiu $a1, $a1, 2 # point at anotherString.charAt(i++)
2255 subu $v0, $a2, $a3
2256
22579:
2258 j $ra
2259 nop
2260END art_quick_string_compareto
Orion Hodsonac141392017-01-13 11:53:47 +00002261
2262.extern artInvokePolymorphic
2263ENTRY art_quick_invoke_polymorphic
2264 SETUP_SAVE_REFS_AND_ARGS_FRAME
2265 move $a2, rSELF # Make $a2 an alias for the current Thread.
Alexey Frunzec480b982017-01-16 19:03:21 -08002266 addiu $a3, $sp, ARG_SLOT_SIZE # Make $a3 a pointer to the saved frame context.
Orion Hodsonac141392017-01-13 11:53:47 +00002267 sw $zero, 20($sp) # Initialize JValue result.
2268 sw $zero, 16($sp)
Orion Hodsonac141392017-01-13 11:53:47 +00002269 la $t9, artInvokePolymorphic
2270 jalr $t9 # (result, receiver, Thread*, context)
Alexey Frunzec480b982017-01-16 19:03:21 -08002271 addiu $a0, $sp, 16 # Make $a0 a pointer to the JValue result
Orion Hodsonac141392017-01-13 11:53:47 +00002272.macro MATCH_RETURN_TYPE c, handler
2273 li $t0, \c
2274 beq $v0, $t0, \handler
2275.endm
2276 MATCH_RETURN_TYPE 'V', .Lcleanup_and_return
2277 MATCH_RETURN_TYPE 'L', .Lstore_int_result
2278 MATCH_RETURN_TYPE 'I', .Lstore_int_result
2279 MATCH_RETURN_TYPE 'J', .Lstore_long_result
2280 MATCH_RETURN_TYPE 'B', .Lstore_int_result
2281 MATCH_RETURN_TYPE 'C', .Lstore_char_result
2282 MATCH_RETURN_TYPE 'D', .Lstore_double_result
2283 MATCH_RETURN_TYPE 'F', .Lstore_float_result
2284 MATCH_RETURN_TYPE 'S', .Lstore_int_result
Alexey Frunzec480b982017-01-16 19:03:21 -08002285 MATCH_RETURN_TYPE 'Z', .Lstore_boolean_result
Orion Hodsonac141392017-01-13 11:53:47 +00002286.purgem MATCH_RETURN_TYPE
2287 nop
2288 b .Lcleanup_and_return
2289 nop
2290.Lstore_boolean_result:
Alexey Frunzec480b982017-01-16 19:03:21 -08002291 b .Lcleanup_and_return
Orion Hodsonac141392017-01-13 11:53:47 +00002292 lbu $v0, 16($sp) # Move byte from JValue result to return value register.
Orion Hodsonac141392017-01-13 11:53:47 +00002293.Lstore_char_result:
Orion Hodsonac141392017-01-13 11:53:47 +00002294 b .Lcleanup_and_return
Alexey Frunzec480b982017-01-16 19:03:21 -08002295 lhu $v0, 16($sp) # Move char from JValue result to return value register.
Orion Hodsonac141392017-01-13 11:53:47 +00002296.Lstore_double_result:
2297.Lstore_float_result:
2298 LDu $f0, $f1, 16, $sp, $t0 # Move double/float from JValue result to return value register.
2299 b .Lcleanup_and_return
2300 nop
2301.Lstore_long_result:
2302 lw $v1, 20($sp) # Move upper bits from JValue result to return value register.
2303 // Fall-through for lower bits.
2304.Lstore_int_result:
2305 lw $v0, 16($sp) # Move lower bits from JValue result to return value register.
2306 // Fall-through to clean up and return.
2307.Lcleanup_and_return:
Orion Hodsonac141392017-01-13 11:53:47 +00002308 lw $t7, THREAD_EXCEPTION_OFFSET(rSELF) # Load Thread::Current()->exception_
2309 RESTORE_SAVE_REFS_AND_ARGS_FRAME
2310 bnez $t7, 1f # Success if no exception is pending.
2311 nop
2312 jalr $zero, $ra
2313 nop
23141:
2315 DELIVER_PENDING_EXCEPTION
2316END art_quick_invoke_polymorphic