quick_entrypoints_mips.S revision 8ea18d0f066f63fa4e5d154f14327468bf288e2b
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
40735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -48
41735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset 48
425c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
435c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe     // Ugly compile-time check, but we only have the preprocessor.
44735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 48)
455c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "SAVE_ALL_CALLEE_SAVE_FRAME(MIPS) size not as expected."
465c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
475c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
48735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $ra, 44($sp)
49735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 31, 44
50735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s8, 40($sp)
51735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 30, 40
52735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $gp, 36($sp)
53735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 28, 36
54735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s7, 32($sp)
55735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 23, 32
56735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s6, 28($sp)
57735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 22, 28
58735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s5, 24($sp)
59735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 21, 24
60735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s4, 20($sp)
61735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 20, 20
62735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s3, 16($sp)
63735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 19, 16
64735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s2, 12($sp)
65735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 18, 12
66735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s1, 8($sp)
67735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 17, 8
68735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s0, 4($sp)
69735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 16, 4
70735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # 1 word for holding Method*
711d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
724af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
734af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
741d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    THIS_LOAD_REQUIRES_READ_BARRIER
754af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET($t0)
761d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
771d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
78735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
79735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
805bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
825bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
835bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that sets up the callee save frame to conform with
845bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC.
855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Does not include rSUSPEND or rSELF
86735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * callee-save: $s2-$s8 + $gp + $ra, 9 total + 2 words padding + 1 word to hold Method*
87735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $t0 and $sp
88735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
89735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_ONLY_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
911d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
92735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -48
93735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset 48
945c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
955c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
96735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 48)
975c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "REFS_ONLY_CALLEE_SAVE_FRAME(MIPS) size not as expected."
985c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
995c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
100735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $ra, 44($sp)
101735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 31, 44
102735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s8, 40($sp)
103735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 30, 40
104735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $gp, 36($sp)
105735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 28, 36
106735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s7, 32($sp)
107735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 23, 32
108735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s6, 28($sp)
109735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 22, 28
110735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s5, 24($sp)
111735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 21, 24
112735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s4, 20($sp)
113735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 20, 20
114735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s3, 16($sp)
115735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 19, 16
116735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $s2, 12($sp)
117735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_rel_offset 18, 12
118735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # 2 words for alignment and bottom word will hold Method*
1191d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
1204af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
1214af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
1221d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    THIS_LOAD_REQUIRES_READ_BARRIER
1234af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET($t0)
1241d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
1251d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
126735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
127735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
1285bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1295bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1301d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
131735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, ARG_SLOT_SIZE                # remove argument slots on the stack
132735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
133735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $ra, 44($sp)
134bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
135735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s8, 40($sp)
136bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
137735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $gp, 36($sp)
138bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 28
139735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s7, 32($sp)
140bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 23
141735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s6, 28($sp)
142bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 22
143735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s5, 24($sp)
144bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 21
145735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s4, 20($sp)
146bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 20
147735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s3, 16($sp)
148bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 19
149735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $s2, 12($sp)
150bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 18
151735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, 48
152735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -48
1535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1545bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1551d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
156735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
1578d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
158735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    nop
1595bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
1605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1615bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
1625bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that sets up the callee save frame to conform with
163735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
1641f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao     * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
1655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
166735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
1671f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    addiu  $sp, $sp, -64
1681f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_adjust_cfa_offset 64
1695c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
1705c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe    // Ugly compile-time check, but we only have the preprocessor.
1715c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 64)
1725c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(MIPS) size not as expected."
1735c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe#endif
1745c1e4352614d61fed6868567e58b96682828cb4dAndreas Gampe
1751f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $ra, 60($sp)
1761f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 31, 60
1771f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s8, 56($sp)
1781f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 30, 56
1791f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $gp, 52($sp)
1801f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 28, 52
1811f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s7, 48($sp)
1821f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 23, 48
1831f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s6, 44($sp)
1841f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 22, 44
1851f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s5, 40($sp)
1861f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 21, 40
1871f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s4, 36($sp)
1881f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 20, 36
1891f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s3, 32($sp)
1901f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 19, 32
1911f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    sw     $s2, 28($sp)
1921f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_rel_offset 18, 28
193c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    sw     $a3, 24($sp)
194c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    .cfi_rel_offset 7, 24
195c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    sw     $a2, 20($sp)
196c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    .cfi_rel_offset 6, 20
197c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    sw     $a1, 16($sp)
198c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    .cfi_rel_offset 5, 16
199fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    # bottom will hold Method*
200735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.endm
2011d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers
202735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    /*
203735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Macro that sets up the callee save frame to conform with
204735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
205735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
206735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $t0 and $sp
207735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
208735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
209735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     */
210735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
211735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
2124af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, %got(_ZN3art7Runtime9instance_E)($gp)
2134af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, 0($t0)
2141d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    THIS_LOAD_REQUIRES_READ_BARRIER
2154af77b7636fe98aae443b46a241fd9a29f16e291Douglas Leung    lw $t0, RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET($t0)
2161d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $t0, 0($sp)                                # Place Method* at bottom of stack.
2171d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
218735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
219735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
220735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.endm
221735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
222735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    /*
223735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Macro that sets up the callee save frame to conform with
224735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC.
225735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * callee-save: $a1-$a3, $s2-$s8 + $gp + $ra, 12 total + 3 words padding + method*
226735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Clobbers $sp
227735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Use $a0 as the Method* and loads it into bottom of stack.
228735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Allocates ARG_SLOT_SIZE bytes at the bottom of the stack for arg slots.
229735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     * Reserves FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE + ARG_SLOT_SIZE bytes on the stack
230735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung     */
231735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung.macro SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
232735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_REGISTERS_ONLY
233735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw $a0, 0($sp)                                # Place Method* at bottom of stack.
234735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)  # Place sp in Thread::Current()->top_quick_frame.
235735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -ARG_SLOT_SIZE               # reserve argument slots on the stack
236735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset ARG_SLOT_SIZE
2375bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2385bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2391d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers.macro RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
240735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, ARG_SLOT_SIZE                # remove argument slots on the stack
241735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset -ARG_SLOT_SIZE
2422a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $ra, 60($sp)
243bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
2442a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s8, 56($sp)
245bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
2462a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $gp, 52($sp)
247bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 28
2482a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s7, 48($sp)
249bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 23
2502a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s6, 44($sp)
251bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 22
2522a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s5, 40($sp)
253bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 21
2542a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s4, 36($sp)
255bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 20
2562a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s3, 32($sp)
257bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 19
2582a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    lw     $s2, 28($sp)
259bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 18
260c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    lw     $a3, 24($sp)
261bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 7
262c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    lw     $a2, 20($sp)
263bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 6
264c6d86725521841637bdd9564e71be3d9691db20fDouglas Leung    lw     $a1, 16($sp)
265bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 5
266468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    addiu  $sp, $sp, 64           # pop frame
2671f3bc2f0f9366594379249027622ab63673b0d3bJeff Hao    .cfi_adjust_cfa_offset -64
2685bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2695bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2705bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
2715bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
2725bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * exception is Thread::Current()->exception_
2735bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
2745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro DELIVER_PENDING_EXCEPTION
2758161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME     # save callee saves for throw
2768161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la      $t9, artDeliverPendingExceptionFromCode
2778d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $t9                   # artDeliverPendingExceptionFromCode(Thread*)
2781d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a0, rSELF                   # pass Thread::Current
2795bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2805bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro RETURN_IF_NO_EXCEPTION
2827fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw     $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
2831d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
2848161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    bnez   $t0, 1f                       # success if no exception is pending
2855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2868d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
2875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
2895bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
2905bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
2915bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
2925bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro RETURN_IF_ZERO
2931d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
2947fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez   $v0, 1f                       # success?
2955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2968d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra                    # return on success
2975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
2985bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
2995bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
3005bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
3015bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3021cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe.macro RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
3031d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME
3047fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    beqz   $v0, 1f                       # success?
3055bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3068d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra                    # return on success
3075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
3085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
3095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
3105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
3115bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3125bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
3137fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * On entry $a0 is uint32_t* gprs_ and $a1 is uint32_t* fprs_
3145bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * FIXME: just guessing about the shape of the jmpbuf.  Where will pc be?
3155bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
316d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_do_long_jump
317e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f0,  $f1,   0*8, $a1, $t1
318e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f2,  $f3,   1*8, $a1, $t1
319e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f4,  $f5,   2*8, $a1, $t1
320e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f6,  $f7,   3*8, $a1, $t1
321e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f8,  $f9,   4*8, $a1, $t1
322e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f10, $f11,  5*8, $a1, $t1
323e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f12, $f13,  6*8, $a1, $t1
324e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f14, $f15,  7*8, $a1, $t1
325e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f16, $f17,  8*8, $a1, $t1
326e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f18, $f19,  9*8, $a1, $t1
327e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f20, $f21, 10*8, $a1, $t1
328e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f22, $f23, 11*8, $a1, $t1
329e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f24, $f25, 12*8, $a1, $t1
330e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f26, $f27, 13*8, $a1, $t1
331e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f28, $f29, 14*8, $a1, $t1
332e34652f15f32666323052a6718a63248244f1e66Duane Sand    LDu  $f30, $f31, 15*8, $a1, $t1
333e34652f15f32666323052a6718a63248244f1e66Duane Sand
334748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set push
335748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set nomacro
336748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set noat
3377fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $at, 4($a0)
338748dd957eecbce2f379a3182ce95c19be308a54eChris Dearman    .set pop
3397fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $v0, 8($a0)
3407fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $v1, 12($a0)
3417fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a1, 20($a0)
3427fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a2, 24($a0)
3437fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a3, 28($a0)
3447fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t0, 32($a0)
3457fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t1, 36($a0)
3467fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t2, 40($a0)
3477fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t3, 44($a0)
3487fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t4, 48($a0)
3497fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t5, 52($a0)
3507fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t6, 56($a0)
3517fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t7, 60($a0)
3527fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s0, 64($a0)
3537fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s1, 68($a0)
3547fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s2, 72($a0)
3557fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s3, 76($a0)
3567fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s4, 80($a0)
3577fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s5, 84($a0)
3587fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s6, 88($a0)
3597fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $s7, 92($a0)
3607fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t8, 96($a0)
3617fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t9, 100($a0)
3627fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $gp, 112($a0)
3637fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $sp, 116($a0)
3647fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $fp, 120($a0)
3657fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $ra, 124($a0)
3667fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $a0, 16($a0)
3677fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $v0, $zero          # clear result registers r0 and r1
3688d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra          # do long jump
3697fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $v1, $zero
370d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_do_long_jump
3715bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3725bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
3735bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code, saves most registers (forms basis of long jump context) and passes
3745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
3755bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * the bottom of the thread. On entry r0 holds Throwable*
3765bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
377468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_deliver_exception
37857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
3798161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artDeliverExceptionFromCode
3808d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artDeliverExceptionFromCode(Throwable*, Thread*)
3811d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a1, rSELF                 # pass Thread::Current
382468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_deliver_exception
3835bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3845bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
3855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver a NullPointerException
3865bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
387d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowNullPointerExceptionFromCode
388468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_null_pointer_exception
38957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
3908161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowNullPointerExceptionFromCode
3918d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowNullPointerExceptionFromCode(Thread*)
3921d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
393468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_null_pointer_exception
3945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
3955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
3965bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver an ArithmeticException
3975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
398d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowDivZeroFromCode
399468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_div_zero
40057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4018161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowDivZeroFromCode
4028d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowDivZeroFromCode(Thread*)
4031d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
404468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_div_zero
4055bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4065bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
4075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
4085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
409d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowArrayBoundsFromCode
410468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_array_bounds
41157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4128161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowArrayBoundsFromCode
4138d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowArrayBoundsFromCode(index, limit, Thread*)
4141d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
415468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_array_bounds
4165bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
41757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
41857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a StackOverflowError.
41957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     */
420d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowStackOverflowFromCode
421468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_stack_overflow
42257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4238161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowStackOverflowFromCode
4248d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowStackOverflowFromCode(Thread*)
4251d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a0, rSELF                 # pass Thread::Current
426468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_stack_overflow
4275bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
42857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
42957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a NoSuchMethodError.
43057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     */
431d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artThrowNoSuchMethodFromCode
432468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_throw_no_such_method
43357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
4348161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    la   $t9, artThrowNoSuchMethodFromCode
4358d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowNoSuchMethodFromCode(method_idx, Thread*)
4361d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a1, rSELF                 # pass Thread::Current
437468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_throw_no_such_method
4385bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4395bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
4405bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * All generated callsites for interface invokes and invocation slow paths will load arguments
4417fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * as usual - except instead of loading arg0/$a0 with the target Method*, arg0/$a0 will contain
4427ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray     * the method_idx.  This wrapper will save arg1-arg3, and call the appropriate C helper.
4437fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * NOTE: "this" is first visable argument of the target, and so can be found in arg1/$a1.
4445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
4457fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * The helper will attempt to locate the target and return a 64-bit result in $v0/$v1 consisting
4467fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     * of the target Method* in $v0 and method->code_ in $v1.
4475bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
4482cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier     * If unsuccessful, the helper will return null/null. There will be a pending exception in the
4495bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * thread and we branch to another stub to deliver it.
4505bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *
4515bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
4525bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * pointing back to the original caller.
4535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
4545bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.macro INVOKE_TRAMPOLINE c_name, cxx_name
4555bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    .extern \cxx_name
456d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY \c_name
4571d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME  # save callee saves in case allocation triggers GC
4587ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a2, rSELF                       # pass Thread::Current
4597ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    jal   \cxx_name                        # (method_idx, this, Thread*, $sp)
4607ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    addiu $a3, $sp, ARG_SLOT_SIZE          # pass $sp (remove arg slots)
4617ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $a0, $v0                         # save target Method*
4621d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
463fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    beqz  $v0, 1f
4647ea6a170486d81b127e69673cd1020c4db628c93Nicolas Geoffray    move  $t9, $v1                         # save $v0->code_
4658d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $t9
4665bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
4675bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
4685bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
469d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND \c_name
4705bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee.endm
4715bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4728dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
4738dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
4745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
4758dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
4768dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
4778dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
4788dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
4795bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
48079fe539587d4c09244172d0168eeed0ec9770466Jeff Hao    /*
481ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers     * Invocation stub for quick code.
4825d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     * On entry:
4835d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a0 = method pointer
4842cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier     *   a1 = argument array or null for no argument methods
4855d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a2 = size of argument array in bytes
4865d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     *   a3 = (managed) thread pointer
4876474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   [sp + 16] = JValue* result
4880177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers     *   [sp + 20] = shorty
4895d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     */
4905d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoENTRY art_quick_invoke_stub
4915d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $a0, 0($sp)           # save out a0
4925d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, -16         # spill s0, s1, fp, ra
4935d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_adjust_cfa_offset 16
4945d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $ra, 12($sp)
4955d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 31, 12
4965d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $fp, 8($sp)
4975d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 30, 8
4985d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $s1, 4($sp)
4995d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 17, 4
5005d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $s0, 0($sp)
5015d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset 16, 0
5025d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $fp, $sp              # save sp in fp
5035d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_def_cfa_register 30
5045d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $s1, $a3              # move managed thread pointer into s1
5055d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $s0, $zero, SUSPEND_CHECK_INTERVAL  # reset s0 to suspend check interval
506735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu $t0, $a2, 4           # create space for method pointer in frame.
507735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    subu  $t0, $sp, $t0         # reserve & align *stack* to 16 bytes:
508735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    srl   $t0, $t0, 4           # native calling convention only aligns to 8B,
509735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sll   $sp, $t0, 4           # so we have to ensure ART 16B alignment ourselves.
5105d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $a0, $sp, 4           # pass stack pointer + method ptr as dest for memcpy
5115d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    jal   memcpy                # (dest, src, bytes)
5125d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, -16         # make space for argument slots for memcpy
5135d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, 16          # restore stack after memcpy
5145d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $a0, 16($fp)          # restore method*
5155d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $a1, 4($sp)           # copy arg value for a1
5165d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $a2, 8($sp)           # copy arg value for a2
5175d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $a3, 12($sp)          # copy arg value for a3
5182d7210188805292e463be4bcf7a133b654d7e0eaMathieu Chartier    lw    $t9, MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32($a0)  # get pointer to the code
5195d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    jalr  $t9                   # call the method
5202cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier    sw    $zero, 0($sp)         # store null for method* at bottom of frame
5215d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    move  $sp, $fp              # restore the stack
5225d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $s0, 0($sp)
523bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 16
5245d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $s1, 4($sp)
525bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 17
5265d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $fp, 8($sp)
527bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 30
5285d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $ra, 12($sp)
529bbb32c277b800a8ee378c16a3645ab6d4d19aef1Dave Allison    .cfi_restore 31
5305d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    addiu $sp, $sp, 16
5315d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_adjust_cfa_offset -16
5325d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    lw    $t0, 16($sp)          # get result pointer
5330177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers    lw    $t1, 20($sp)          # get shorty
5340177e53ea521ad58b70c305700dab32f1ac773b7Ian Rogers    lb    $t1, 0($t1)           # get result type char
5356474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    li    $t2, 68               # put char 'D' into t2
5366474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    beq   $t1, $t2, 1f          # branch if result type char == 'D'
5376474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    li    $t3, 70               # put char 'F' into t3
5386474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    beq   $t1, $t3, 1f          # branch if result type char == 'F'
5395d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $v0, 0($t0)           # store the result
5408d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $ra
5415d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sw    $v1, 4($t0)           # store the other half of the result
5426474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao1:
543e34652f15f32666323052a6718a63248244f1e66Duane Sand    SDu   $f0, $f1, 0, $t0, $t1 # store floating point result
5448d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr  $zero, $ra
545e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
5465d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoEND art_quick_invoke_stub
5475d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao
5485d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    /*
5495bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
5505bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * failure.
5515bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
552d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artHandleFillArrayDataFromCode
553468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_handle_fill_data
554735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                    # pass referrer's Method*
555735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case exception allocation triggers GC
5561d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artHandleFillArrayDataFromCode # (payload offset, Array*, method, Thread*)
557832336b3c9eb892045a8de1bb12c9361112ca3c5Ian Rogers    move   $a3, rSELF                     # pass Thread::Current
558fc6a30e2fa8f0d44e6c95bbeb5deca4b499f67cejeffhao    RETURN_IF_ZERO
559468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_handle_fill_data
5605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5615bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
56257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Entry from managed code that calls artLockObjectFromCode, may block for GC.
5635bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
564d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artLockObjectFromCode
565468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_lock_object
56686bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
567a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
568735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME     # save callee saves in case we block
5691d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal     artLockObjectFromCode         # (Object* obj, Thread*)
5707fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $a1, rSELF                    # pass Thread::Current
5716bcd163d322b867578fbcfe60e4e3b247c42974bIan Rogers    RETURN_IF_ZERO
572468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_lock_object
5735bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
5755bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
5765bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
577d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artUnlockObjectFromCode
578468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_unlock_object
57986bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz    $a0, .Lart_quick_throw_null_pointer_exception_gp_set
580a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
581735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC
5821d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal     artUnlockObjectFromCode   # (Object* obj, Thread*)
5837fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move    $a1, rSELF                # pass Thread::Current
5845bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
585468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_unlock_object
5865bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
5875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
5885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
5895bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
590a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .extern artThrowClassCastException
591468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_check_cast
592a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    addiu  $sp, $sp, -16
593a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset 16
594a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $ra, 12($sp)
595a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset 31, 12
596a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $t9, 8($sp)
597a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a1, 4($sp)
598a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a0, 0($sp)
599a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    jal    artIsAssignableFromCode
600735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, -16             # reserve argument slots on the stack
601735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu  $sp, $sp, 16
60286bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz   $v0, .Lthrow_class_cast_exception
603a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $ra, 12($sp)
6048d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
605a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    addiu  $sp, $sp, 16
606a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -16
60786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Lthrow_class_cast_exception:
608a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $t9, 8($sp)
609a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a1, 4($sp)
610a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a0, 0($sp)
611a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    addiu  $sp, $sp, 16
612a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -16
613a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
614a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    la   $t9, artThrowClassCastException
6158d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowClassCastException (Class*, Class*, Thread*)
6161d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
617468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_check_cast
6185bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
6195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
620a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * Entry from managed code for array put operations of objects where the value being stored
621a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * needs to be checked for compatibility.
622a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * a0 = array, a1 = index, a2 = value
6235bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
624a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_null_and_bound_check
62586bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez    $a0, .Lart_quick_aput_obj_with_bound_check_gp_set
626a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
62786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    b .Lart_quick_throw_null_pointer_exception_gp_set
628a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
629a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_null_and_bound_check
630a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
631a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_bound_check
6321d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    lw $t0, MIRROR_ARRAY_LENGTH_OFFSET($a0)
633a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sltu $t1, $a1, $t0
63486bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez $t1, .Lart_quick_aput_obj_gp_set
635a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
636a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a0, $a1
63786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    b .Lart_quick_throw_array_bounds_gp_set
638a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a1, $t0
639a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_bound_check
640a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
641a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj
64286bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    beqz $a2, .Ldo_aput_null
643a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
6441d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    lw $t0, MIRROR_OBJECT_CLASS_OFFSET($a0)
6451d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    lw $t1, MIRROR_OBJECT_CLASS_OFFSET($a2)
6461d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    lw $t0, MIRROR_CLASS_COMPONENT_TYPE_OFFSET($t0)
64786bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bne $t1, $t0, .Lcheck_assignability  # value's type == array's component type - trivial assignability
648a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
64986bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Ldo_aput:
650a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sll $a1, $a1, 2
651a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t0, $a0, $a1
6521d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw  $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
653a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw  $t0, THREAD_CARD_TABLE_OFFSET(rSELF)
654a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    srl $t1, $a0, 7
655a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t1, $t1, $t0
656a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sb  $t0, ($t1)
6578d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $ra
658a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
65986bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Ldo_aput_null:
660a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sll $a1, $a1, 2
661a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add $t0, $a0, $a1
6621d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw  $a2, MIRROR_OBJECT_ARRAY_DATA_OFFSET($t0)
6638d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $ra
664a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
66586bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers.Lcheck_assignability:
666a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    addiu  $sp, $sp, -32
667a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset 32
668a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $ra, 28($sp)
669a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset 31, 28
670a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $t9, 12($sp)
671a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a2, 8($sp)
672a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a1, 4($sp)
673a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sw     $a0, 0($sp)
674a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move   $a1, $t1
675a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move   $a0, $t0
676a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    jal    artIsAssignableFromCode  # (Class*, Class*)
677735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu $sp, $sp, -16     # reserve argument slots on the stack
678735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu $sp, $sp, 16
679a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $ra, 28($sp)
680a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $t9, 12($sp)
681a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a2, 8($sp)
682a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a1, 4($sp)
683a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lw     $a0, 0($sp)
684e34652f15f32666323052a6718a63248244f1e66Duane Sand    addiu  $sp, 32
685a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -32
68686bcdc251f5ae22fcedd18c096ea538b7dbfa8cbIan Rogers    bnez   $v0, .Ldo_aput
687a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    nop
688a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
689a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    move $a1, $a2
690a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    la   $t9, artThrowArrayStoreException
6918d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr $zero, $t9                 # artThrowArrayStoreException(Class*, Class*, Thread*)
6921d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move $a2, rSELF                 # pass Thread::Current
693a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj
6945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
6955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
69637f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a boolean primitive value.
69737f05ef45e0393de812d51261dc293240c17294dFred Shih     */
69837f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetBooleanStaticFromCode
69937f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_boolean_static
700735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
701735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7021d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetBooleanStaticFromCode   # (uint32_t field_idx, const Method* referrer, Thread*)
70337f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
70437f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
70537f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_boolean_static
70637f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
70737f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a byte primitive value.
70837f05ef45e0393de812d51261dc293240c17294dFred Shih     */
70937f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetByteStaticFromCode
71037f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_byte_static
711735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
712735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7131d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetByteStaticFromCode      # (uint32_t field_idx, const Method* referrer, Thread*)
71437f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
71537f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
71637f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_byte_static
71737f05ef45e0393de812d51261dc293240c17294dFred Shih
71837f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
71937f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a char primitive value.
72037f05ef45e0393de812d51261dc293240c17294dFred Shih     */
72137f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetCharStaticFromCode
72237f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_char_static
723735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
724735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7251d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetCharStaticFromCode      # (uint32_t field_idx, const Method* referrer, Thread*)
72637f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
72737f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
72837f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_char_static
72937f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
73037f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and load a short primitive value.
73137f05ef45e0393de812d51261dc293240c17294dFred Shih     */
73237f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetShortStaticFromCode
73337f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_short_static
734735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
735735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7361d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetShortStaticFromCode     # (uint32_t field_idx, const Method* referrer, Thread*)
73737f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a2, rSELF                    # pass Thread::Current
73837f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
73937f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_short_static
7405bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
7415bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
74257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 32-bit primitive value.
7435bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
744d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet32StaticFromCode
745468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_static
746735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
747735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7481d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGet32StaticFromCode        # (uint32_t field_idx, const Method* referrer, Thread*)
7497fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
7505bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
751468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_static
7525bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
7535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
75457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 64-bit primitive value.
7555bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
756d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet64StaticFromCode
757468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_static
758735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
759735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7601d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGet64StaticFromCode        # (uint32_t field_idx, const Method* referrer, Thread*)
7617fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
7625bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
763468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_static
7645bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
7655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
76657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load an object reference.
7675bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
768d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGetObjStaticFromCode
769468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_static
770735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
771735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7721d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetObjStaticFromCode       # (uint32_t field_idx, const Method* referrer, Thread*)
7737fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a2, rSELF                    # pass Thread::Current
7745bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
775468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_static
7765bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
7775bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
77837f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a boolean primitive value.
77937f05ef45e0393de812d51261dc293240c17294dFred Shih     */
78037f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetBooleanInstanceFromCode
78137f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_boolean_instance
782735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
783735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7841d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetBooleanInstanceFromCode # (field_idx, Object*, referrer, Thread*)
78537f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
78637f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
78737f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_boolean_instance
78837f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
78937f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a byte primitive value.
79037f05ef45e0393de812d51261dc293240c17294dFred Shih     */
79137f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetByteInstanceFromCode
79237f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_byte_instance
793735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
794735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
7951d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetByteInstanceFromCode    # (field_idx, Object*, referrer, Thread*)
79637f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
79737f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
79837f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_byte_instance
79937f05ef45e0393de812d51261dc293240c17294dFred Shih
80037f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
80137f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a char primitive value.
80237f05ef45e0393de812d51261dc293240c17294dFred Shih     */
80337f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetCharInstanceFromCode
80437f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_char_instance
805735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
806735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
8071d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetCharInstanceFromCode    # (field_idx, Object*, referrer, Thread*)
80837f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
80937f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
81037f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_char_instance
81137f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
81237f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and load a short primitive value.
81337f05ef45e0393de812d51261dc293240c17294dFred Shih     */
81437f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artGetShortInstanceFromCode
81537f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_get_short_instance
816735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
817735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
818735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal    artGetShortInstanceFromCode   # (field_idx, Object*, referrer, Thread*)
81937f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
82037f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_NO_EXCEPTION
82137f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_get_short_instance
82237f05ef45e0393de812d51261dc293240c17294dFred Shih
82337f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
82457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 32-bit primitive value.
8255bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
826d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet32InstanceFromCode
827468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_instance
828735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
829735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
830735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal    artGet32InstanceFromCode      # (field_idx, Object*, referrer, Thread*)
8317fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
8325bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
833468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_instance
8345bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
8355bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
83657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 64-bit primitive value.
8375bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
838d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGet64InstanceFromCode
839468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_instance
840735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
841735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
842735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal    artGet64InstanceFromCode      # (field_idx, Object*, referrer, Thread*)
8437fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
8445bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
845468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_instance
8465bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
8475bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
84857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load an object reference.
8495bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
850d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artGetObjInstanceFromCode
851468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_instance
852735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
853735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
8541d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artGetObjInstanceFromCode     # (field_idx, Object*, referrer, Thread*)
8557fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
8565bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_NO_EXCEPTION
857468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_instance
8585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
8595bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
86037f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and store a 8-bit primitive value.
86137f05ef45e0393de812d51261dc293240c17294dFred Shih     */
86237f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet8StaticFromCode
86337f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set8_static
864735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
865735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
8661d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet8StaticFromCode         # (field_idx, new_val, referrer, Thread*)
86737f05ef45e0393de812d51261dc293240c17294dFred Shih    move   $a3, rSELF                    # pass Thread::Current
86837f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
86937f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set8_static
87037f05ef45e0393de812d51261dc293240c17294dFred Shih
87137f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
87237f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve a static field and store a 16-bit primitive value.
87337f05ef45e0393de812d51261dc293240c17294dFred Shih     */
87437f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet16StaticFromCode
87537f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set16_static
876735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
877735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
87837f05ef45e0393de812d51261dc293240c17294dFred Shih    jal    artSet16StaticFromCode        # (field_idx, new_val, referrer, Thread*, $sp)
8791d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move   $a3, rSELF                    # pass Thread::Current
88037f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
88137f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set16_static
88237f05ef45e0393de812d51261dc293240c17294dFred Shih
88337f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
88457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 32-bit primitive value.
8855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
886d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSet32StaticFromCode
887468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_static
888735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
889735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
8901d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet32StaticFromCode        # (field_idx, new_val, referrer, Thread*)
8917fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
8925bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
893468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_static
8945bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
8955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
89657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 64-bit primitive value.
8975bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
89837f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet64StaticFromCode
899468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_static
900735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a1, 0($sp)                   # pass referrer's Method*
9018d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe                                         # 64 bit new_val is in a2:a3 pair
902735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9031d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet64StaticFromCode        # (field_idx, referrer, new_val, Thread*)
904fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
9055bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
906468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_static
9075bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9085bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
90957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store an object reference.
9105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
911d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSetObjStaticFromCode
912468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_static
913735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a2, 0($sp)                   # pass referrer's Method*
914735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9157fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a3, rSELF                    # pass Thread::Current
916735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal    artSetObjStaticFromCode       # (field_idx, new_val, referrer, Thread*)
9175bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
918468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_static
9195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
92137f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and store a 8-bit primitive value.
92237f05ef45e0393de812d51261dc293240c17294dFred Shih     */
92337f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet8InstanceFromCode
92437f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set8_instance
925735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
926735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
927735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal    artSet8InstanceFromCode       # (field_idx, Object*, new_val, referrer, Thread*)
92837f05ef45e0393de812d51261dc293240c17294dFred Shih    sw     rSELF, 16($sp)                # pass Thread::Current
92937f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
93037f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set8_instance
93137f05ef45e0393de812d51261dc293240c17294dFred Shih
93237f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
93337f05ef45e0393de812d51261dc293240c17294dFred Shih     * Called by managed code to resolve an instance field and store a 16-bit primitive value.
93437f05ef45e0393de812d51261dc293240c17294dFred Shih     */
93537f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet16InstanceFromCode
93637f05ef45e0393de812d51261dc293240c17294dFred ShihENTRY art_quick_set16_instance
937735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
938735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9391d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet16InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
94037f05ef45e0393de812d51261dc293240c17294dFred Shih    sw     rSELF, 16($sp)                # pass Thread::Current
94137f05ef45e0393de812d51261dc293240c17294dFred Shih    RETURN_IF_ZERO
94237f05ef45e0393de812d51261dc293240c17294dFred ShihEND art_quick_set16_instance
94337f05ef45e0393de812d51261dc293240c17294dFred Shih
94437f05ef45e0393de812d51261dc293240c17294dFred Shih    /*
94557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 32-bit primitive value.
9465bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
947d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSet32InstanceFromCode
948468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_instance
949735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
950735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9511d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet32InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
952fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
9535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
954468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_instance
9555bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9565bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
95757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 64-bit primitive value.
9585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
95937f05ef45e0393de812d51261dc293240c17294dFred Shih    .extern artSet64InstanceFromCode
960468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_instance
961735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $t1, 0($sp)                   # load referrer's Method*
9628d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe                                         # 64 bit new_val is in a2:a3 pair
963735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9641d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    sw     rSELF, 20($sp)                # pass Thread::Current
9651d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSet64InstanceFromCode      # (field_idx, Object*, new_val, referrer, Thread*)
966735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw     $t1, 16($sp)                  # pass referrer's Method*
9675bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
968468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_instance
9695bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
9705bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
97157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store an object reference.
9725bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
973d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artSetObjInstanceFromCode
974468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_instance
975735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw     $a3, 0($sp)                   # pass referrer's Method*
976735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME    # save callee saves in case of GC
9771d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artSetObjInstanceFromCode     # (field_idx, Object*, new_val, referrer, Thread*)
978fa147e22a73c6df166b08a2f71f9c9b52b09d17cjeffhao    sw     rSELF, 16($sp)                # pass Thread::Current
9795bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    RETURN_IF_ZERO
980468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_instance
9815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
982a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko// Macro to facilitate adding new allocation entrypoints.
9835ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.macro ONE_ARG_DOWNCALL name, entrypoint, return
9845ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    .extern \entrypoint
9855ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoENTRY \name
9865ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
9875ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    jal     \entrypoint
9885ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    move    $a1, rSELF                # pass Thread::Current
9895ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko    \return
9905ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoEND \name
9915ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko.endm
9925ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko
993cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.macro TWO_ARG_DOWNCALL name, entrypoint, return
994cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    .extern \entrypoint
995cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierENTRY \name
996735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
997cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    jal     \entrypoint
9981d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a2, rSELF                # pass Thread::Current
999cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    \return
1000cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierEND \name
1001cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.endm
10025bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1003cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.macro THREE_ARG_DOWNCALL name, entrypoint, return
1004cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    .extern \entrypoint
1005cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierENTRY \name
1006735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1007cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    jal     \entrypoint
10081d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move    $a3, rSELF                # pass Thread::Current
1009cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier    \return
1010cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu ChartierEND \name
1011cbb2d20bea2861f244da2e2318d8c088300a3710Mathieu Chartier.endm
10125bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
1013848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao.macro FOUR_ARG_DOWNCALL name, entrypoint, return
1014848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao    .extern \entrypoint
1015848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff HaoENTRY \name
1016a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC
1017848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao    jal     \entrypoint
1018a3c382738bc54f464a57e2b51b51ad305eb03dd2Vladimir Marko    sw      rSELF, 16($sp)            # pass Thread::Current
1019848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao    \return
1020848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff HaoEND \name
1021848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao.endm
1022848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao
10237410f29b4dae223befac036ea567d7f33351dad1Mathieu Chartier// Generate the allocation entrypoints for each allocator.
10247410f29b4dae223befac036ea567d7f33351dad1Mathieu ChartierGENERATE_ALL_ALLOC_ENTRYPOINTS
10253b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
10265bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
10271cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
10285ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * exception on error. On success the String is returned. A0 holds the string index. The fast
10295ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir Marko     * path check for hit in strings cache has already been performed.
10301cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
10315ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
10321cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
10331cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
10341cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when uninitialized static storage, this stub will run the class
10351cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * initializer and deliver the exception on error. On success the static storage base is
10361cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * returned.
10371cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
10385ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
10391cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
10401cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
10411cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when dex cache misses for a type_idx.
10421cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
10435ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
10441cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
10451cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
10461cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * Entry from managed code when type_idx needs to be checked for access and dex cache may also
10471cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     * miss.
10481cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe     */
10495ea536aa4a6414db01beaf6f8bd8cb9adc5cfc92Vladimir MarkoONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
10501cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe
10511cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampe    /*
105257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code when the value in rSUSPEND has been decremented to 0.
10535bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1054d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artTestSuspendFromCode
1055d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_test_suspend
1056474b6da273c7ce6df50a4e51eb9929a77e1611c3Ian Rogers    lh     $a0, THREAD_FLAGS_OFFSET(rSELF)
10577fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez   $a0, 1f
1058e34652f15f32666323052a6718a63248244f1e66Duane Sand    addiu  rSUSPEND, $zero, SUSPEND_CHECK_INTERVAL   # reset rSUSPEND to SUSPEND_CHECK_INTERVAL
10598d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr   $zero, $ra
10605bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    nop
10615bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
10621d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME          # save callee saves for stack crawl
10631d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal    artTestSuspendFromCode              # (Thread*)
10647fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    move   $a0, rSELF
10651d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
1066d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_test_suspend
10675bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
10685bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
10695bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Called by managed code that is attempting to call a method on a proxy class. On entry
107057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * r0 holds the proxy method; r1, r2 and r3 may contain arguments.
10715bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
10725fa60c3db4208df407113b5a69d295a9c93d53b1Jeff Hao    .extern artQuickProxyInvokeHandler
1073d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_proxy_invoke_handler
1074735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1075735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, rSELF                  # pass Thread::Current
10765fa60c3db4208df407113b5a69d295a9c93d53b1Jeff Hao    jal     artQuickProxyInvokeHandler  # (Method* proxy method, receiver, Thread*, SP)
1077735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a3, $sp, ARG_SLOT_SIZE     # pass $sp (remove arg slots)
10787fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1079735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
10807fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    bnez    $t0, 1f
1081e34652f15f32666323052a6718a63248244f1e66Duane Sand    # don't care if $v0 and/or $v1 are modified, when exception branch taken
1082e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1          # move float value to return value
10838d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1084e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
10855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee1:
10865bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    DELIVER_PENDING_EXCEPTION
1087d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_proxy_invoke_handler
10885bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
108988474b416eb257078e590bf9bc7957cee604a186Jeff Hao    /*
109088474b416eb257078e590bf9bc7957cee604a186Jeff Hao     * Called to resolve an imt conflict. t0 is a hidden argument that holds the target method's
109188474b416eb257078e590bf9bc7957cee604a186Jeff Hao     * dex method index.
109288474b416eb257078e590bf9bc7957cee604a186Jeff Hao     */
109313738bf7c769638b7922cb2477471ad382632bc2Douglas LeungENTRY art_quick_imt_conflict_trampoline
109488474b416eb257078e590bf9bc7957cee604a186Jeff Hao    la      $t9, art_quick_invoke_interface_trampoline
10958d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $t9
10968ea18d0f066f63fa4e5d154f14327468bf288e2bNicolas Geoffray    move    $a0, $t0
109788474b416eb257078e590bf9bc7957cee604a186Jeff HaoEND art_quick_imt_conflict_trampoline
109888474b416eb257078e590bf9bc7957cee604a186Jeff Hao
1099468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickResolutionTrampoline
1100468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_resolution_trampoline
11011d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1102735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, rSELF                    # pass Thread::Current
110365d1b22d0b02fb0111f69013163c8170e68392f1Ian Rogers    jal     artQuickResolutionTrampoline  # (Method* called, receiver, Thread*, SP)
1104735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a3, $sp, ARG_SLOT_SIZE       # pass $sp (remove arg slots)
1105468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    beqz    $v0, 1f
1106735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a0, ARG_SLOT_SIZE($sp)       # load resolved method to $a0
11071d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
110865d1b22d0b02fb0111f69013163c8170e68392f1Ian Rogers    move    $t9, $v0               # code pointer must be in $t9 to generate the global pointer
1109f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    jalr    $zero, $t9             # tail call to method
11101984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    nop
1111468532ea115657709bc32ee498e701a4c71762d4Ian Rogers1:
11121d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1113468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    DELIVER_PENDING_EXCEPTION
1114468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_resolution_trampoline
1115468532ea115657709bc32ee498e701a4c71762d4Ian Rogers
1116735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .extern artQuickGenericJniTrampoline
1117735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .extern artQuickGenericJniEndTrampoline
1118735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas LeungENTRY art_quick_generic_jni_trampoline
1119735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_A0
1120735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $s8, $sp               # save $sp to $s8
1121735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $s3, $gp               # save $gp to $s3
1122735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1123735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # prepare for call to artQuickGenericJniTrampoline(Thread*, SP)
1124735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a0, rSELF                     # pass Thread::Current
1125735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a1, $sp, ARG_SLOT_SIZE        # save $sp (remove arg slots)
1126735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal     artQuickGenericJniTrampoline   # (Thread*, SP)
1127735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, -5120                # reserve space on the stack
1128735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1129735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # The C call will have registered the complete save-frame on success.
1130735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # The result of the call is:
1131735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # v0: ptr to native code, 0 on error.
1132735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # v1: ptr to the bottom of the used area of the alloca, can restore stack till here.
1133735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    beq     $v0, $zero, 1f         # check entry error
1134735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $t9, $v0               # save the code ptr
1135735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $sp, $v1               # release part of the alloca
1136735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1137735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # Load parameters from stack into registers
1138735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a0,   0($sp)
1139735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a1,   4($sp)
1140735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a2,   8($sp)
1141735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1142735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # Load FPRs the same as GPRs. Look at BuildNativeCallFrameStateMachine.
1143735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jalr    $t9                    # native call
1144735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $a3,  12($sp)
1145735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, 16           # remove arg slots
1146735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1147735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $gp, $s3               # restore $gp from $s3
1148735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1149735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # result sign extension is handled in C code
1150735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # prepare for call to artQuickGenericJniEndTrampoline(Thread*, result, result_f)
1151735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a0, rSELF             # pass Thread::Current
1152735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a2, $v0               # pass result
1153735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a3, $v1
1154735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $sp, $sp, -24          # reserve arg slots
1155735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal     artQuickGenericJniEndTrampoline
1156735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    s.d     $f0, 16($sp)           # pass result_f
1157735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1158735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1159126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    bne     $t0, $zero, 1f         # check for pending exceptions
1160126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray
1161735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $sp, $s8               # tear down the alloca
1162735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1163735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    # tear dpown the callee-save frame
1164735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1165735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1166e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1     # move float value to return value
11678d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1168e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1169735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1170735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung1:
1171126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    lw $sp, THREAD_TOP_QUICK_FRAME_OFFSET(rSELF)
1172126d65952a03b3e44d5021208673c01920a982a4Nicolas Geoffray    # This will create a new save-all frame, required by the runtime.
1173735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    DELIVER_PENDING_EXCEPTION
1174735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas LeungEND art_quick_generic_jni_trampoline
11752da882315a61072664f7ce3c212307342e907207Andreas Gampe
1176468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickToInterpreterBridge
1177468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_to_interpreter_bridge
11781d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1179735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    move    $a1, rSELF                          # pass Thread::Current
1180735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    jal     artQuickToInterpreterBridge         # (Method* method, Thread*, SP)
1181735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu   $a2, $sp, ARG_SLOT_SIZE             # pass $sp (remove arg slots)
11827db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    lw      $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_
1183735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
11847db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    bnez    $t0, 1f
1185e34652f15f32666323052a6718a63248244f1e66Duane Sand    # don't care if $v0 and/or $v1 are modified, when exception branch taken
1186e34652f15f32666323052a6718a63248244f1e66Duane Sand    MTD     $v0, $v1, $f0, $f1                  # move float value to return value
11878d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe    jalr    $zero, $ra
1188e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
11897db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers1:
11907db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    DELIVER_PENDING_EXCEPTION
1191468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_to_interpreter_bridge
11927db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers
11935bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
1194725a957985171d712d5c048cc3d00ff14968784bjeffhao     * Routine that intercepts method calls and returns.
11955bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
1196d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artInstrumentationMethodEntryFromCode
1197d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artInstrumentationMethodExitFromCode
1198468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_instrumentation_entry
11991d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME
1200735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    sw       $a0, 28($sp)   # save arg0 in free arg slot
12011d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move     $a3, $ra       # pass $ra
12021d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal      artInstrumentationMethodEntryFromCode  # (Method*, Object*, Thread*, LR)
120362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a2, rSELF     # pass Thread::Current
12048161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    move     $t9, $v0       # $t9 holds reference to code
1205735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    lw       $a0, 28($sp)   # restore arg0 from free arg slot
12061d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
12078161c0336b97e11e02c000af357f8f40de2e23e4jeffhao    jalr     $t9            # call method
120862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    nop
1209468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_entry
12105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* intentional fallthrough */
1211468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .global art_quick_instrumentation_exit
1212468532ea115657709bc32ee498e701a4c71762d4Ian Rogersart_quick_instrumentation_exit:
1213d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .cfi_startproc
121412051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    addiu    $t9, $ra, 4    # put current address into $t9 to rebuild $gp
12151d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    .cpload  $t9
1216c3d131e1ec030b4ff5c44fe2a45d5fb45b3295afDouglas Leung    move     $ra, $zero     # link register is to here, so clobber with 0 for later checks
1217735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung
1218f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    SETUP_REFS_ONLY_CALLEE_SAVE_FRAME
1219735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    addiu    $sp, $sp, -16  # allocate temp storage on the stack
1220735b8559d6dd26c610d4b97d72f25a092d9c8947Douglas Leung    .cfi_adjust_cfa_offset 16
1221f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    sw       $v0, ARG_SLOT_SIZE+12($sp)
1222f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_rel_offset 2, ARG_SLOT_SIZE+12
1223f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    sw       $v1, ARG_SLOT_SIZE+8($sp)
1224f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_rel_offset 3, ARG_SLOT_SIZE+8
1225f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    s.d      $f0, ARG_SLOT_SIZE($sp)
1226e34652f15f32666323052a6718a63248244f1e66Duane Sand    s.d      $f0, 16($sp)   # pass fpr result
122762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a2, $v0       # pass gpr result
122862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    move     $a3, $v1
1229f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    addiu    $a1, $sp, ARG_SLOT_SIZE+16   # pass $sp (remove arg slots and temp storage)
123062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    jal      artInstrumentationMethodExitFromCode  # (Thread*, SP, gpr_res, fpr_res)
123112051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    move     $a0, rSELF     # pass Thread::Current
1232f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    move     $t9, $v0       # set aside returned link register
123312051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    move     $ra, $v1       # set link register for deoptimization
1234f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    lw       $v0, ARG_SLOT_SIZE+12($sp)   # restore return values
1235f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    lw       $v1, ARG_SLOT_SIZE+8($sp)
1236f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    l.d      $f0, ARG_SLOT_SIZE($sp)
1237f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    jalr     $zero, $t9     # return
1238f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    addiu    $sp, $sp, ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16  # restore stack
1239f96e8bdf47cfcbecd8ad8ebceb765e5a257ca143Douglas Leung    .cfi_adjust_cfa_offset -(ARG_SLOT_SIZE+FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+16)
1240468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_exit
12415bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
124212051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao    /*
124362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
124462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * will long jump to the upcall with a special exception of -1.
124512051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao     */
1246d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff Hao    .extern artDeoptimize
1247d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoENTRY art_quick_deoptimize
124814dd5a82ad85a28612bf86e755ff929d767cea4cJeff Hao    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
12491d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    jal      artDeoptimize  # artDeoptimize(Thread*)
125012051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao                            # Returns caller method's frame size.
12511d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian Rogers    move     $a0, rSELF     # pass Thread::current
1252d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_deoptimize
125312051ea86ec27703b07b3d5c2cd4604b20f71810jeffhao
12545bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
12555bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
12565bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
12575bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
12585bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
12595bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
12607fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a0: low word
12617fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a1: high word
12627fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a2: shift count
12635bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
12641d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_shl_long
12655bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* shl-long vAA, vBB, vCC */
12667fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $v0, $a0, $a2                    #  rlo<- alo << (shift&31)
12677fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $v1, $a2                         #  rhi<- 31-shift  (shift is 5b)
12687fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $a0, 1
12697fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $a0, $v1                         #  alo<- alo >> (32-(shift&31))
12707fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $v1, $a1, $a2                    #  rhi<- ahi << (shift&31)
12717fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift< shift & 0x20
1272e34652f15f32666323052a6718a63248244f1e66Duane Sand    beqz    $a2, 1f
1273e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v1, $a0                         #  rhi<- rhi | alo
1274e34652f15f32666323052a6718a63248244f1e66Duane Sand
1275e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $v0                         #  rhi<- rlo (if shift&0x20)
1276e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $zero                       #  rlo<- 0 (if shift&0x20)
1277e34652f15f32666323052a6718a63248244f1e66Duane Sand
12788d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1279e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1280d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_shl_long
12815bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
12825bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
12835bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
12845bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
12855bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
12865bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
12875bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
12887fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a0: low word
12897fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a1: high word
12907fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao     *   $a2: shift count
12915bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
12921d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_shr_long
12937fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sra     $v1, $a1, $a2                    #  rhi<- ahi >> (shift&31)
12947fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $v0, $a0, $a2                    #  rlo<- alo >> (shift&31)
12957fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sra     $a3, $a1, 31                     #  $a3<- sign(ah)
12967fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $a0, $a2                         #  alo<- 31-shift (shift is 5b)
12977fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, 1
12987fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, $a0                         #  ahi<- ahi << (32-(shift&31))
12997fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift & 0x20
1300475cfd8ff9dcc73d1a7502c9310efe0f1a30337fDouglas Leung    beqz    $a2, 1f
1301e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v0, $a1                         #  rlo<- rlo | ahi
1302e34652f15f32666323052a6718a63248244f1e66Duane Sand
1303e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $v1                         #  rlo<- rhi (if shift&0x20)
1304e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $a3                         #  rhi<- sign(ahi) (if shift&0x20)
1305e34652f15f32666323052a6718a63248244f1e66Duane Sand
13068d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1307e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1308d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_shr_long
13095bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee
13105bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /*
13115bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
13125bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
13135bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
13145bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * 6 bits.
13155bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     * On entry:
13165bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *   r0: low word
13175bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *   r1: high word
13185bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     *   r2: shift count
13195bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee     */
13205bc5a7b9d9adcfb50e18bd3776d3875ad7a4ae8cbuzbee    /* ushr-long vAA, vBB, vCC */
13211d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersENTRY_NO_GP art_quick_ushr_long
1322fc6a30e2fa8f0d44e6c95bbeb5deca4b499f67cejeffhao    srl     $v1, $a1, $a2                    #  rhi<- ahi >> (shift&31)
13237fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    srl     $v0, $a0, $a2                    #  rlo<- alo >> (shift&31)
13247fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    not     $a0, $a2                         #  alo<- 31-shift (shift is 5b)
13257fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, 1
13267fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    sll     $a1, $a0                         #  ahi<- ahi << (32-(shift&31))
13277fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao    andi    $a2, 0x20                        #  shift & 0x20
1328e34652f15f32666323052a6718a63248244f1e66Duane Sand    beqz    $a2, 1f
1329e34652f15f32666323052a6718a63248244f1e66Duane Sand    or      $v0, $a1                         #  rlo<- rlo | ahi
1330e34652f15f32666323052a6718a63248244f1e66Duane Sand
1331e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v0, $v1                         #  rlo<- rhi (if shift&0x20)
1332e34652f15f32666323052a6718a63248244f1e66Duane Sand    move    $v1, $zero                       #  rhi<- 0 (if shift&0x20)
1333e34652f15f32666323052a6718a63248244f1e66Duane Sand
13348d36591d93920e7b7830c3ffee3759b561f5339eAndreas Gampe1:  jalr    $zero, $ra
1335e34652f15f32666323052a6718a63248244f1e66Duane Sand    nop
1336d4c3f7d4e850049b3c1019e451b18b05443b0f28Jeff HaoEND art_quick_ushr_long
13377fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao
13381d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersUNIMPLEMENTED art_quick_indexof
13391d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5Ian RogersUNIMPLEMENTED art_quick_string_compareto
1340