quick_entrypoints_mips.S revision 87f3fcbd0db352157fc59148e94647ef21b73bce
10f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes/*
20f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * Copyright (C) 2012 The Android Open Source Project
30f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes *
40f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
50f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * you may not use this file except in compliance with the License.
60f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * You may obtain a copy of the License at
70f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes *
80f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
90f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes *
100f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * Unless required by applicable law or agreed to in writing, software
110f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
120f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * See the License for the specific language governing permissions and
140f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes * limitations under the License.
150f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes */
160f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes
177655f29fabc0a12765de828914a18314382e5a35Ian Rogers#include "asm_support_mips.S"
185bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
197410f29b4dae223befac036ea567d7f33351dad1Mathieu Chartier#include "arch/quick_alloc_entrypoints.S"
207410f29b4dae223befac036ea567d7f33351dad1Mathieu Chartier
210703060875166106af3d490c6c264611aea67ec8jeffhao    .set noreorder
225bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    .balign 4
235bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
245bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* Deliver the given exception */
255bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    .extern artDeliverExceptionFromCode
265bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* Deliver an exception pending on a thread */
278161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    .extern artDeliverPendingExceptionFromCode
285bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
29735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung#define ARG_SLOT_SIZE   32    // space for a0-a3 plus 4 more words
30735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
315bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
325bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that sets up the callee save frame to conform with
335bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Runtime::CreateCalleeSaveMethod(kSaveAll)
34735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Callee-save: $s0-$s8 + $gp + $ra, 11 total + 1 word for Method*
35735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $t0 and $sp
36735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
37735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_SAVE_ALL_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
385bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
3957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
40a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    addiu  $sp, $sp, -96
41a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_adjust_cfa_offset 96
425c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
435c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe     // Ugly compile-time check, but we only have the preprocessor.
44a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 96)
455c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
465c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
475c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
48a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $ra, 92($sp)
49a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 31, 92
50a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s8, 88($sp)
51a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 30, 88
52a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $gp, 84($sp)
53a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 28, 84
54a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s7, 80($sp)
55a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 23, 80
56a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s6, 76($sp)
57a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 22, 76
58a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s5, 72($sp)
59a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 21, 72
60a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s4, 68($sp)
61a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 20, 68
62a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s3, 64($sp)
63a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 19, 64
64a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s2, 60($sp)
65a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 18, 60
66a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s1, 56($sp)
67a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 17, 56
68a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    sw     $s0, 52($sp)
69a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    .cfi_rel_offset 16, 52
70a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe
71a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f30, $f31, 44, $sp, $t1
72a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f28, $f29, 36, $sp, $t1
73a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f26, $f27, 28, $sp, $t1
74a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f24, $f25, 20, $sp, $t1
75a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f22, $f23, 12, $sp, $t1
76a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe    SDu $f20, $f21, 4,  $sp, $t1
77a4e0e67611f54180694e0807d6599c1132269b6cAndreas Gampe
78735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # 1 word for holding Method*
791d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
804af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
814af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
824af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
831d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
841d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
85735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
86735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
895bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that sets up the callee save frame to conform with
915bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
925bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Does not include rSUSPEND or rSELF
93735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
94735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $t0 and $sp
95735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
96735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
981d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
99735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -48
100735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset 48
1015c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
1025c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
103735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
1045c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
1055c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
1065c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
107735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $ra, 44($sp)
108735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 31, 44
109735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s8, 40($sp)
110735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 30, 40
111735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $gp, 36($sp)
112735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 28, 36
113735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s7, 32($sp)
114735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 23, 32
115735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s6, 28($sp)
116735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 22, 28
117735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s5, 24($sp)
118735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 21, 24
119735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s4, 20($sp)
120735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 20, 20
121735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s3, 16($sp)
122735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 19, 16
123735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s2, 12($sp)
124735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 18, 12
125735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # 2 words for alignment and bottom word will hold Method*
1261d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
1274af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
1284af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
1294af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
1301d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
1311d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
132735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
133735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
1345bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1355bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1361d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
137735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, ARG_SLOT_SIZE                # remove argument slots on the stack
138735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
139735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $ra, 44($sp)
140bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
141735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s8, 40($sp)
142bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
143735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $gp, 36($sp)
144bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 28
145735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s7, 32($sp)
146bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 23
147735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s6, 28($sp)
148bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 22
149735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s5, 24($sp)
150bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 21
151735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s4, 20($sp)
152bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 20
153735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s3, 16($sp)
154bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 19
155735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s2, 12($sp)
156bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 18
157735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, 48
158735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -48
1595bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1611d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
162735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
1638d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
164735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    nop
1655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1665bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1675bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
1685bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that sets up the callee save frame to conform with
169735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
1701f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao     * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
1715bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
172735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
173ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu  $sp, $sp, -80
174ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_adjust_cfa_offset 80
1755c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
1765c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
177ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 80)
1785c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
1795c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
1805c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
181ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $ra, 76($sp)
182ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 31, 76
183ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s8, 72($sp)
184ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 30, 72
185ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $gp, 68($sp)
186ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 28, 68
187ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s7, 64($sp)
188ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 23, 64
189ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s6, 60($sp)
190ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 22, 60
191ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s5, 56($sp)
192ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 21, 56
193ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s4, 52($sp)
194ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 20, 52
195ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s3, 48($sp)
196ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 19, 48
197ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $s2, 44($sp)
198ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 18, 44
199ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $a3, 40($sp)
200ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 7, 40
201ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $a2, 36($sp)
202ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 6, 36
203ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw     $a1, 32($sp)
204ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 5, 32
205ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    SDu $f14, $f15, 24, $sp, $t0
206ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    SDu $f12, $f13, 16, $sp, $t0
207fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    # bottom will hold Method*
208735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.endm
2091d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
210735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    /*
211735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Macro that sets up the callee save frame to conform with
212735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
213ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     * callee-save: $a1-$a3, $f12-$f15, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
214735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $t0 and $sp
215735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
216735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
217735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     */
218735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
219735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
2204af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
2214af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
2224af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
2231d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
2241d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
225735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
226735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
227735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.endm
228735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
229735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    /*
230735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Macro that sets up the callee save frame to conform with
231735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
232ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     * callee-save: $a1-$a3, $f12-$f15, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
233735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $sp
234735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Use $a0 as the Method* and loads it into bottom of stack.
235735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
236735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
237735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     */
238735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
239735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
240735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw $a0, 0($sp)                                # Place Method* at bottom of stack.
241735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
242735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
243735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
2445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2455bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2461d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
247735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, ARG_SLOT_SIZE                # remove argument slots on the stack
248735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
249ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $ra, 76($sp)
250bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
251ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s8, 72($sp)
252bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
253ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $gp, 68($sp)
254bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 28
255ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s7, 64($sp)
256bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 23
257ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s6, 60($sp)
258bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 22
259ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s5, 56($sp)
260bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 21
261ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s4, 52($sp)
262bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 20
263ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s3, 48($sp)
264bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 19
265ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $s2, 44($sp)
266bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 18
267ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $a3, 40($sp)
268bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 7
269ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $a2, 36($sp)
270bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 6
271ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw     $a1, 32($sp)
272bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 5
273ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LDu $f14, $f15, 24, $sp, $t1
274ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LDu $f12, $f13, 16, $sp, $t1
275ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu  $sp, $sp, 80           # pop frame
276ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_adjust_cfa_offset -80
2775bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2785bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2795bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
2805bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
2815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * exception is Thread::Current()->exception_
2825bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
2835bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro DELIVER_PENDING_EXCEPTION
2848161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME     # save callee saves for throw
2858161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la      $t9, artDeliverPendingExceptionFromCode
2868d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $t9                   # artDeliverPendingExceptionFromCode(Thread*)
2871d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a0, rSELF                   # pass Thread::Current
2885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2895bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro RETURN_IF_NO_EXCEPTION
2917fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw     $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
2921d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
2938161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    bnez   $t0, 1f                       # success if no exception is pending
2945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2958d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
2965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
2985bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
2995bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
3005bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3015bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro RETURN_IF_ZERO
3021d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3037fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez   $v0, 1f                       # success?
3045bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3058d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra                    # return on success
3065bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
3085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
3095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
3105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3111cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
3121d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3137fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    beqz   $v0, 1f                       # success?
3145bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3158d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra                    # return on success
3165bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3175bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
3185bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
3195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
3205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3215bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
3223bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     * On stack replacement stub.
3233bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     * On entry:
3243bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   a0 = stack to copy
3253bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   a1 = size of stack
3263bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   a2 = pc to call
3273bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   a3 = JValue* result
3283bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   [sp + 16] = shorty
3293bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     *   [sp + 20] = thread
3303bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic     */
3313bc13817a19e36f3833bb44624ef86800892eaadGoran JakovljevicENTRY art_quick_osr_stub
3323bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    // Save callee general purpose registers, RA and GP.
3333bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $sp, $sp, -48
3343bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_adjust_cfa_offset 48
3353bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $ra, 44($sp)
3363bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 31, 44
3373bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s8, 40($sp)
3383bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 30, 40
3393bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $gp, 36($sp)
3403bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 28, 36
3413bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s7, 32($sp)
3423bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 23, 32
3433bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s6, 28($sp)
3443bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 22, 28
3453bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s5, 24($sp)
3463bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 21, 24
3473bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s4, 20($sp)
3483bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 20, 20
3493bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s3, 16($sp)
3503bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 19, 16
3513bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s2, 12($sp)
3523bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 18, 12
3533bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s1, 8($sp)
3543bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 17, 8
3553bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s0, 4($sp)
3563bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_rel_offset 16, 4
3573bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic
3583bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $s8, $sp                        # Save the stack pointer
3593bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $s7, $a1                        # Save size of stack
3603bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $s6, $a2                        # Save the pc to call
3613bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     rSELF, 48+20($sp)               # Save managed thread pointer into rSELF
3623bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $t0, $sp, -12                   # Reserve space for stack pointer,
3633bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic                                           #    JValue* result, and ArtMethod* slot.
3643bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    srl    $t0, $t0, 4                     # Align stack pointer to 16 bytes
3653bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sll    $sp, $t0, 4                     # Update stack pointer
3663bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $s8, 4($sp)                     # Save old stack pointer
3673bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $a3, 8($sp)                     # Save JValue* result
3683bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $zero, 0($sp)                   # Store null for ArtMethod* at bottom of frame
3693bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    subu   $sp, $a1                        # Reserve space for callee stack
3703bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $a2, $a1
3713bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $a1, $a0
3723bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $a0, $sp
3733bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    la     $t9, memcpy
3743bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    jalr   $t9                             # memcpy (dest a0, src a1, bytes a2)
3753bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $sp, $sp, -16                   # make space for argument slots for memcpy
3763bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    bal    .Losr_entry                     # Call the method
3773bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $sp, $sp, 16                    # restore stack after memcpy
3783bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $a2, 8($sp)                     # Restore JValue* result
3793bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $sp, 4($sp)                     # Restore saved stack pointer
3803bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $a0, 48+16($sp)                 # load shorty
3813bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lbu    $a0, 0($a0)                     # load return type
3823bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    li     $a1, 'D'                        # put char 'D' into a1
3833bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    beq    $a0, $a1, .Losr_fp_result       # Test if result type char == 'D'
3843bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    li     $a1, 'F'                        # put char 'F' into a1
3853bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    beq    $a0, $a1, .Losr_fp_result       # Test if result type char == 'F'
3863bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    nop
3873bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $v0, 0($a2)
3883bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    b      .Losr_exit
3893bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $v1, 4($a2)                     # store v0/v1 into result
3903bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic.Losr_fp_result:
3913bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    SDu    $f0, $f1, 0, $a2, $t0           # store f0/f1 into result
3923bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic.Losr_exit:
3933bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $ra, 44($sp)
3943bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 31
3953bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s8, 40($sp)
3963bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 30
3973bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $gp, 36($sp)
3983bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 28
3993bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s7, 32($sp)
4003bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 23
4013bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s6, 28($sp)
4023bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 22
4033bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s5, 24($sp)
4043bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 21
4053bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s4, 20($sp)
4063bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 20
4073bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s3, 16($sp)
4083bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 19
4093bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s2, 12($sp)
4103bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 18
4113bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s1, 8($sp)
4123bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 17
4133bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    lw     $s0, 4($sp)
4143bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_restore 16
4153bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    jalr   $zero, $ra
4163bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $sp, $sp, 48
4173bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    .cfi_adjust_cfa_offset -48
4183bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic.Losr_entry:
4193bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addiu  $s7, $s7, -4
4203bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    addu   $t0, $s7, $sp
4213bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    move   $t9, $s6
4223bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    jalr   $zero, $t9
4233bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    sw     $ra, 0($t0)                     # Store RA per the compiler ABI
4243bc13817a19e36f3833bb44624ef86800892eaadGoran JakovljevicEND art_quick_osr_stub
4253bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic
4263bc13817a19e36f3833bb44624ef86800892eaadGoran Jakovljevic    /*
4277fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
4285bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * FIXME: just guessing about the shape of the jmpbuf.  Where will pc be?
4295bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
430d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_do_long_jump
431e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f0,  $f1,   0*8, $a1, $t1
432e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f2,  $f3,   1*8, $a1, $t1
433e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f4,  $f5,   2*8, $a1, $t1
434e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f6,  $f7,   3*8, $a1, $t1
435e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f8,  $f9,   4*8, $a1, $t1
436e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f10, $f11,  5*8, $a1, $t1
437e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f12, $f13,  6*8, $a1, $t1
438e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f14, $f15,  7*8, $a1, $t1
439e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f16, $f17,  8*8, $a1, $t1
440e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f18, $f19,  9*8, $a1, $t1
441e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f20, $f21, 10*8, $a1, $t1
442e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f22, $f23, 11*8, $a1, $t1
443e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f24, $f25, 12*8, $a1, $t1
444e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f26, $f27, 13*8, $a1, $t1
445e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f28, $f29, 14*8, $a1, $t1
446e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f30, $f31, 15*8, $a1, $t1
447e34652f15f32666323052a6718a63248244f1e66Duane Sand
448748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set push
449748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set nomacro
450748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set noat
4517fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $at, 4($a0)
452748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set pop
4537fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $v0, 8($a0)
4547fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $v1, 12($a0)
4557fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a1, 20($a0)
4567fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a2, 24($a0)
4577fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a3, 28($a0)
4587fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t0, 32($a0)
4597fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t1, 36($a0)
4607fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t2, 40($a0)
4617fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t3, 44($a0)
4627fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t4, 48($a0)
4637fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t5, 52($a0)
4647fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t6, 56($a0)
4657fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t7, 60($a0)
4667fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s0, 64($a0)
4677fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s1, 68($a0)
4687fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s2, 72($a0)
4697fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s3, 76($a0)
4707fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s4, 80($a0)
4717fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s5, 84($a0)
4727fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s6, 88($a0)
4737fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s7, 92($a0)
4747fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t8, 96($a0)
4757fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t9, 100($a0)
4767fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $gp, 112($a0)
4777fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $sp, 116($a0)
4787fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $fp, 120($a0)
4797fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $ra, 124($a0)
4807fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a0, 16($a0)
481590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    move    $v0, $zero          # clear result registers v0 and v1 (in branch delay slot)
48275969963213c39a029e01c3b9440fb388d793afbGoran Jakovljevic    jalr    $zero, $t9          # do long jump
4837fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $v1, $zero
484d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_do_long_jump
4855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4865bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
4875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code, saves most registers (forms basis of long jump context) and passes
4885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
48984bc06e30ba12c3ff07e577c52b63b9df162af7eLazar Trsic     * the bottom of the thread. On entry a0 holds Throwable*
4905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
491468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_deliver_exception
49257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4938161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artDeliverExceptionFromCode
4948d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artDeliverExceptionFromCode(Throwable*, Thread*)
4951d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a1, rSELF                 # pass Thread::Current
496468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_deliver_exception
4975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4985bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
4995bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver a NullPointerException
5005bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
501d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowNullPointerExceptionFromCode
502468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_null_pointer_exception
50357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5048161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowNullPointerExceptionFromCode
5058d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowNullPointerExceptionFromCode(Thread*)
5061d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
507468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_null_pointer_exception
5085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
5105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver an ArithmeticException
5115bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
512d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowDivZeroFromCode
513468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_div_zero
51457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5158161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowDivZeroFromCode
5168d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowDivZeroFromCode(Thread*)
5171d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
518468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_div_zero
5195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
5215bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
5225bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
523d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowArrayBoundsFromCode
524468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_array_bounds
52557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5268161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowArrayBoundsFromCode
5278d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowArrayBoundsFromCode(index, limit, Thread*)
5281d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
529468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_array_bounds
5305bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
53157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
53287f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko     * Called by managed code to create and deliver a StringIndexOutOfBoundsException
53387f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko     * as if thrown from a call to String.charAt().
53487f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko     */
53587f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    .extern artThrowStringBoundsFromCode
53687f3fcbd0db352157fc59148e94647ef21b73bceVladimir MarkoENTRY art_quick_throw_string_bounds
53787f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
53887f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    la   $t9, artThrowStringBoundsFromCode
53987f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    jalr $zero, $t9                 # artThrowStringBoundsFromCode(index, limit, Thread*)
54087f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    move $a2, rSELF                 # pass Thread::Current
54187f3fcbd0db352157fc59148e94647ef21b73bceVladimir MarkoEND art_quick_throw_string_bounds
54287f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko
54387f3fcbd0db352157fc59148e94647ef21b73bceVladimir Marko    /*
54457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a StackOverflowError.
54557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     */
546d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowStackOverflowFromCode
547468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_stack_overflow
54857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5498161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowStackOverflowFromCode
5508d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowStackOverflowFromCode(Thread*)
5511d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
552468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_stack_overflow
5535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
55457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
55557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a NoSuchMethodError.
55657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     */
557d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowNoSuchMethodFromCode
558468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_no_such_method
55957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
5608161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowNoSuchMethodFromCode
5618d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
5621d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a1, rSELF                 # pass Thread::Current
563468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_no_such_method
5645bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
5665bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * All generated callsites for interface invokes and invocation slow paths will load arguments
5677fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
5687ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray     * the method_idx.  This wrapper will save arg1-arg3, and call the appropriate C helper.
5697fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
5705bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
5717fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
5727fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * of the target Method* in $v0 and method->code_ in $v1.
5735bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
5742cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier     * If unsuccessful, the helper will return null/null. There will be a pending exception in the
5755bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * thread and we branch to another stub to deliver it.
5765bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
5775bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
5785bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * pointing back to the original caller.
5795bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
5803031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.macro INVOKE_TRAMPOLINE_BODY cxx_name
5815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    .extern \cxx_name
5821d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME  # save callee saves in case allocation triggers GC
5837ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a2, rSELF                       # pass Thread::Current
584590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la    $t9, \cxx_name
585590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr  $t9                              # (method_idx, this, Thread*, $sp)
5867ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    addiu $a3, $sp, ARG_SLOT_SIZE          # pass $sp (remove arg slots)
5877ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a0, $v0                         # save target Method*
5881d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
589fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    beqz  $v0, 1f
5907ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $t9, $v1                         # save $v0->code_
5918d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $t9
5925bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
5935bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
5945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
5953031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.endm
5963031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe.macro INVOKE_TRAMPOLINE c_name, cxx_name
5973031c8da0c5009183f770b005c245f9bf2a4d01bAndreas GampeENTRY \c_name
5983031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe    INVOKE_TRAMPOLINE_BODY \cxx_name
599d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND \c_name
6005bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
6015bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
6028dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
6035bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
6048dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
6058dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
6068dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
6078dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
6085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
609ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.macro LOAD_WORD_TO_REG reg, next_arg, index, label
610ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $\reg, -4($\next_arg)   # next_arg points to argument after the current one (offset is 4)
611ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    b     \label
612ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $\index, 1
613ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.endm
614ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
615ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.macro LOAD_LONG_TO_REG reg1, reg2, next_arg, index, label
616ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $\reg1, -8($\next_arg)  # next_arg points to argument after the current one (offset is 8)
617ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $\reg2, -4($\next_arg)
618ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    b     \label
619ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $\index, 4              # long can be loaded only to a2_a3 pair so index will be always 4
620ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.endm
621ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
622ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.macro LOAD_FLOAT_TO_REG reg, next_arg, index, label
623ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lwc1  $\reg, -4($\next_arg)   # next_arg points to argument after the current one (offset is 4)
624ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    b     \label
625ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $\index, 1
626ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.endm
627ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
628ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.macro LOAD_DOUBLE_TO_REG reg1, reg2, next_arg, index, tmp, label
629ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LDu  $\reg1, $\reg2, -8, $\next_arg, $\tmp  # next_arg points to argument after the current one
630ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic                                                # (offset is 8)
631ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    b     \label
632ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $\index, 1
633ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic.endm
634ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
635590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic#define SPILL_SIZE    32
636590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic
63779fe539587d4c09244172d0168eeed0ec9770466Jeff Hao    /*
638ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers     * Invocation stub for quick code.
6395d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     * On entry:
6405d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a0 = method pointer
6412cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier     *   a1 = argument array or null for no argument methods
6425d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a2 = size of argument array in bytes
6435d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a3 = (managed) thread pointer
6446474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   [sp + 16] = JValue* result
6450177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers     *   [sp + 20] = shorty
6465d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     */
6475d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoENTRY art_quick_invoke_stub
6485d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $a0, 0($sp)           # save out a0
649590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
650590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset SPILL_SIZE
651590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    sw    $gp, 16($sp)
6525d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $ra, 12($sp)
6535d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 31, 12
6545d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $fp, 8($sp)
6555d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 30, 8
6565d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $s1, 4($sp)
6575d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 17, 4
6585d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $s0, 0($sp)
6595d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 16, 0
6605d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $fp, $sp              # save sp in fp
6615d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_def_cfa_register 30
6625d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $s1, $a3              # move managed thread pointer into s1
6635d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $s0, $zero, SUSPEND_CHECK_INTERVAL  # reset s0 to suspend check interval
664ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, $a2, 4           # create space for ArtMethod* in frame.
665735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    subu  $t0, $sp, $t0         # reserve & align *stack* to 16 bytes:
666ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    srl   $t0, $t0, 4           #   native calling convention only aligns to 8B,
667ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sll   $sp, $t0, 4           #   so we have to ensure ART 16B alignment ourselves.
668ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $a0, $sp, 4           # pass stack pointer + ArtMethod* as dest for memcpy
669590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la    $t9, memcpy
670590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr  $t9                   # (dest, src, bytes)
6715d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, -16         # make space for argument slots for memcpy
6725d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, 16          # restore stack after memcpy
673590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $gp, 16($fp)          # restore $gp
674590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $a0, SPILL_SIZE($fp)  # restore ArtMethod*
675ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $a1, 4($sp)           # a1 = this*
676ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, $sp, 8           # t0 = pointer to the current argument (skip ArtMethod* and this*)
677ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 2                # t3 = gpr_index = 2 (skip A0 and A1)
678ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    move  $t4, $zero            # t4 = fp_index = 0
679590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $t1, 20 + SPILL_SIZE($fp)  # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
680590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic                                # as the $fp is SPILL_SIZE bytes below the $sp on entry)
681ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t1, 1                # t1 = shorty + 1 (skip 1 for return type)
682ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevicloop:
683ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lbu   $t2, 0($t1)           # t2 = shorty[i]
684ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beqz  $t2, loopEnd          # finish getting args when shorty[i] == '\0'
685ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t1, 1
686ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
687ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'J'              # put char 'J' into t9
688ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isLong      # branch if result type char == 'J'
689ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'D'              # put char 'D' into t9
690ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isDouble    # branch if result type char == 'D'
691ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'F'              # put char 'F' into t9
692ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isSingle    # branch if result type char == 'F'
693ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 4                # next_arg = curr_arg + 4 (in branch delay slot,
694ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic                                # for both, int and single)
695ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
696ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 2                                   # skip a0 and a1 (ArtMethod* and this*)
697ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t3, 1f                             # if (gpr_index == 2)
698ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
699ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_WORD_TO_REG a2, t0, t3, loop              #   a2 = current argument, gpr_index++
700ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic1:  bne   $t5, $t3, loop                           # else if (gpr_index == 3)
701ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
702ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_WORD_TO_REG a3, t0, t3, loop              #   a3 = current argument, gpr_index++
703ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
704ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisLong:
705ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 8                                   # next_arg = curr_arg + 8
706ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    slti  $t5, $t3, 3
707ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beqz  $t5, 2f                                  # if (gpr_index < 3)
708ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
709ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_LONG_TO_REG a2, a3, t0, t3, loop          #   a2_a3 = curr_arg, gpr_index = 4
710ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic2:  b     loop                                     # else
711ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 4                                   #   gpr_index = 4
712ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
713ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisDouble:
714ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 8                                   # next_arg = curr_arg + 8
715ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 0
716ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t4, 3f                             # if (fp_index == 0)
717ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
718ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loop  #   f12_f13 = curr_arg, fp_index++
719ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic3:  bne   $t5, $t4, loop                           # else if (fp_index == 1)
720ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
721ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loop  #   f14_f15 = curr_arg, fp_index++
722ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
723ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisSingle:
724ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 0
725ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t4, 4f                             # if (fp_index == 0)
726ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
727ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_FLOAT_TO_REG f12, t0, t4, loop            #   f12 = curr_arg, fp_index++
728ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic4:  bne   $t5, $t4, loop                           # else if (fp_index == 1)
729ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
730ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_FLOAT_TO_REG f14, t0, t4, loop            #   f14 = curr_arg, fp_index++
731ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
732ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicloopEnd:
733e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier    lw    $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)  # get pointer to the code
7345d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    jalr  $t9                   # call the method
735ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $zero, 0($sp)         # store null for ArtMethod* at bottom of frame
7365d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $sp, $fp              # restore the stack
7375d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $s0, 0($sp)
738bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 16
7395d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $s1, 4($sp)
740bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 17
7415d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $fp, 8($sp)
742bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
7435d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $ra, 12($sp)
744bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
745590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu $sp, $sp, SPILL_SIZE
746590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset -SPILL_SIZE
7475d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $t0, 16($sp)          # get result pointer
7480177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers    lw    $t1, 20($sp)          # get shorty
7490177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers    lb    $t1, 0($t1)           # get result type char
750ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t2, 'D'              # put char 'D' into t2
751ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t1, $t2, 5f          # branch if result type char == 'D'
752ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 'F'              # put char 'F' into t3
753ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t1, $t3, 5f          # branch if result type char == 'F'
7545d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $v0, 0($t0)           # store the result
7558d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $ra
7565d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $v1, 4($t0)           # store the other half of the result
757ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic5:
758e34652f15f32666323052a6718a63248244f1e66Duane Sand    SDu   $f0, $f1, 0, $t0, $t1 # store floating point result
7598d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $ra
760e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
7615d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoEND art_quick_invoke_stub
7625d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao
7635d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    /*
764ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     * Invocation static stub for quick code.
765ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     * On entry:
766ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   a0 = method pointer
767ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   a1 = argument array or null for no argument methods
768ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   a2 = size of argument array in bytes
769ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   a3 = (managed) thread pointer
770ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   [sp + 16] = JValue* result
771ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     *   [sp + 20] = shorty
772ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic     */
773ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicENTRY art_quick_invoke_static_stub
774ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $a0, 0($sp)           # save out a0
775590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu $sp, $sp, -SPILL_SIZE # spill s0, s1, fp, ra and gp
776590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset SPILL_SIZE
777590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    sw    $gp, 16($sp)
778ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $ra, 12($sp)
779ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 31, 12
780ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $fp, 8($sp)
781ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 30, 8
782ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $s1, 4($sp)
783ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 17, 4
784ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $s0, 0($sp)
785ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_rel_offset 16, 0
786ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    move  $fp, $sp              # save sp in fp
787ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_def_cfa_register 30
788ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    move  $s1, $a3              # move managed thread pointer into s1
789ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $s0, $zero, SUSPEND_CHECK_INTERVAL  # reset s0 to suspend check interval
790ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, $a2, 4           # create space for ArtMethod* in frame.
791ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    subu  $t0, $sp, $t0         # reserve & align *stack* to 16 bytes:
792ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    srl   $t0, $t0, 4           #   native calling convention only aligns to 8B,
793ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sll   $sp, $t0, 4           #   so we have to ensure ART 16B alignment ourselves.
794ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $a0, $sp, 4           # pass stack pointer + ArtMethod* as dest for memcpy
795590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la    $t9, memcpy
796590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr  $t9                   # (dest, src, bytes)
797ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $sp, $sp, -16         # make space for argument slots for memcpy
798ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $sp, $sp, 16          # restore stack after memcpy
799590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $gp, 16($fp)          # restore $gp
800590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $a0, SPILL_SIZE($fp)  # restore ArtMethod*
801ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, $sp, 4           # t0 = pointer to the current argument (skip ArtMethod*)
802ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 1                # t3 = gpr_index = 1 (skip A0)
803ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    move  $t4, $zero            # t4 = fp_index = 0
804590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw    $t1, 20 + SPILL_SIZE($fp)  # get shorty (20 is offset from the $sp on entry + SPILL_SIZE
805590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic                                # as the $fp is SPILL_SIZE bytes below the $sp on entry)
806ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t1, 1                # t1 = shorty + 1 (skip 1 for return type)
807ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicloopS:
808ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lbu   $t2, 0($t1)           # t2 = shorty[i]
809ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beqz  $t2, loopEndS         # finish getting args when shorty[i] == '\0'
810ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t1, 1
811ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
812ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'J'              # put char 'J' into t9
813ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isLongS     # branch if result type char == 'J'
814ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'D'              # put char 'D' into t9
815ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isDoubleS   # branch if result type char == 'D'
816ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t9, 'F'              # put char 'F' into t9
817ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t9, $t2, isSingleS   # branch if result type char == 'F'
818ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 4                # next_arg = curr_arg + 4 (in branch delay slot,
819ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic                                # for both, int and single)
820ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
821ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 1                                    # skip a0 (ArtMethod*)
822ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t3, 1f                              # if (gpr_index == 1)
823ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
824ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_WORD_TO_REG a1, t0, t3, loopS              #   a1 = current argument, gpr_index++
825ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic1:  bne   $t5, $t3, 2f                              # else if (gpr_index == 2)
826ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
827ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_WORD_TO_REG a2, t0, t3, loopS              #   a2 = current argument, gpr_index++
828ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic2:  bne   $t5, $t3, loopS                           # else if (gpr_index == 3)
829ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
830ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_WORD_TO_REG a3, t0, t3, loopS              #   a3 = current argument, gpr_index++
831ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
832ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisLongS:
833ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 8                                    # next_arg = curr_arg + 8
834ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    slti  $t5, $t3, 3
835ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beqz  $t5, 3f                                   # if (gpr_index < 3)
836ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
837ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_LONG_TO_REG a2, a3, t0, t3, loopS          #   a2_a3 = curr_arg, gpr_index = 4
838ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic3:  b     loopS                                     # else
839ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 4                                    #   gpr_index = 4
840ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
841ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisDoubleS:
842ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t0, 8                                    # next_arg = curr_arg + 8
843ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 0
844ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t4, 4f                              # if (fp_index == 0)
845ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
846ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_DOUBLE_TO_REG f12, f13, t0, t4, t9, loopS  #   f12_f13 = curr_arg, fp_index++
847ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic4:  bne   $t5, $t4, loopS                           # else if (fp_index == 1)
848ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
849ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_DOUBLE_TO_REG f14, f15, t0, t4, t9, loopS  #   f14_f15 = curr_arg, fp_index++
850ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
851ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicisSingleS:
852ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t5, 0
853ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    bne   $t5, $t4, 5f                              # if (fp_index == 0)
854ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    addiu $t5, 1
855ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_FLOAT_TO_REG f12, t0, t4, loopS            #   f12 = curr_arg, fp_index++
856ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic5:  bne   $t5, $t4, loopS                           # else if (fp_index == 1)
857ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
858ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    LOAD_FLOAT_TO_REG f14, t0, t4, loopS            #   f14 = curr_arg, fp_index++
859ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
860ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicloopEndS:
861ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)  # get pointer to the code
862ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    jalr  $t9                   # call the method
863ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $zero, 0($sp)         # store null for ArtMethod* at bottom of frame
864ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    move  $sp, $fp              # restore the stack
865ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $s0, 0($sp)
866ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_restore 16
867ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $s1, 4($sp)
868ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_restore 17
869ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $fp, 8($sp)
870ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_restore 30
871ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $ra, 12($sp)
872ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    .cfi_restore 31
873590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu $sp, $sp, SPILL_SIZE
874590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset -SPILL_SIZE
875ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $t0, 16($sp)          # get result pointer
876ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lw    $t1, 20($sp)          # get shorty
877ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    lb    $t1, 0($t1)           # get result type char
878ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t2, 'D'              # put char 'D' into t2
879ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t1, $t2, 6f          # branch if result type char == 'D'
880ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    li    $t3, 'F'              # put char 'F' into t3
881ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    beq   $t1, $t3, 6f          # branch if result type char == 'F'
882ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $v0, 0($t0)           # store the result
883ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    jalr  $zero, $ra
884ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    sw    $v1, 4($t0)           # store the other half of the result
885ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic6:
886ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    SDu   $f0, $f1, 0, $t0, $t1 # store floating point result
887ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    jalr  $zero, $ra
888ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    nop
889ff73498a5539d87424a964265e43765e788aec44Goran JakovljevicEND art_quick_invoke_static_stub
890ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic
891590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic#undef SPILL_SIZE
892590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic
893ff73498a5539d87424a964265e43765e788aec44Goran Jakovljevic    /*
8945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
8955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * failure.
8965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
897d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artHandleFillArrayDataFromCode
898468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_handle_fill_data
899735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                    # pass referrer's Method*
900735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case exception allocation triggers GC
901590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artHandleFillArrayDataFromCode
902590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                            # (payload offset, Array*, method, Thread*)
903832336b3c9eb892045a8de1bb12c9361112ca3c5Ian Rogers    move   $a3, rSELF                     # pass Thread::Current
904fc6a30e2fa8f0d44e6c95bbeb5deca4b499f67cejeffhao    RETURN_IF_ZERO
905468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_handle_fill_data
9065bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
90857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Entry from managed code that calls artLockObjectFromCode, may block for GC.
9095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
910d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artLockObjectFromCode
911468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_lock_object
91286bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
913a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
914735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case we block
915590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artLockObjectFromCode
916590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                           # (Object* obj, Thread*)
9177fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $a1, rSELF                    # pass Thread::Current
9186bcd163d322b867578fbcfe60e4e3b247c42974bIan Rogers    RETURN_IF_ZERO
919468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_lock_object
9205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
921c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas GampeENTRY art_quick_lock_object_no_inline
922c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
923c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    nop
924c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case we block
925c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    la      $t9, artLockObjectFromCode
926c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    jalr    $t9                           # (Object* obj, Thread*)
927c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    move    $a1, rSELF                    # pass Thread::Current
928c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    RETURN_IF_ZERO
929c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas GampeEND art_quick_lock_object_no_inline
930c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe
9315bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
9325bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
9335bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
934d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artUnlockObjectFromCode
935468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_unlock_object
93686bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
937a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
938735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
939590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artUnlockObjectFromCode
940590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                       # (Object* obj, Thread*)
9417fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $a1, rSELF                # pass Thread::Current
9425bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
943468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_unlock_object
9445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
945c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas GampeENTRY art_quick_unlock_object_no_inline
946c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
947c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    nop
948c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
949c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    la      $t9, artUnlockObjectFromCode
950c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    jalr    $t9                       # (Object* obj, Thread*)
951c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    move    $a1, rSELF                # pass Thread::Current
952c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe    RETURN_IF_ZERO
953c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas GampeEND art_quick_unlock_object_no_inline
954c7ed09bd5d6f2c7af3bcba1c39b3f9185af68796Andreas Gampe
9555bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
9565bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
9575bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
958a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .extern artThrowClassCastException
959468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_check_cast
960590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $sp, $sp, -32
961590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset 32
962590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    sw     $gp, 16($sp)
963a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $ra, 12($sp)
964a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset 31, 12
965a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $t9, 8($sp)
966a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a1, 4($sp)
967a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a0, 0($sp)
968590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artIsAssignableFromCode
969590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9
970735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -16             # reserve argument slots on the stack
971735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, 16
972590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw     $gp, 16($sp)
97386bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz   $v0, .Lthrow_class_cast_exception
974a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $ra, 12($sp)
9758d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
976590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $sp, $sp, 32
977590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset -32
97886bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Lthrow_class_cast_exception:
979a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $t9, 8($sp)
980a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a1, 4($sp)
981a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a0, 0($sp)
982590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $sp, $sp, 32
983590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    .cfi_adjust_cfa_offset -32
984a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
985a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    la   $t9, artThrowClassCastException
9868d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowClassCastException (Class*, Class*, Thread*)
9871d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
988468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_check_cast
9895bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
9911aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * Restore rReg's value from offset($sp) if rReg is not the same as rExclude.
9921aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * nReg is the register number for rReg.
9931aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     */
9941aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.macro POP_REG_NE rReg, nReg, offset, rExclude
9951aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .ifnc \rReg, \rExclude
9961aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        lw \rReg, \offset($sp)      # restore rReg
9971aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        .cfi_restore \nReg
9981aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .endif
9991aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.endm
10001aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
10011aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    /*
10021aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * Macro to insert read barrier, only used in art_quick_aput_obj.
10031aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * rObj and rDest are registers, offset is a defined literal such as MIRROR_OBJECT_CLASS_OFFSET.
10041aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path.
10051aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao     */
10061aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.macro READ_BARRIER rDest, rObj, offset
10071aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#ifdef USE_READ_BARRIER
10081aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    # saved registers used in art_quick_aput_obj: a0-a2, t0-t1, t9, ra. 8 words for 16B alignment.
10091aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    addiu  $sp, $sp, -32
10101aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_adjust_cfa_offset 32
10111aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $ra, 28($sp)
10121aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 31, 28
10131aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $t9, 24($sp)
10141aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 25, 24
10151aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $t1, 20($sp)
10161aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 9, 20
10171aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $t0, 16($sp)
10181aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 8, 16
10191aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $a2, 8($sp)              # padding slot at offset 12 (padding can be any slot in the 32B)
10201aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 6, 8
10211aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $a1, 4($sp)
10221aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 5, 4
10231aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    sw     $a0, 0($sp)
10241aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_rel_offset 4, 0
10251aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
10266306921722283d2b0f8aac01883ad83215d6e864Man Cao    # move $a0, \rRef               # pass ref in a0 (no-op for now since parameter ref is unused)
10271aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .ifnc \rObj, $a1
10281aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao        move $a1, \rObj             # pass rObj
10291aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .endif
1030590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $a2, $zero, \offset      # pass offset
1031590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artReadBarrierSlow
1032590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                      # artReadBarrierSlow(ref, rObj, offset)
10331aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    addiu  $sp, $sp, -16            # Use branch delay slot to reserve argument slots on the stack
10341aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # before the call to artReadBarrierSlow.
10351aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    addiu  $sp, $sp, 16             # restore stack after call to artReadBarrierSlow
10361aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    # No need to unpoison return value in v0, artReadBarrierSlow() would do the unpoisoning.
10371aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    move \rDest, $v0                # save return value in rDest
10381aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # (rDest cannot be v0 in art_quick_aput_obj)
10391aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
10401aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     $a0, 0($sp)              # restore registers except rDest
10411aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao                                    # (rDest can only be t0 or t1 in art_quick_aput_obj)
10421aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 4
10431aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     $a1, 4($sp)
10441aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 5
10451aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     $a2, 8($sp)
10461aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 6
10471aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    POP_REG_NE $t0, 8, 16, \rDest
10481aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    POP_REG_NE $t1, 9, 20, \rDest
10491aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     $t9, 24($sp)
10501aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 25
10511aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     $ra, 28($sp)             # restore $ra
10521aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_restore 31
10531aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    addiu  $sp, $sp, 32
10541aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .cfi_adjust_cfa_offset -32
10551aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#else
10561aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    lw     \rDest, \offset(\rObj)
10571aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    UNPOISON_HEAP_REF \rDest
10581aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#endif  // USE_READ_BARRIER
10591aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao.endm
10601aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao
10611aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    /*
1062a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * Entry from managed code for array put operations of objects where the value being stored
1063a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * needs to be checked for compatibility.
1064a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * a0 = array, a1 = index, a2 = value
10655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1066a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_null_and_bound_check
106786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez    $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
1068a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
106986bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    b .Lart_quick_throw_null_pointer_exception_gp_set
1070a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
1071a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_null_and_bound_check
1072a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
1073a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_bound_check
10741d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
1075a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sltu $t1, $a1, $t0
107686bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez $t1, .Lart_quick_aput_obj_gp_set
1077a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
1078a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a0, $a1
107986bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    b .Lart_quick_throw_array_bounds_gp_set
1080a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a1, $t0
1081a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_bound_check
1082a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
10831aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#ifdef USE_READ_BARRIER
10841aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    .extern artReadBarrierSlow
10851aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#endif
1086a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj
108786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz $a2, .Ldo_aput_null
1088a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
10891aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t0, $a0, MIRROR_OBJECT_CLASS_OFFSET
10901aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t1, $a2, MIRROR_OBJECT_CLASS_OFFSET
10911aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao    READ_BARRIER $t0, $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET
109286bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bne $t1, $t0, .Lcheck_assignability  # value's type == array's component type - trivial assignability
1093a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
109486bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Ldo_aput:
1095a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sll $a1, $a1, 2
1096a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t0, $a0, $a1
1097bfa5eb6e8d15ea73a36f8df449630f285a91e995Hiroshi Yamauchi    POISON_HEAP_REF $a2
10981d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw  $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
1099a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw  $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
1100a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    srl $t1, $a0, 7
1101a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t1, $t1, $t0
1102a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sb  $t0, ($t1)
11038d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $ra
1104a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
110586bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Ldo_aput_null:
1106a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sll $a1, $a1, 2
1107a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t0, $a0, $a1
11081d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw  $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
11098d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $ra
1110a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
111186bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Lcheck_assignability:
1112a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    addiu  $sp, $sp, -32
1113a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset 32
1114a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $ra, 28($sp)
1115a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset 31, 28
1116590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    sw     $gp, 16($sp)
1117a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $t9, 12($sp)
1118a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a2, 8($sp)
1119a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a1, 4($sp)
1120a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a0, 0($sp)
1121a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move   $a1, $t1
1122a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move   $a0, $t0
1123590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artIsAssignableFromCode
1124590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9               # (Class*, Class*)
1125590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $sp, $sp, -16     # reserve argument slots on the stack
1126590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu  $sp, $sp, 16
1127a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $ra, 28($sp)
1128590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    lw     $gp, 16($sp)
1129a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $t9, 12($sp)
1130a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a2, 8($sp)
1131a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a1, 4($sp)
1132a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a0, 0($sp)
1133e34652f15f32666323052a6718a63248244f1e66Duane Sand    addiu  $sp, 32
1134a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -32
113586bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez   $v0, .Ldo_aput
1136a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
1137a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1138a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a1, $a2
1139a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    la   $t9, artThrowArrayStoreException
11408d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowArrayStoreException(Class*, Class*, Thread*)
11411d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
1142a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj
11435bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
11445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
114537f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a boolean primitive value.
114637f05ef45e0393de812d51261dc293240c17294dFred Shih     */
114737f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetBooleanStaticFromCode
114837f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_boolean_static
1149735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1150735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1151590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetBooleanStaticFromCode
1152590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
115337f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
115437f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
115537f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_boolean_static
115637f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
115737f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a byte primitive value.
115837f05ef45e0393de812d51261dc293240c17294dFred Shih     */
115937f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetByteStaticFromCode
116037f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_byte_static
1161735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1162735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1163590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetByteStaticFromCode
1164590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
116537f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
116637f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
116737f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_byte_static
116837f05ef45e0393de812d51261dc293240c17294dFred Shih
116937f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
117037f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a char primitive value.
117137f05ef45e0393de812d51261dc293240c17294dFred Shih     */
117237f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetCharStaticFromCode
117337f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_char_static
1174735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1175735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1176590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetCharStaticFromCode
1177590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
117837f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
117937f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
118037f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_char_static
118137f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
118237f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a short primitive value.
118337f05ef45e0393de812d51261dc293240c17294dFred Shih     */
118437f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetShortStaticFromCode
118537f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_short_static
1186735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1187735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1188590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetShortStaticFromCode
1189590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
119037f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
119137f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
119237f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_short_static
11935bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
11945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
119557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 32-bit primitive value.
11965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1197d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet32StaticFromCode
1198468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_static
1199735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1200735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1201590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGet32StaticFromCode
1202590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
12037fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
12045bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1205468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_static
12065bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
12075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
120857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 64-bit primitive value.
12095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1210d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet64StaticFromCode
1211468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_static
1212735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1213735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1214590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGet64StaticFromCode
1215590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
12167fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
12175bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1218468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_static
12195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
12205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
122157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load an object reference.
12225bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1223d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGetObjStaticFromCode
1224468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_static
1225735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
1226735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1227590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetObjStaticFromCode
1228590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (uint32_t field_idx, const Method* referrer, Thread*)
12297fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
12305bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1231468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_static
12325bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
12335bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
123437f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a boolean primitive value.
123537f05ef45e0393de812d51261dc293240c17294dFred Shih     */
123637f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetBooleanInstanceFromCode
123737f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_boolean_instance
1238735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1239735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1240590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetBooleanInstanceFromCode
1241590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
124237f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
124337f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
124437f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_boolean_instance
124537f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
124637f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a byte primitive value.
124737f05ef45e0393de812d51261dc293240c17294dFred Shih     */
124837f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetByteInstanceFromCode
124937f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_byte_instance
1250735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1251735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1252590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetByteInstanceFromCode
1253590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
125437f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
125537f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
125637f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_byte_instance
125737f05ef45e0393de812d51261dc293240c17294dFred Shih
125837f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
125937f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a char primitive value.
126037f05ef45e0393de812d51261dc293240c17294dFred Shih     */
126137f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetCharInstanceFromCode
126237f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_char_instance
1263735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1264735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1265590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetCharInstanceFromCode
1266590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
126737f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
126837f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
126937f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_char_instance
127037f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
127137f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a short primitive value.
127237f05ef45e0393de812d51261dc293240c17294dFred Shih     */
127337f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetShortInstanceFromCode
127437f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_short_instance
1275735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1276735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1277590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetShortInstanceFromCode
1278590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
127937f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
128037f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
128137f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_short_instance
128237f05ef45e0393de812d51261dc293240c17294dFred Shih
128337f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
128457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 32-bit primitive value.
12855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1286d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet32InstanceFromCode
1287468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_instance
1288735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1289735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1290590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGet32InstanceFromCode
1291590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
12927fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
12935bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1294468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_instance
12955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
12965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
129757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 64-bit primitive value.
12985bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1299d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet64InstanceFromCode
1300468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_instance
1301735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1302735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1303590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGet64InstanceFromCode
1304590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
13057fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
13065bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1307468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_instance
13085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
131057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load an object reference.
13115bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1312d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGetObjInstanceFromCode
1313468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_instance
1314735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1315735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1316590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artGetObjInstanceFromCode
1317590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, referrer, Thread*)
13187fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
13195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
1320468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_instance
13215bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13225bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
132337f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and store a 8-bit primitive value.
132437f05ef45e0393de812d51261dc293240c17294dFred Shih     */
132537f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet8StaticFromCode
132637f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set8_static
1327735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1328735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1329590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet8StaticFromCode
1330590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, new_val, referrer, Thread*)
133137f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
133237f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
133337f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set8_static
133437f05ef45e0393de812d51261dc293240c17294dFred Shih
133537f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
133637f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and store a 16-bit primitive value.
133737f05ef45e0393de812d51261dc293240c17294dFred Shih     */
133837f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet16StaticFromCode
133937f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set16_static
1340735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1341735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1342590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet16StaticFromCode
1343590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, new_val, referrer, Thread*, $sp)
13441d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move   $a3, rSELF                    # pass Thread::Current
134537f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
134637f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set16_static
134737f05ef45e0393de812d51261dc293240c17294dFred Shih
134837f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
134957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 32-bit primitive value.
13505bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1351d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSet32StaticFromCode
1352468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_static
1353735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1354735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1355590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet32StaticFromCode
1356590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, new_val, referrer, Thread*)
13577fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
13585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1359468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_static
13605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13615bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
136257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 64-bit primitive value.
13635bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
136437f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet64StaticFromCode
1365468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_static
1366735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
13678d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe                                         # 64 bit new_val is in a2:a3 pair
1368735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1369590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet64StaticFromCode
1370590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, referrer, new_val, Thread*)
1371fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
13725bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1373468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_static
13745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13755bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
137657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store an object reference.
13775bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1378d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSetObjStaticFromCode
1379468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_static
1380735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
1381735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1382590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSetObjStaticFromCode
1383590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, new_val, referrer, Thread*)
13847fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
13855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1386468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_static
13875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
138937f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and store a 8-bit primitive value.
139037f05ef45e0393de812d51261dc293240c17294dFred Shih     */
139137f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet8InstanceFromCode
139237f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set8_instance
1393735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
1394735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1395590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet8InstanceFromCode
1396590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, new_val, referrer, Thread*)
139737f05ef45e0393de812d51261dc293240c17294dFred Shih    sw     rSELF, 16($sp)                # pass Thread::Current
139837f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
139937f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set8_instance
140037f05ef45e0393de812d51261dc293240c17294dFred Shih
140137f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
140237f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and store a 16-bit primitive value.
140337f05ef45e0393de812d51261dc293240c17294dFred Shih     */
140437f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet16InstanceFromCode
140537f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set16_instance
1406735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
1407735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1408590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet16InstanceFromCode
1409590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, new_val, referrer, Thread*)
141037f05ef45e0393de812d51261dc293240c17294dFred Shih    sw     rSELF, 16($sp)                # pass Thread::Current
141137f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
141237f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set16_instance
141337f05ef45e0393de812d51261dc293240c17294dFred Shih
141437f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
141557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 32-bit primitive value.
14165bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1417d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSet32InstanceFromCode
1418468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_instance
1419735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
1420735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1421590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet32InstanceFromCode
1422590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, new_val, referrer, Thread*)
1423fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
14245bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1425468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_instance
14265bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
14275bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
142857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 64-bit primitive value.
14295bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
143037f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet64InstanceFromCode
1431468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_instance
1432735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $t1, 0($sp)                   # load referrer's Method*
14338d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe                                         # 64 bit new_val is in a2:a3 pair
1434735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
14351d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw     rSELF, 20($sp)                # pass Thread::Current
1436590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSet64InstanceFromCode
1437590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, new_val, referrer, Thread*)
1438735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $t1, 16($sp)                  # pass referrer's Method*
14395bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1440468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_instance
14415bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
14425bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
144357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store an object reference.
14445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1445d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSetObjInstanceFromCode
1446468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_instance
1447735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
1448735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
1449590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artSetObjInstanceFromCode
1450590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                           # (field_idx, Object*, new_val, referrer, Thread*)
1451fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
14525bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
1453468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_instance
14545bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1455a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko// Macro to facilitate adding new allocation entrypoints.
14565ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.macro ONE_ARG_DOWNCALL name, entrypoint, return
14575ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    .extern \entrypoint
14585ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoENTRY \name
14595ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1460590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, \entrypoint
1461590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9
14625ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    move    $a1, rSELF                # pass Thread::Current
14635ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    \return
14645ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoEND \name
14655ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.endm
14665ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
1467cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.macro TWO_ARG_DOWNCALL name, entrypoint, return
1468cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    .extern \entrypoint
1469cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierENTRY \name
1470735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1471590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, \entrypoint
1472590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9
14731d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a2, rSELF                # pass Thread::Current
1474cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    \return
1475cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierEND \name
1476cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.endm
14775bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1478cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.macro THREE_ARG_DOWNCALL name, entrypoint, return
1479cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    .extern \entrypoint
1480cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierENTRY \name
1481735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1482590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, \entrypoint
1483590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9
14841d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a3, rSELF                # pass Thread::Current
1485cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    \return
1486cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierEND \name
1487cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.endm
14885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1489848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1490848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao    .extern \entrypoint
1491848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff HaoENTRY \name
1492a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1493590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, \entrypoint
1494590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9
1495a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko    sw      rSELF, 16($sp)            # pass Thread::Current
1496848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao    \return
1497848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff HaoEND \name
1498848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao.endm
1499848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao
15007410f29b4dae223befac036ea567d7f33351dad1Mathieu Chartier// Generate the allocation entrypoints for each allocator.
1501712c59d160325d5759300427ab596cf8321a4156Pavle BatutaGENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR
150210d4c08c0ea9df0a85a11e1c77974df24078c0ecHiroshi Yamauchi
1503712c59d160325d5759300427ab596cf8321a4156Pavle Batuta// A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc).
1504712c59d160325d5759300427ab596cf8321a4156Pavle BatutaENTRY art_quick_alloc_object_rosalloc
1505712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1506712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Fast path rosalloc allocation
1507712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # a0: type_idx
1508712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # a1: ArtMethod*
1509712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # s1: Thread::Current
1510712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # -----------------------------
1511712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t0: class
1512712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t1: object size
1513712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t2: rosalloc run
1514712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t3: thread stack top offset
1515712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t4: thread stack bottom offset
1516712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # v0: free list head
1517712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    #
1518712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # t5, t6 : temps
1519712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1520712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t0, ART_METHOD_DEX_CACHE_TYPES_OFFSET_32($a1)       # Load dex cache resolved types
1521712c59d160325d5759300427ab596cf8321a4156Pavle Batuta                                                               # array.
1522712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1523712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sll   $t5, $a0, COMPRESSED_REFERENCE_SIZE_SHIFT            # Shift the value.
1524712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addu  $t5, $t0, $t5                                        # Compute the index.
1525712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t0, 0($t5)                                          # Load class (t0).
1526712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    beqz  $t0, .Lart_quick_alloc_object_rosalloc_slow_path
1527712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1528712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    li    $t6, MIRROR_CLASS_STATUS_INITIALIZED
1529712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t5, MIRROR_CLASS_STATUS_OFFSET($t0)                 # Check class status.
1530712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    bne   $t5, $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1531712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1532712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Add a fake dependence from the following access flag and size loads to the status load. This
1533712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # is to prevent those loads from being reordered above the status load and reading wrong values.
1534712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    xor   $t5, $t5, $t5
1535712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addu  $t0, $t0, $t5
1536712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1537712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t5, MIRROR_CLASS_ACCESS_FLAGS_OFFSET($t0)           # Check if access flags has
1538712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    li    $t6, ACCESS_FLAGS_CLASS_IS_FINALIZABLE               # kAccClassIsFinalizable.
1539712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    and   $t6, $t5, $t6
1540712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    bnez  $t6, .Lart_quick_alloc_object_rosalloc_slow_path
1541712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1542712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)        # Check if thread local allocation
1543712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t4, THREAD_LOCAL_ALLOC_STACK_END_OFFSET($s1)        # stack has any room left.
1544712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    bgeu  $t3, $t4, .Lart_quick_alloc_object_rosalloc_slow_path
1545712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1546712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t1, MIRROR_CLASS_OBJECT_SIZE_OFFSET($t0)            # Load object size (t1).
1547712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    li    $t5, ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE          # Check if size is for a thread local
1548712c59d160325d5759300427ab596cf8321a4156Pavle Batuta                                                               # allocation.
1549712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    bgtu  $t1, $t5, .Lart_quick_alloc_object_rosalloc_slow_path
1550712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1551712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Compute the rosalloc bracket index from the size. Allign up the size by the rosalloc bracket
1552712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # quantum size and divide by the quantum size and subtract by 1.
1553712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1554712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addiu $t1, $t1, -1                                         # Decrease obj size and shift right
1555712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    srl   $t1, $t1, ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT        # by quantum.
1556712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1557712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sll   $t2, $t1, POINTER_SIZE_SHIFT
1558712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addu  $t2, $t2, $s1
1559712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t2, THREAD_ROSALLOC_RUNS_OFFSET($t2)                # Load rosalloc run (t2).
1560712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1561712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Load the free list head (v0).
1562712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # NOTE: this will be the return val.
1563712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1564712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $v0, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1565712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    beqz  $v0, .Lart_quick_alloc_object_rosalloc_slow_path
1566712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    nop
1567712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1568712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Load the next pointer of the head and update the list head with the next pointer.
1569712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1570712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t5, ROSALLOC_SLOT_NEXT_OFFSET($v0)
1571712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sw    $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)($t2)
1572712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1573712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Store the class pointer in the header. This also overwrites the first pointer. The offsets are
1574712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # asserted to match.
1575712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1576712c59d160325d5759300427ab596cf8321a4156Pavle Batuta#if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET
1577712c59d160325d5759300427ab596cf8321a4156Pavle Batuta#error "Class pointer needs to overwrite next pointer."
1578712c59d160325d5759300427ab596cf8321a4156Pavle Batuta#endif
1579712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1580712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    POISON_HEAP_REF $t0
1581712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sw    $t0, MIRROR_OBJECT_CLASS_OFFSET($v0)
1582712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1583712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Push the new object onto the thread local allocation stack and increment the thread local
1584712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # allocation stack top.
1585712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1586712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sw    $v0, 0($t3)
1587712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addiu $t3, $t3, COMPRESSED_REFERENCE_SIZE
1588712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sw    $t3, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET($s1)
1589712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1590712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    # Decrement the size of the free list.
1591712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1592712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    lw    $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1593712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    addiu $t5, $t5, -1
1594712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sw    $t5, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)($t2)
1595712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1596712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    sync                                                          # Fence.
1597712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1598712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    jalr  $zero, $ra
1599712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    nop
1600712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1601712c59d160325d5759300427ab596cf8321a4156Pavle Batuta  .Lart_quick_alloc_object_rosalloc_slow_path:
1602712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1603712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
1604590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la    $t9, artAllocObjectFromCodeRosAlloc
1605590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr  $t9
1606cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen    move  $a2, $s1                                                # Pass self as argument.
1607712c59d160325d5759300427ab596cf8321a4156Pavle Batuta    RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
1608712c59d160325d5759300427ab596cf8321a4156Pavle Batuta
1609712c59d160325d5759300427ab596cf8321a4156Pavle BatutaEND art_quick_alloc_object_rosalloc
16103b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
161110d4c08c0ea9df0a85a11e1c77974df24078c0ecHiroshi YamauchiGENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB)
161210d4c08c0ea9df0a85a11e1c77974df24078c0ecHiroshi YamauchiGENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB)
161310d4c08c0ea9df0a85a11e1c77974df24078c0ecHiroshi Yamauchi
16145bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
16151cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
16165ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * exception on error. On success the String is returned. A0 holds the string index. The fast
16175ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * path check for hit in strings cache has already been performed.
16181cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
16195ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
16201cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
16211cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
16221cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when uninitialized static storage, this stub will run the class
16231cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * initializer and deliver the exception on error. On success the static storage base is
16241cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * returned.
16251cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
16265ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
16271cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
16281cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
16291cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when dex cache misses for a type_idx.
16301cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
16315ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
16321cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
16331cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
16341cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when type_idx needs to be checked for access and dex cache may also
16351cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * miss.
16361cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
16375ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
16381cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
16391cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
164057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code when the value in rSUSPEND has been decremented to 0.
16415bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1642d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artTestSuspendFromCode
1643d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_test_suspend
1644474b6da273c7ce6df50a4e51eb9929a77e1611c3Ian Rogers    lh     $a0, THREAD_FLAGS_OFFSET(rSELF)
16457fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez   $a0, 1f
1646e34652f15f32666323052a6718a63248244f1e66Duane Sand    addiu  rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL   # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
16478d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
16485bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
16495bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
16501d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME          # save callee saves for stack crawl
1651590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la     $t9, artTestSuspendFromCode
1652590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr   $t9                                 # (Thread*)
16537fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a0, rSELF
16541d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
1655d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_test_suspend
16565bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
16575bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
16585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code that is attempting to call a method on a proxy class. On entry
1659590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic     * a0 holds the proxy method; a1, a2 and a3 may contain arguments.
16605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
16615fa60c3db4208df407113b5a69d295a9c93d53b1Jeff Hao    .extern artQuickProxyInvokeHandler
1662d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_proxy_invoke_handler
1663735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1664735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, rSELF                  # pass Thread::Current
1665590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artQuickProxyInvokeHandler
1666590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                         # (Method* proxy method, receiver, Thread*, SP)
1667735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a3, $sp, ARG_SLOT_SIZE     # pass $sp (remove arg slots)
16687fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1669735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
16707fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez    $t0, 1f
1671e34652f15f32666323052a6718a63248244f1e66Duane Sand    # don't care if $v0 and/or $v1 are modified, when exception branch taken
1672e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1          # move float value to return value
16738d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1674e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
16755bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
16765bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
1677d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_proxy_invoke_handler
16785bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
167988474b416eb257078e590bf9bc7957cee604a186Jeff Hao    /*
168059028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic     * Called to resolve an imt conflict.
168159028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic     * a0 is the conflict ArtMethod.
168259028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic     * t0 is a hidden argument that holds the target interface method's dex method index.
168359028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic     *
168459028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic     * Note that this stub writes to a0, t0 and t1.
168588474b416eb257078e590bf9bc7957cee604a186Jeff Hao     */
168613738bf7c769638b7922cb2477471ad382632bc2Douglas LeungENTRY art_quick_imt_conflict_trampoline
168759028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $t1, 0($sp)                                      # Load referrer.
168859028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $t1, ART_METHOD_DEX_CACHE_METHODS_OFFSET_32($t1) # Load dex cache methods array.
168959028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    sll     $t0, $t0, POINTER_SIZE_SHIFT                     # Calculate offset.
169059028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    addu    $t0, $t1, $t0                                    # Add offset to base.
169159028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $t0, 0($t0)                                      # Load interface method.
169259028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $a0, ART_METHOD_JNI_OFFSET_32($a0)               # Load ImtConflictTable.
169359028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic
169459028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic.Limt_table_iterate:
169559028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $t1, 0($a0)                                      # Load next entry in ImtConflictTable.
169659028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    # Branch if found.
169759028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    beq     $t1, $t0, .Limt_table_found
169859028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    nop
169959028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    # If the entry is null, the interface method is not in the ImtConflictTable.
170059028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    beqz    $t1, .Lconflict_trampoline
170159028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    nop
170259028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    # Iterate over the entries of the ImtConflictTable.
170359028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    b       .Limt_table_iterate
170459028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    addiu   $a0, $a0, 2 * __SIZEOF_POINTER__                 # Iterate to the next entry.
170559028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic
170659028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic.Limt_table_found:
170759028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    # We successfully hit an entry in the table. Load the target method and jump to it.
170859028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $a0, __SIZEOF_POINTER__($a0)
170959028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    lw      $t9, ART_METHOD_QUICK_CODE_OFFSET_32($a0)
171059028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    jr      $t9
171159028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    nop
171259028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic
171359028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic.Lconflict_trampoline:
171459028d90d51a800bcea8be354d77d7be924da3a0Goran Jakovljevic    # Call the runtime stub to populate the ImtConflictTable and jump to the resolved method.
17153031c8da0c5009183f770b005c245f9bf2a4d01bAndreas Gampe    INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline
171688474b416eb257078e590bf9bc7957cee604a186Jeff HaoEND art_quick_imt_conflict_trampoline
171788474b416eb257078e590bf9bc7957cee604a186Jeff Hao
1718468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickResolutionTrampoline
1719468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_resolution_trampoline
17201d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1721735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, rSELF                    # pass Thread::Current
1722590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artQuickResolutionTrampoline
1723590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                           # (Method* called, receiver, Thread*, SP)
1724735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a3, $sp, ARG_SLOT_SIZE       # pass $sp (remove arg slots)
1725468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    beqz    $v0, 1f
1726735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a0, ARG_SLOT_SIZE($sp)       # load resolved method to $a0
17271d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
172865d1b22d0b02fb0111f69013163c8170e68392f1Ian Rogers    move    $t9, $v0               # code pointer must be in $t9 to generate the global pointer
1729f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    jalr    $zero, $t9             # tail call to method
17301984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    nop
1731468532ea115657709bc32ee498e701a4c71762d4Ian Rogers1:
17321d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1733468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    DELIVER_PENDING_EXCEPTION
1734468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_resolution_trampoline
1735468532ea115657709bc32ee498e701a4c71762d4Ian Rogers
1736735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .extern artQuickGenericJniTrampoline
1737735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .extern artQuickGenericJniEndTrampoline
1738735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas LeungENTRY art_quick_generic_jni_trampoline
1739735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1740735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $s8, $sp               # save $sp to $s8
1741735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $s3, $gp               # save $gp to $s3
1742735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1743735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1744735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a0, rSELF                     # pass Thread::Current
1745735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a1, $sp, ARG_SLOT_SIZE        # save $sp (remove arg slots)
1746590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artQuickGenericJniTrampoline
1747590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                            # (Thread*, SP)
1748735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, -5120                # reserve space on the stack
1749735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1750735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # The C call will have registered the complete save-frame on success.
1751735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # The result of the call is:
1752735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # v0: ptr to native code, 0 on error.
1753735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1754735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    beq     $v0, $zero, 1f         # check entry error
1755735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $t9, $v0               # save the code ptr
1756735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $sp, $v1               # release part of the alloca
1757735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1758735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # Load parameters from stack into registers
1759735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a0,   0($sp)
1760735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a1,   4($sp)
1761735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a2,   8($sp)
1762735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1763735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1764735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jalr    $t9                    # native call
1765735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a3,  12($sp)
1766735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, 16           # remove arg slots
1767735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1768735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $gp, $s3               # restore $gp from $s3
1769735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1770735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # result sign extension is handled in C code
1771735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1772735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a0, rSELF             # pass Thread::Current
1773735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, $v0               # pass result
1774735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a3, $v1
1775735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, -24          # reserve arg slots
1776590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artQuickGenericJniEndTrampoline
1777590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9
1778735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    s.d     $f0, 16($sp)           # pass result_f
1779735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1780735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1781126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    bne     $t0, $zero, 1f         # check for pending exceptions
1782126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray
1783735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $sp, $s8               # tear down the alloca
1784735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1785735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # tear dpown the callee-save frame
1786735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1787735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1788e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1     # move float value to return value
17898d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1790e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1791735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1792735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung1:
1793126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1794126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    # This will create a new save-all frame, required by the runtime.
1795735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    DELIVER_PENDING_EXCEPTION
1796735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas LeungEND art_quick_generic_jni_trampoline
17972da882315a61072664f7ce3c212307342e907207Andreas Gampe
1798468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickToInterpreterBridge
1799468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_to_interpreter_bridge
18001d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1801735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a1, rSELF                          # pass Thread::Current
1802590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la      $t9, artQuickToInterpreterBridge
1803590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr    $t9                                 # (Method* method, Thread*, SP)
1804735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a2, $sp, ARG_SLOT_SIZE             # pass $sp (remove arg slots)
18057db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1806735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
18077db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    bnez    $t0, 1f
1808e34652f15f32666323052a6718a63248244f1e66Duane Sand    # don't care if $v0 and/or $v1 are modified, when exception branch taken
1809e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1                  # move float value to return value
18108d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1811e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
18127db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers1:
18137db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    DELIVER_PENDING_EXCEPTION
1814468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_to_interpreter_bridge
18157db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers
18165bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
1817725a957985171d712d5c048cc3d00ff14968784bjeffhao     * Routine that intercepts method calls and returns.
18185bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1819d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artInstrumentationMethodEntryFromCode
1820d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artInstrumentationMethodExitFromCode
1821468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_instrumentation_entry
18221d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1823735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw       $a0, 28($sp)   # save arg0 in free arg slot
18241d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move     $a3, $ra       # pass $ra
1825590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la       $t9, artInstrumentationMethodEntryFromCode
1826590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr     $t9            # (Method*, Object*, Thread*, LR)
182762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a2, rSELF     # pass Thread::Current
18288161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    move     $t9, $v0       # $t9 holds reference to code
1829735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw       $a0, 28($sp)   # restore arg0 from free arg slot
18301d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
18318161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    jalr     $t9            # call method
183262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    nop
1833468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_entry
18345bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* intentional fallthrough */
1835468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .global art_quick_instrumentation_exit
1836468532ea115657709bc32ee498e701a4c71762d4Ian Rogersart_quick_instrumentation_exit:
1837d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .cfi_startproc
183812051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    addiu    $t9, $ra, 4    # put current address into $t9 to rebuild $gp
18391d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    .cpload  $t9
1840c3d131e1ec030b4ff5c44fe2a45d5fb45b3295afDouglas Leung    move     $ra, $zero     # link register is to here, so clobber with 0 for later checks
1841735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1842f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
1843735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu    $sp, $sp, -16  # allocate temp storage on the stack
1844735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset 16
1845f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    sw       $v0, ARG_SLOT_SIZE+12($sp)
1846f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_rel_offset 2, ARG_SLOT_SIZE+12
1847f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    sw       $v1, ARG_SLOT_SIZE+8($sp)
1848f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_rel_offset 3, ARG_SLOT_SIZE+8
1849f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    s.d      $f0, ARG_SLOT_SIZE($sp)
1850e34652f15f32666323052a6718a63248244f1e66Duane Sand    s.d      $f0, 16($sp)   # pass fpr result
185162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a2, $v0       # pass gpr result
185262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a3, $v1
1853f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    addiu    $a1, $sp, ARG_SLOT_SIZE+16   # pass $sp (remove arg slots and temp storage)
1854590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la       $t9, artInstrumentationMethodExitFromCode
1855590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr     $t9            # (Thread*, SP, gpr_res, fpr_res)
185612051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    move     $a0, rSELF     # pass Thread::Current
1857f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    move     $t9, $v0       # set aside returned link register
185812051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    move     $ra, $v1       # set link register for deoptimization
1859f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    lw       $v0, ARG_SLOT_SIZE+12($sp)   # restore return values
1860f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    lw       $v1, ARG_SLOT_SIZE+8($sp)
1861f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    l.d      $f0, ARG_SLOT_SIZE($sp)
1862f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    jalr     $zero, $t9     # return
1863590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    addiu    $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16  # restore stack
1864f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16)
1865468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_exit
18665bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
186712051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    /*
186862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
186962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * will long jump to the upcall with a special exception of -1.
187012051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao     */
1871d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artDeoptimize
1872d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_deoptimize
187314dd5a82ad85a28612bf86e755ff929d767cea4cJeff Hao    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1874590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la       $t9, artDeoptimize
1875590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr     $t9            # artDeoptimize(Thread*)
187612051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao                            # Returns caller method's frame size.
18771d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move     $a0, rSELF     # pass Thread::current
1878d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_deoptimize
187912051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao
18805bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
18810747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     * Compiled code has requested that we deoptimize into the interpreter. The deoptimization
18820747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     * will long jump to the upcall with a special exception of -1.
18830747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz     */
18840747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    .extern artDeoptimizeFromCompiledCode
18850747466fca310eedea5fc49e37d54f240a0b3c0fSebastien HertzENTRY art_quick_deoptimize_from_compiled_code
18860747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
1887590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    la       $t9, artDeoptimizeFromCompiledCode
1888590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic    jalr     $t9                            # artDeoptimizeFromCompiledCode(Thread*)
18890747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz                                            # Returns caller method's frame size.
18900747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    move     $a0, rSELF                     # pass Thread::current
18910747466fca310eedea5fc49e37d54f240a0b3c0fSebastien HertzEND art_quick_deoptimize_from_compiled_code
18920747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz
18930747466fca310eedea5fc49e37d54f240a0b3c0fSebastien Hertz    /*
18945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
18955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
18965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
18975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
18985bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
18997fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a0: low word
19007fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a1: high word
19017fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a2: shift count
19025bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
19031d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_shl_long
19045bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* shl-long vAA, vBB, vCC */
19057fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $v0, $a0, $a2                    #  rlo<- alo << (shift&31)
19067fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $v1, $a2                         #  rhi<- 31-shift  (shift is 5b)
19077fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $a0, 1
19087fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $a0, $v1                         #  alo<- alo >> (32-(shift&31))
19097fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $v1, $a1, $a2                    #  rhi<- ahi << (shift&31)
19107fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift< shift & 0x20
1911e34652f15f32666323052a6718a63248244f1e66Duane Sand    beqz    $a2, 1f
1912e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v1, $a0                         #  rhi<- rhi | alo
1913e34652f15f32666323052a6718a63248244f1e66Duane Sand
1914e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $v0                         #  rhi<- rlo (if shift&0x20)
1915e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $zero                       #  rlo<- 0 (if shift&0x20)
1916e34652f15f32666323052a6718a63248244f1e66Duane Sand
19178d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1918e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1919d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_shl_long
19205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
19215bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
19225bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
19235bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
19245bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
19255bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
19265bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
19277fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a0: low word
19287fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a1: high word
19297fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a2: shift count
19305bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
19311d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_shr_long
19327fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sra     $v1, $a1, $a2                    #  rhi<- ahi >> (shift&31)
19337fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $v0, $a0, $a2                    #  rlo<- alo >> (shift&31)
19347fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sra     $a3, $a1, 31                     #  $a3<- sign(ah)
19357fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $a0, $a2                         #  alo<- 31-shift (shift is 5b)
19367fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, 1
19377fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, $a0                         #  ahi<- ahi << (32-(shift&31))
19387fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift & 0x20
1939475cfd8ff9dcc73d1a7502c9310efe0f1a30337fDouglas Leung    beqz    $a2, 1f
1940e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v0, $a1                         #  rlo<- rlo | ahi
1941e34652f15f32666323052a6718a63248244f1e66Duane Sand
1942e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $v1                         #  rlo<- rhi (if shift&0x20)
1943e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $a3                         #  rhi<- sign(ahi) (if shift&0x20)
1944e34652f15f32666323052a6718a63248244f1e66Duane Sand
19458d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1946e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1947d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_shr_long
19485bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
19495bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
19505bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
19515bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
19525bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
19535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
19545bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
1955590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic     *   $a0: low word
1956590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic     *   $a1: high word
1957590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic     *   $a2: shift count
19585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
19595bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* ushr-long vAA, vBB, vCC */
19601d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_ushr_long
1961fc6a30e2fa8f0d44e6c95bbeb5deca4b499f67cejeffhao    srl     $v1, $a1, $a2                    #  rhi<- ahi >> (shift&31)
19627fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $v0, $a0, $a2                    #  rlo<- alo >> (shift&31)
19637fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $a0, $a2                         #  alo<- 31-shift (shift is 5b)
19647fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, 1
19657fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, $a0                         #  ahi<- ahi << (32-(shift&31))
19667fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift & 0x20
1967e34652f15f32666323052a6718a63248244f1e66Duane Sand    beqz    $a2, 1f
1968e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v0, $a1                         #  rlo<- rlo | ahi
1969e34652f15f32666323052a6718a63248244f1e66Duane Sand
1970e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $v1                         #  rlo<- rhi (if shift&0x20)
1971e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $zero                       #  rhi<- 0 (if shift&0x20)
1972e34652f15f32666323052a6718a63248244f1e66Duane Sand
19738d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1974e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1975d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_ushr_long
19767fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao
1977cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* java.lang.String.indexOf(int ch, int fromIndex=0) */
1978cf283daf579e9eda586f312c3fc89444601e2525Chris LarsenENTRY_NO_GP art_quick_indexof
1979cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a0 holds address of "this" */
1980cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a1 holds "ch" */
1981cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a2 holds "fromIndex" */
1982cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lw    $t0, MIRROR_STRING_COUNT_OFFSET($a0)    # this.length()
1983590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic  slt   $t1, $a2, $zero # if fromIndex < 0
1984cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6)
1985590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic  seleqz $a2, $a2, $t1  #     fromIndex = 0;
1986cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen#else
1987590b1362b64d7feeb688d787c1d140d9b7ca78b1Goran Jakovljevic  movn   $a2, $zero, $t1 #    fromIndex = 0;
1988cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen#endif
1989cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu  $t0, $t0, $a2   # this.length() - fromIndex
1990cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  blez  $t0, 6f         # if this.length()-fromIndex <= 0
1991cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  li    $v0, -1         #     return -1;
1992cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
1993cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  sll   $v0, $a2, 1     # $a0 += $a2 * 2
1994cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  addu  $a0, $a0, $v0   #  "  "   "  " "
1995cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  move  $v0, $a2        # Set i to fromIndex.
1996cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
1997cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen1:
1998cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lhu   $t3, MIRROR_STRING_VALUE_OFFSET($a0)    # if this.charAt(i) == ch
1999cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  beq   $t3, $a1, 6f                            #     return i;
2000cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  addu  $a0, $a0, 2     # i++
2001cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu  $t0, $t0, 1     # this.length() - i
2002cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  bnez  $t0, 1b         # while this.length() - i > 0
2003cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  addu  $v0, $v0, 1     # i++
2004cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2005cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  li    $v0, -1         # if this.length() - i <= 0
2006cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen                        #     return -1;
2007cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2008cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen6:
2009cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  j     $ra
2010cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  nop
2011cf283daf579e9eda586f312c3fc89444601e2525Chris LarsenEND art_quick_indexof
2012cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2013cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* java.lang.String.compareTo(String anotherString) */
2014cf283daf579e9eda586f312c3fc89444601e2525Chris LarsenENTRY_NO_GP art_quick_string_compareto
2015cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a0 holds address of "this" */
2016cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen/* $a1 holds address of "anotherString" */
2017cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  beq    $a0, $a1, 9f   # this and anotherString are the same object
2018cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  move   $v0, $zero
2019cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2020cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lw     $a2, MIRROR_STRING_COUNT_OFFSET($a0)   # this.length()
2021cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lw     $a3, MIRROR_STRING_COUNT_OFFSET($a1)   # anotherString.length()
2022cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  MINu   $t2, $a2, $a3
2023cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen# $t2 now holds min(this.length(),anotherString.length())
2024cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2025cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  beqz   $t2, 9f        # while min(this.length(),anotherString.length())-i != 0
2026cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu   $v0, $a2, $a3  # if $t2==0 return
2027cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen                        #     (this.length() - anotherString.length())
2028cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen1:
2029cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lhu    $t0, MIRROR_STRING_VALUE_OFFSET($a0)   # while this.charAt(i) == anotherString.charAt(i)
2030cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  lhu    $t1, MIRROR_STRING_VALUE_OFFSET($a1)
2031cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  bne    $t0, $t1, 9f   # if this.charAt(i) != anotherString.charAt(i)
2032cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu   $v0, $t0, $t1  #     return (this.charAt(i) - anotherString.charAt(i))
2033cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  addiu  $a0, $a0, 2    # point at this.charAt(i++)
2034cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu   $t2, $t2, 1    # new value of
2035cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen                        # min(this.length(),anotherString.length())-i
2036cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  bnez   $t2, 1b
2037cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  addiu  $a1, $a1, 2    # point at anotherString.charAt(i++)
2038cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  subu   $v0, $a2, $a3
2039cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen
2040cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen9:
2041cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  j      $ra
2042cf283daf579e9eda586f312c3fc89444601e2525Chris Larsen  nop
2043cf283daf579e9eda586f312c3fc89444601e2525Chris LarsenEND art_quick_string_compareto
2044