quick_entrypoints_arm.S revision 88474b416eb257078e590bf9bc7957cee604a186
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_arm.S"
189651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
19ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /* Deliver the given exception */
20ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artDeliverExceptionFromCode
21ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /* Deliver an exception pending on a thread */
22ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artDeliverPendingException
23ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
244f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
254f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
264f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Runtime::CreateCalleeSaveMethod(kSaveAll)
274f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
2857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
294f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    push {r4-r11, lr} @ 9 words of callee saves
309329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r4-r11, lr}
319329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 36
329329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r4, 0
339329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r5, 4
349329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r6, 8
359329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r7, 12
369329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r8, 16
379329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 20
389329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r10, 24
399329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r11, 28
409329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset lr, 32
4115fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    vpush {s0-s31}
429329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #128
439329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 128
444f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    sub sp, #12       @ 3 words of space, bottom word will hold Method*
459329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #12
469329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 12
474f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
484f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
494f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
504f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
511984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier     * Runtime::CreateCalleeSaveMethod(kRefsOnly).
524f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
534f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
544f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    push {r5-r8, r10-r11, lr} @ 7 words of callee saves
559329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r5-r8, r10-r11, lr}
569329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 28
579329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r5, 0
589329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r6, 4
599329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r7, 8
609329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r8, 12
619329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r10, 16
629329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r11, 20
639329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset lr, 24
644f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    sub sp, #4                @ bottom word will hold Method*
659329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #4
669329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 4
674f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
684f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
694f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
702a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    add sp, #4               @ bottom word holds Method*
712a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
729329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -32
734f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
744f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
754f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
762a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    add sp, #4               @ bottom word holds Method*
772a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
789329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -32
792a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    bx  lr                   @ return
804f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
814f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
824f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
834f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
841984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs).
854f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
864f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
87dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    push {r1-r3, r5-r8, r10-r11, lr}  @ 10 words of callee saves
889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r1-r3, r5-r8, r10-r11, lr}
899329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 40
905d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r1, 0
915d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r2, 4
925d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r3, 8
935d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r5, 12
945d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r6, 16
955d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r7, 20
965d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r8, 24
975d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r10, 28
985d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r11, 32
995d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset lr, 36
100dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    sub sp, #8                        @ 2 words of space, bottom word will hold Method*
1019329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
1029329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
1034f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
1044f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
1054f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1062a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    add  sp, #8                      @ rewind sp
1072a6c7b7c21adcd4493542604305585b852ccf554Mathieu Chartier    pop {r1-r3, r5-r8, r10-r11, lr}  @ 10 words of callee saves
1089329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -48
10915fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers.endm
11015fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers
111637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers.macro RETURN_IF_RESULT_IS_ZERO
112637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r0, 1f              @ result non-zero branch over
113637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                  @ return
114637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
115637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers.endm
116637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers
117637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers.macro RETURN_IF_RESULT_IS_NON_ZERO
118637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbz    r0, 1f              @ result zero branch over
119637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                  @ return
120637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
121637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers.endm
122637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers
123ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
124ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
125ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * exception is Thread::Current()->exception_
126ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
127ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers.macro DELIVER_PENDING_EXCEPTION
1289329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .fnend
1299329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .fnstart
13057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME           @ save callee saves for throw
131ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r0, r9                              @ pass Thread::Current
132ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r1, sp                              @ pass SP
133ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    b      artDeliverPendingExceptionFromCode  @ artDeliverPendingExceptionFromCode(Thread*, SP)
134ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers.endm
135ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
13657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
13757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    .extern \cxx_name
1389329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY \c_name
13957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME  // save all registers as basis for long jump context
14057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r0, r9                      @ pass Thread::Current
14157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r1, sp                      @ pass SP
14257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    b   \cxx_name                   @ \cxx_name(Thread*, SP)
1439329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND \c_name
14457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.endm
14557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers
14657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name
14757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    .extern \cxx_name
1489329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY \c_name
14957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME  // save all registers as basis for long jump context
15057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r1, r9                      @ pass Thread::Current
15157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r2, sp                      @ pass SP
15257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    b   \cxx_name                   @ \cxx_name(Thread*, SP)
153a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bkpt
1549329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND \c_name
15557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.endm
15657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers
15757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name
15857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    .extern \cxx_name
1599329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY \c_name
16057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME  // save all registers as basis for long jump context
16157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r2, r9                      @ pass Thread::Current
16257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov r3, sp                      @ pass SP
16357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    b   \cxx_name                   @ \cxx_name(Thread*, SP)
164a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bkpt
1659329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND \c_name
16657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers.endm
16757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers
16844b412bb795fa6999129b2bc16f5eec1ea97e8f8buzbee    /*
16957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code, saves callee saves and then calls artThrowException
17057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception.
17144b412bb795fa6999129b2bc16f5eec1ea97e8f8buzbee     */
172468532ea115657709bc32ee498e701a4c71762d4Ian RogersONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode
17344b412bb795fa6999129b2bc16f5eec1ea97e8f8buzbee
1746f495f2898a418f87e2a919e04fe23521bb0b9e9Brian Carlstrom    /*
17557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a NullPointerException.
1766f495f2898a418f87e2a919e04fe23521bb0b9e9Brian Carlstrom     */
177468532ea115657709bc32ee498e701a4c71762d4Ian RogersNO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode
1786f495f2898a418f87e2a919e04fe23521bb0b9e9Brian Carlstrom
179bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers    /*
18057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver an ArithmeticException.
181bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers     */
182468532ea115657709bc32ee498e701a4c71762d4Ian RogersNO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode
1839651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
1849651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
18557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds
18657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * index, arg2 holds limit.
1879651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
188468532ea115657709bc32ee498e701a4c71762d4Ian RogersTWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode
1899651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
1909651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
19157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a StackOverflowError.
1929651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
193468532ea115657709bc32ee498e701a4c71762d4Ian RogersNO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode
1949651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
1959651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
19657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to create and deliver a NoSuchMethodError.
1979651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
198468532ea115657709bc32ee498e701a4c71762d4Ian RogersONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode
19957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers
20057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
201c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * All generated callsites for interface invokes and invocation slow paths will load arguments
202c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain
203c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * the method_idx.  This wrapper will save arg1-arg3, load the caller's Method*, align the
204c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * stack and call the appropriate C helper.
205634eb2eb14f87753519d0ef2c5f256e55888f378Elliott Hughes     * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1.
2064a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
207c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting
208c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * of the target Method* in r0 and method->code_ in r1.
2094a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
210c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the
211c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers     * thread and we branch to another stub to deliver it.
2124a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
213ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
214ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * pointing back to the original caller.
2154a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     */
216c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers.macro INVOKE_TRAMPOLINE c_name, cxx_name
217c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers    .extern \cxx_name
2189329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY \c_name
2194f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME  @ save callee saves in case allocation triggers GC
220c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers    ldr    r2, [sp, #48]                  @ pass caller Method*
221c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers    mov    r3, r9                         @ pass Thread::Current
222865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
223865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!               @ expand the frame and pass SP
2249329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
2259329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
226c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers    bl     \cxx_name                      @ (method_idx, this, caller, Thread*, SP)
227865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                        @ strip the extra frame
2289329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
229634eb2eb14f87753519d0ef2c5f256e55888f378Elliott Hughes    mov    r12, r1                        @ save Method*->code_
230a32a6fd4a781262dff4fec102da053d16b7ef6c0Ian Rogers    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
231637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbz    r0, 1f                         @ did we find the target? if not go to exception delivery
232637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     r12                            @ tail call to target
233637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
234a32a6fd4a781262dff4fec102da053d16b7ef6c0Ian Rogers    DELIVER_PENDING_EXCEPTION
2359329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND \c_name
236c8b306f5221658c7e4b5516be8917dc8c9288e7eIan Rogers.endm
237a32a6fd4a781262dff4fec102da053d16b7ef6c0Ian Rogers
2388dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline
2398dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
240a32a6fd4a781262dff4fec102da053d16b7ef6c0Ian Rogers
2418dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
2428dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
2438dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
2448dbb708c7dc05c786329eb5c3fff3194ab6472acLogan ChienINVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
245ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
24657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    /*
2476474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     * Quick invocation stub.
2486474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     * On entry:
2496474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   r0 = method pointer
2506474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   r1 = argument array or NULL for no argument methods
2516474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   r2 = size of argument array in bytes
2526474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   r3 = (managed) thread pointer
2536474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   [sp] = JValue* result
2546474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao     *   [sp + 4] = result type char
2555d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao     */
2565d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoENTRY art_quick_invoke_stub
2575d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    push   {r0, r4, r5, r9, r11, lr}       @ spill regs
2585d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .save  {r0, r4, r5, r9, r11, lr}
2595d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .pad #24
2605d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_adjust_cfa_offset 24
2615d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r0, 0
2625d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r4, 4
2635d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r5, 8
2645d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r9, 12
2655d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset r11, 16
2665d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_rel_offset lr, 20
2675d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    mov    r11, sp                         @ save the stack pointer
2685d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_def_cfa_register r11
2695d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    mov    r9, r3                          @ move managed thread pointer into r9
2705d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    mov    r4, #SUSPEND_CHECK_INTERVAL     @ reset r4 to suspend check interval
2715d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    add    r5, r2, #16                     @ create space for method pointer in frame
2726474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    and    r5, #0xFFFFFFF0                 @ align frame size to 16 bytes
2735d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    sub    sp, r5                          @ reserve stack space for argument array
2745d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    add    r0, sp, #4                      @ pass stack pointer + method ptr as dest for memcpy
2755d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    bl     memcpy                          @ memcpy (dest, src, bytes)
2765d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    r0, [r11]                       @ restore method*
2775d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    r1, [sp, #4]                    @ copy arg value for r1
2785d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    r2, [sp, #8]                    @ copy arg value for r2
2795d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    r3, [sp, #12]                   @ copy arg value for r3
2805d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    mov    ip, #0                          @ set ip to 0
2815d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    str    ip, [sp]                        @ store NULL for method* at bottom of frame
2825d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    ip, [r0, #METHOD_CODE_OFFSET]   @ get pointer to the code
2835d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    blx    ip                              @ call the method
2846474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao    mov    sp, r11                         @ restore the stack pointer
2855d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    ldr    ip, [sp, #24]                   @ load the result pointer
2865d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    strd   r0, [ip]                        @ store r0/r1 into result pointer
2875d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    pop    {r0, r4, r5, r9, r11, lr}       @ restore spill regs
2885d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    .cfi_adjust_cfa_offset -24
2895d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    bx     lr
2905d9173014c1ca09f7249a6b07629aa37778b5f8fJeff HaoEND art_quick_invoke_stub
2916474d190d5604898354ebf767f1944b6e3e9b445Jeff Hao
2925d9173014c1ca09f7249a6b07629aa37778b5f8fJeff Hao    /*
29357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_
29457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     */
295637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan RogersARM_ENTRY art_quick_do_long_jump
29657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    vldm r1, {s0-s31}     @ load all fprs from argument fprs_
29757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    ldr  r2, [r0, #60]    @ r2 = r15 (PC from gprs_ 60=4*15)
29857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    add  r0, r0, #12      @ increment r0 to skip gprs_[0..2] 12=4*3
29957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    ldm  r0, {r3-r14}     @ load remaining gprs from argument gprs_
30057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov  r0, #0           @ clear result registers r0 and r1
30157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    mov  r1, #0
30257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers    bx   r2               @ do long jump
3039329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_do_long_jump
30457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers
30560db5ab3a2e480db9236325a14cb5a867881d8bbIan Rogers    /*
306ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
307ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * failure.
308ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
3099329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artHandleFillArrayDataFromCode
310468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_handle_fill_data
3114f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case exception allocation triggers GC
3124f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                          @ pass Thread::Current
3134f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                          @ pass SP
314af778e627aa41ec6c176cba537062b95d4d960b6Elliott Hughes    bl     artHandleFillArrayDataFromCode  @ (Array*, const DexFile::Payload*, Thread*, SP)
3154f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
316637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
317ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
318468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_handle_fill_data
3194f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
3204f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
321d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers     * Entry from managed code that calls artLockObjectFromCode, may block for GC. r0 holds the
322d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers     * possibly null object to lock.
3234f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
3249329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artLockObjectFromCode
325468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_lock_object
326d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cbz    r0, slow_lock
327d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersretry_lock:
328d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    ldrex  r1, [r0, #LOCK_WORD_OFFSET]
329d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    ldrt   r2, [r9, #THREAD_ID_OFFSET]
330d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cmp    r1, #0
331d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bmi    slow_lock                  @ lock word contains a monitor
332d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bne    already_thin
333d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    @ unlocked case - r2 holds thread id with count of 0
334d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    strex  r3, r2, [r0, #LOCK_WORD_OFFSET]
335d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cbnz   r3, strex_fail             @ store failed, retry
336d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bx lr
337d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersstrex_fail:
338d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    b retry_lock                      @ unlikely forward branch, need to reload and recheck r1/r2
339d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersalready_thin:
340d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    eor    r2, r1, r2                 @ lock_word.ThreadId() ^ self->ThreadId()
341d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    uxth   r2, r2                     @ zero top 16 bits
342d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cbnz   r2, slow_lock              @ lock word and self thread id's match -> recursive lock
343d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers                                      @ else contention, go to slow path
344d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    adds   r2, r1, #65536             @ increment count in lock word placing in r2 for storing
345d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bmi    slow_lock                  @ if we overflow the count go slow
346d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    str    r2, [r0, #LOCK_WORD_OFFSET] @ no need for strex as we hold the lock
347d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bx lr
348d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersslow_lock:
3494f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case we block
3504f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r1, r9                     @ pass Thread::Current
3514f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, sp                     @ pass SP
3524f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artLockObjectFromCode      @ (Object* obj, Thread*, SP)
353d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
354d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    RETURN_IF_RESULT_IS_ZERO
355d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    DELIVER_PENDING_EXCEPTION
356468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_lock_object
357ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
358ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /*
359ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
360d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers     * r0 holds the possibly null object to lock.
361ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
3629329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artUnlockObjectFromCode
363468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_unlock_object
364d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cbz    r0, slow_unlock
365d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    ldr    r1, [r0, #LOCK_WORD_OFFSET]
366d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    ldr    r2, [r9, #THREAD_ID_OFFSET]
367d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cmp    r1, #0
368d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bmi    slow_unlock                @ lock word contains a monitor
369d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    eor    r3, r1, r2                 @ lock_word.ThreadId() ^ self->ThreadId()
370d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    uxth   r3, r3                     @ zero top 16 bits
371d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cbnz   r3, slow_unlock            @ do lock word and self thread id's match?
372d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    cmp    r1, #65536
373d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bpl    recursive_thin_unlock
374d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    @ transition to unlocked, r3 holds 0
375d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    str    r3, [r0, #LOCK_WORD_OFFSET]
376d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bx     lr
377d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersrecursive_thin_unlock:
378d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    sub    r1, r1, #65536
379d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    str    r1, [r0, #LOCK_WORD_OFFSET]
380d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    bx     lr
381d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogersslow_unlock:
3824f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case exception allocation triggers GC
383637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    mov    r1, r9                     @ pass Thread::Current
384637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    mov    r2, sp                     @ pass SP
385637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bl     artUnlockObjectFromCode    @ (Object* obj, Thread*, SP)
3864f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
387637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
388ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
389468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_unlock_object
390ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
391ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /*
392a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * Entry from managed code that calls artIsAssignableFromCode and on failure calls
393a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * artThrowClassCastException.
394ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
395a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .extern artThrowClassCastException
396468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_check_cast
397a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    push {r0-r1, lr}                    @ save arguments, link register and pad
398a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .save {r0-r1, lr}
399a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset 12
400a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset r0, 0
401a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset r1, 4
402a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_rel_offset lr, 8
403a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    sub sp, #4
404a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .pad #4
405a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset 4
406a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bl artIsAssignableFromCode
407a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    cbz    r0, throw_class_cast_exception
408a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add sp, #4
409a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -4
410a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    pop {r0-r1, pc}
411a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogersthrow_class_cast_exception:
412a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add sp, #4
413a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    .cfi_adjust_cfa_offset -4
414a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    pop {r0-r1, lr}
415a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME  // save all registers as basis for long jump context
416a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r2, r9                      @ pass Thread::Current
417a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r3, sp                      @ pass SP
418a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    b   artThrowClassCastException  @ (Class*, Class*, Thread*, SP)
419a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bkpt
420468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_check_cast
421e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers
422e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers    /*
423a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * Entry from managed code for array put operations of objects where the value being stored
424a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * needs to be checked for compatibility.
425a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers     * r0 = array, r1 = index, r2 = value
426e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers     */
427a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_null_and_bound_check
428a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    tst r0, r0
429a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bne art_quick_aput_obj_with_bound_check
430a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    b art_quick_throw_null_pointer_exception
431a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_null_and_bound_check
432a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
433a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj_with_bound_check
434a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr r3, [r0, #ARRAY_LENGTH_OFFSET]
435a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    cmp r3, r1
436a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bhi art_quick_aput_obj
437a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r0, r1
438a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r1, r3
439a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    b art_quick_throw_array_bounds
440a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj_with_bound_check
441a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers
442a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersENTRY art_quick_aput_obj
443a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    cbz r2, do_aput_null
444a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr r3, [r0, #CLASS_OFFSET]
445a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr ip, [r2, #CLASS_OFFSET]
446a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr r3, [r3, #CLASS_COMPONENT_TYPE_OFFSET]
447a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    cmp r3, ip  @ value's type == array's component type - trivial assignability
448a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bne check_assignability
449a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogersdo_aput:
450a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add r3, r0, #OBJECT_ARRAY_DATA_OFFSET
451a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    str r2, [r3, r1, lsl #2]
452a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr r3, [r9, #THREAD_CARD_TABLE_OFFSET]
453a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lsr r0, r0, #7
454a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    strb r3, [r3, r0]
455a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    blx lr
456a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogersdo_aput_null:
457a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add r3, r0, #OBJECT_ARRAY_DATA_OFFSET
458a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    str r2, [r3, r1, lsl #2]
459a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    blx lr
460a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogerscheck_assignability:
461a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    push {r0-r2, lr}                 @ save arguments
462a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r1, ip
463a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r0, r3
464a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bl artIsAssignableFromCode
465a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    cbz r0, throw_array_store_exception
466a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    pop {r0-r2, lr}
467a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    add r3, r0, #OBJECT_ARRAY_DATA_OFFSET
468a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    str r2, [r3, r1, lsl #2]
469a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    ldr r3, [r9, #THREAD_CARD_TABLE_OFFSET]
470a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    lsr r0, r0, #7
471a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    strb r3, [r3, r0]
472a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    blx lr
473a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogersthrow_array_store_exception:
474a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    pop {r0-r2, lr}
475a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
476a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r1, r2
477a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r2, r9                   @ pass Thread::Current
478a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    mov r3, sp                   @ pass SP
479a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    b artThrowArrayStoreException  @ (Class*, Class*, Thread*, SP)
480a9a8254c920ce8e22210abfc16c9842ce0aea28fIan Rogers    bkpt                         @ unreached
481a9a8254c920ce8e22210abfc16c9842ce0aea28fIan RogersEND art_quick_aput_obj
482cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers
483cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers    /*
484cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * Entry from managed code when uninitialized static storage, this stub will run the class
485cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * initializer and deliver the exception on error. On success the static storage base is
486cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * returned.
487cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     */
4889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artInitializeStaticStorageFromCode
489468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_initialize_static_storage
4904f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME           @ save callee saves in case of GC
4914f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                              @ pass Thread::Current
4924f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                              @ pass SP
493aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom    @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
4944f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artInitializeStaticStorageFromCode
4954f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
496637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
497ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
498468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_initialize_static_storage
499ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
50028ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    /*
50128ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers     * Entry from managed code when dex cache misses for a type_idx
50228ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers     */
5039329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artInitializeTypeFromCode
504468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_initialize_type
50528ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME           @ save callee saves in case of GC
50628ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    mov    r2, r9                              @ pass Thread::Current
50728ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    mov    r3, sp                              @ pass SP
50828ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
50928ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    bl     artInitializeTypeFromCode
51028ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
511637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
512b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    DELIVER_PENDING_EXCEPTION
513468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_initialize_type
514b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers
515b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    /*
516b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers     * Entry from managed code when type_idx needs to be checked for access and dex cache may also
51757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * miss.
518b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers     */
5199329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artInitializeTypeAndVerifyAccessFromCode
520468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_initialize_type_and_verify_access
521b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME           @ save callee saves in case of GC
522b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    mov    r2, r9                              @ pass Thread::Current
523b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    mov    r3, sp                              @ pass SP
5248a1ea9f2707a34483faa0e49cdbf8653e0e8bb6dElliott Hughes    @ artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
525b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    bl     artInitializeTypeAndVerifyAccessFromCode
526b093c6b27f8ea9bbe2d49c03ebe345203a121199Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
527637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
52828ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    DELIVER_PENDING_EXCEPTION
529468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_initialize_type_and_verify_access
53028ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers
531ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
53257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 32-bit primitive value.
533ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
5349329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGet32StaticFromCode
535468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_static
536ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
5371bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r1, [sp, #32]                 @ pass referrer
538ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
539ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
540ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGet32StaticFromCode        @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
541637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r1, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
542ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
543637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r1, 1f                        @ success if no exception pending
544637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
545637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
546ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
547468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_static
548ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
549ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
55057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load a 64-bit primitive value.
551ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
5529329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGet64StaticFromCode
553468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_static
554ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
5551bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r1, [sp, #32]                 @ pass referrer
556ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
557ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
558ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGet64StaticFromCode        @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
559637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r2, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
560ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
561637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r2, 1f                        @ success if no exception pending
562637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
563637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
564ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
565468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_static
566ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
567ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
56857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and load an object reference.
569ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
5709329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGetObjStaticFromCode
571468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_static
572ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
5731bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r1, [sp, #32]                 @ pass referrer
574ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
575ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
576ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGetObjStaticFromCode       @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
577637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r1, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
578ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
579637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r1, 1f                        @ success if no exception pending
580637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
581637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
582ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
583468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_static
584ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
5851bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
58657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 32-bit primitive value.
5871bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
5889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGet32InstanceFromCode
589468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get32_instance
5901bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
5911bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r2, [sp, #32]                 @ pass referrer
5921bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r3, r9                        @ pass Thread::Current
593865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
594865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!              @ expand the frame and pass SP
5951bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artGet32InstanceFromCode      @ (field_idx, Object*, referrer, Thread*, SP)
596865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                       @ strip the extra frame
597637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r1, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
5981bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
599637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r1, 1f                        @ success if no exception pending
600637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
601637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
6021bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
603468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get32_instance
6041bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
6051bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
60657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load a 64-bit primitive value.
6071bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
6089329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGet64InstanceFromCode
609468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get64_instance
6101bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
6111bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r2, [sp, #32]                 @ pass referrer
6121bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r3, r9                        @ pass Thread::Current
613865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
614865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!              @ expand the frame and pass SP
6159329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
6169329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
6171bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artGet64InstanceFromCode      @ (field_idx, Object*, referrer, Thread*, SP)
618865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                       @ strip the extra frame
6199329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
620637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r2, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
6211bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
622637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r2, 1f                        @ success if no exception pending
623637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
624637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
6251bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
626468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get64_instance
6271bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
6281bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
62957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and load an object reference.
6301bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
6319329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artGetObjInstanceFromCode
632468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_get_obj_instance
6331bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
6341bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r2, [sp, #32]                 @ pass referrer
6351bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r3, r9                        @ pass Thread::Current
636865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
637865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!              @ expand the frame and pass SP
6389329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
6399329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
6401bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artGetObjInstanceFromCode     @ (field_idx, Object*, referrer, Thread*, SP)
641865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                       @ strip the extra frame
6429329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
643637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr    r1, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
6441bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
645637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r1, 1f                        @ success if no exception pending
646637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                            @ return on success
647637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
6481bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
649468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_get_obj_instance
6501bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
651ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
65257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 32-bit primitive value.
653ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
6549329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSet32StaticFromCode
655468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_static
656ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
6571bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r2, [sp, #32]                 @ pass referrer
658ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, r9                        @ pass Thread::Current
659865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
660865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!              @ expand the frame and pass SP
6619329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
6629329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
6631bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artSet32StaticFromCode        @ (field_idx, new_val, referrer, Thread*, SP)
664865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                       @ strip the extra frame
6659329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
666ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
667637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
668ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
669468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_static
670ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
671ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
67257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store a 64-bit primitive value.
67319abfb4f9af450e2ce3a801c5a0c34c4193e3e57Brian Carlstrom     * On entry r0 holds field index, r1:r2 hold new_val
674ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
6759329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSet64StaticFromCode
676468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_static
677ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
67819abfb4f9af450e2ce3a801c5a0c34c4193e3e57Brian Carlstrom    mov    r3, r2                        @ pass one half of wide argument
67919abfb4f9af450e2ce3a801c5a0c34c4193e3e57Brian Carlstrom    mov    r2, r1                        @ pass other half of wide argument
6801bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r1, [sp, #32]                 @ pass referrer
681ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r12, sp                       @ save SP
682ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    sub    sp, #8                        @ grow frame for alignment with stack args
6839329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
6849329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
685ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    push   {r9, r12}                     @ pass Thread::Current and SP
6869329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r9, r12}
6879329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
6889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 0
689ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artSet64StaticFromCode        @ (field_idx, referrer, new_val, Thread*, SP)
690ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    add    sp, #16                       @ release out args
691ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME   @ TODO: we can clearly save an add here
692637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
693ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
694468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_static
695ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
696ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
69757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve a static field and store an object reference.
698ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
6999329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSetObjStaticFromCode
700468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_static
701ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
7021bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r2, [sp, #32]                 @ pass referrer
703ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, r9                        @ pass Thread::Current
704865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
705865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!              @ expand the frame and pass SP
7069329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
7079329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
7081bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artSetObjStaticFromCode       @ (field_idx, new_val, referrer, Thread*, SP)
709865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                       @ strip the extra frame
7109329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
711ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
712637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
7131bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
714468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_static
7151bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
7161bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
71757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 32-bit primitive value.
7181bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
7199329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSet32InstanceFromCode
720468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set32_instance
7211bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
7221bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r3, [sp, #32]                 @ pass referrer
7231bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r12, sp                       @ save SP
7241bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    sub    sp, #8                        @ grow frame for alignment with stack args
7259329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
7269329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7271bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    push   {r9, r12}                     @ pass Thread::Current and SP
7289329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r9, r12}
7299329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7309329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 0
7319329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r12, 4
7321bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artSet32InstanceFromCode      @ (field_idx, Object*, new_val, referrer, Thread*, SP)
7331bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    add    sp, #16                       @ release out args
7349329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
7351bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME   @ TODO: we can clearly save an add here
736637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
7371bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
738468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set32_instance
7391bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
7401bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
74157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store a 64-bit primitive value.
7421bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
7439329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSet32InstanceFromCode
744468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set64_instance
7451bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
7461bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r12, sp                       @ save SP
7471bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    sub    sp, #8                        @ grow frame for alignment with stack args
7489329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
7499329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7501bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    push   {r9, r12}                     @ pass Thread::Current and SP
7519329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r9, r12}
7529329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7539329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 0
7541bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artSet64InstanceFromCode      @ (field_idx, Object*, new_val, Thread*, SP)
7551bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    add    sp, #16                       @ release out args
7569329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
7571bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME   @ TODO: we can clearly save an add here
758637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
7591bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    DELIVER_PENDING_EXCEPTION
760468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set64_instance
7611bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers
7621bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    /*
76357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to resolve an instance field and store an object reference.
7641bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers     */
7659329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artSetObjInstanceFromCode
766468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_set_obj_instance
7671bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
7681bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    ldr    r3, [sp, #32]                 @ pass referrer
7691bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    mov    r12, sp                       @ save SP
7701bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    sub    sp, #8                        @ grow frame for alignment with stack args
7719329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
7729329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7731bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    push   {r9, r12}                     @ pass Thread::Current and SP
7749329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r9, r12}
7759329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
7769329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 0
7771bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    bl     artSetObjInstanceFromCode     @ (field_idx, Object*, new_val, referrer, Thread*, SP)
7781bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    add    sp, #16                       @ release out args
7799329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
7801bddec3a6521f16df37499754000a3b1787a52e9Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME   @ TODO: we can clearly save an add here
781637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_ZERO
782ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
783468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_set_obj_instance
7844a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee
785aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom    /*
786caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers     * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
787caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers     * exception on error. On success the String is returned. R0 holds the referring method,
788caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers     * R1 holds the string index. The fast path check for hit in strings cache has already been
789caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers     * performed.
790aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom     */
7919329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artResolveStringFromCode
792468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_resolve_string
793caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
794caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers    mov    r2, r9                     @ pass Thread::Current
795caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers    mov    r3, sp                     @ pass SP
796caab8c4ef372db5c119bfac1911fa27b174a935cIan Rogers    @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP)
797aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom    bl     artResolveStringFromCode
798aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
799637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
800aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom    DELIVER_PENDING_EXCEPTION
801468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_resolve_string
802aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom
80321d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers    /*
80421d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers     * Called by managed code to allocate an object
80521d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers     */
8069329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artAllocObjectFromCode
807468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_alloc_object
8084f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8094f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                     @ pass Thread::Current
8104f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                     @ pass SP
8114f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artAllocObjectFromCode     @ (uint32_t type_idx, Method* method, Thread*, SP)
8124f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
813637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
814ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
815468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_alloc_object
81621d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers
8173b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artAllocObjectFromCodeInstrumented
8183b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_alloc_object_instrumented
8193b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8203b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r2, r9                     @ pass Thread::Current
8213b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, sp                     @ pass SP
8223b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artAllocObjectFromCodeInstrumented     @ (uint32_t type_idx, Method* method, Thread*, SP)
8233b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
8243b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
8253b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
8263b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_alloc_object_instrumented
8273b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
828cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    /*
82928ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers     * Called by managed code to allocate an object when the caller doesn't know whether it has
83057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * access to the created type.
831cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee     */
8329329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artAllocObjectFromCodeWithAccessCheck
833468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_alloc_object_with_access_check
834cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
835cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    mov    r2, r9                     @ pass Thread::Current
836cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    mov    r3, sp                     @ pass SP
83728ad40dc3ec2f09b0ffd4f6d6787bf1b532ccd5dIan Rogers    bl     artAllocObjectFromCodeWithAccessCheck  @ (uint32_t type_idx, Method* method, Thread*, SP)
838cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
839637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
840cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee    DELIVER_PENDING_EXCEPTION
841468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_alloc_object_with_access_check
842cc4540ece917ef4b5c81ee684e3294e47e49ff5bbuzbee
8433b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artAllocObjectFromCodeWithAccessCheckInstrumented
8443b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_alloc_object_with_access_check_instrumented
8453b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8463b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r2, r9                     @ pass Thread::Current
8473b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, sp                     @ pass SP
8483b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artAllocObjectFromCodeWithAccessCheckInstrumented  @ (uint32_t type_idx, Method* method, Thread*, SP)
8493b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
8503b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
8513b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
8523b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_alloc_object_with_access_check_instrumented
8533b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
854b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers    /*
85557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to allocate an array.
856b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     */
8579329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artAllocArrayFromCode
858468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_alloc_array
8594f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8604f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, r9                     @ pass Thread::Current
861865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
862865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!           @ expand the frame and pass SP
8639329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
8649329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
8654f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
8664f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artAllocArrayFromCode
867865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                    @ strip the extra frame
8689329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
8694f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
870637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
871ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
872468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_alloc_array
873b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers
8743b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artAllocArrayFromCodeInstrumented
8753b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_alloc_array_instrumented
8763b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8773b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, r9                     @ pass Thread::Current
8783b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r12, sp
8793b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    str    r12, [sp, #-16]!           @ expand the frame and pass SP
8803b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .pad #16
8813b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset 16
8823b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    @ artAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
8833b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artAllocArrayFromCodeInstrumented
8843b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    add    sp, #16                    @ strip the extra frame
8853b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset -16
8863b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
8873b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
8883b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
8893b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_alloc_array_instrumented
8903b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
8910eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    /*
8920eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers     * Called by managed code to allocate an array when the caller doesn't know whether it has
89357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * access to the created type.
8940eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers     */
8959329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artAllocArrayFromCodeWithAccessCheck
896468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_alloc_array_with_access_check
8970eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
8980eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    mov    r3, r9                     @ pass Thread::Current
899865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
900865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9019329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
9029329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
9030eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    @ artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, SP)
9040eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    bl     artAllocArrayFromCodeWithAccessCheck
905865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                    @ strip the extra frame
9069329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
9070eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
908637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
9090eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    DELIVER_PENDING_EXCEPTION
910468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_alloc_array_with_access_check
9110eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers
9123b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artAllocArrayFromCodeWithAccessCheckInstrumented
9133b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_alloc_array_with_access_check_instrumented
9143b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
9153b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, r9                     @ pass Thread::Current
9163b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r12, sp
9173b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9183b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .pad #16
9193b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset 16
9203b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    @ artAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, component_count, Thread*, SP)
9213b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artAllocArrayFromCodeWithAccessCheckInstrumented
9223b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    add    sp, #16                    @ strip the extra frame
9233b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset -16
9243b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
9253b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
9263b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
9273b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_alloc_array_with_access_check_instrumented
9283b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
929b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers    /*
93057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
931b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     */
9329329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artCheckAndAllocArrayFromCode
933468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_check_and_alloc_array
9344f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
9354f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, r9                     @ pass Thread::Current
936865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
937865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9389329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
9399329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
9404f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
9414f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artCheckAndAllocArrayFromCode
942865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                    @ strip the extra frame
9439329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
9444f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
945637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
946ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
947468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_check_and_alloc_array
948b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers
9493b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artCheckAndAllocArrayFromCodeInstrumented
9503b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_check_and_alloc_array_instrumented
9513b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
9523b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, r9                     @ pass Thread::Current
9533b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r12, sp
9543b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9553b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .pad #16
9563b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset 16
9573b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    @ artCheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
9583b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artCheckAndAllocArrayFromCodeInstrumented
9593b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    add    sp, #16                    @ strip the extra frame
9603b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset -16
9613b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
9623b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
9633b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
9643b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_check_and_alloc_array_instrumented
9653b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
9660eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    /*
96757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY.
9680eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers     */
9699329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artCheckAndAllocArrayFromCodeWithAccessCheck
970468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_check_and_alloc_array_with_access_check
9710eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
9720eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    mov    r3, r9                     @ pass Thread::Current
973865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    mov    r12, sp
974865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9759329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #16
9769329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
9770eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    @ artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , SP)
9780eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    bl     artCheckAndAllocArrayFromCodeWithAccessCheck
979865e6e01486e3d7d61b7d0d952b420e5912c8219buzbee    add    sp, #16                    @ strip the extra frame
9809329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
9810eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
982637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    RETURN_IF_RESULT_IS_NON_ZERO
9830eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers    DELIVER_PENDING_EXCEPTION
984468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_check_and_alloc_array_with_access_check
9850eb7d7e2a0c2767b5fd86bd52436c618fd4c3120Ian Rogers
9863b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .extern artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
9873b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiENTRY art_quick_check_and_alloc_array_with_access_check_instrumented
9883b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
9893b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r3, r9                     @ pass Thread::Current
9903b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    mov    r12, sp
9913b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    str    r12, [sp, #-16]!           @ expand the frame and pass SP
9923b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .pad #16
9933b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset 16
9943b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    @ artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented(type_idx, method, count, Thread* , SP)
9953b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    bl     artCheckAndAllocArrayFromCodeWithAccessCheckInstrumented
9963b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    add    sp, #16                    @ strip the extra frame
9973b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    .cfi_adjust_cfa_offset -16
9983b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
9993b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    RETURN_IF_RESULT_IS_NON_ZERO
10003b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi    DELIVER_PENDING_EXCEPTION
10013b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi YamauchiEND art_quick_check_and_alloc_array_with_access_check_instrumented
10023b4c18933c24b8a33f38573c2ebcdb9aa16efeb5Hiroshi Yamauchi
1003dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    /*
100457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers     * Called by managed code when the value in rSUSPEND has been decremented to 0.
1005dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers     */
10069329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artTestSuspendFromCode
10079329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_test_suspend
1008474b6da273c7ce6df50a4e51eb9929a77e1611c3Ian Rogers    ldrh    r0, [rSELF, #THREAD_FLAGS_OFFSET]
10094f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    rSUSPEND, #SUSPEND_CHECK_INTERVAL  @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
1010637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r0, 1f                             @ check Thread::Current()->suspend_count_ == 0
1011637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr                                 @ return if suspend_count_ == 0
1012637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
10134f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r0, rSELF
10144f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME          @ save callee saves for stack crawl
1015c10717a0b86d5719556ac3286fcb47aa2f2416fcbuzbee    mov    r1, sp
10164a510d8750d50b77353d0a5a891d1b9b3a48ecd5Ian Rogers    bl     artTestSuspendFromCode             @ (Thread*, SP)
10174f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
10189329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_test_suspend
10194f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
1020dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    /*
1021dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers     * Called by managed code that is attempting to call a method on a proxy class. On entry
1022af6e67a4816d2593586115b89faa659225363246Ian Rogers     * r0 holds the proxy method and r1 holds the receiver; r2 and r3 may contain arguments. The
1023af6e67a4816d2593586115b89faa659225363246Ian Rogers     * frame size of the invoked proxy method agrees with a ref and args callee save frame.
1024dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers     */
10255fa60c3db4208df407113b5a69d295a9c93d53b1Jeff Hao     .extern artQuickProxyInvokeHandler
10269329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_proxy_invoke_handler
1027dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
1028dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    str     r0, [sp, #0]           @ place proxy method at bottom of frame
1029dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    mov     r2, r9                 @ pass Thread::Current
1030af6e67a4816d2593586115b89faa659225363246Ian Rogers    mov     r3, sp                 @ pass SP
10315fa60c3db4208df407113b5a69d295a9c93d53b1Jeff Hao    blx     artQuickProxyInvokeHandler  @ (Method* proxy method, receiver, Thread*, SP)
1032637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr     r2, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
10331984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    add     sp, #16                @ skip r1-r3, 4 bytes padding.
10341984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    .cfi_adjust_cfa_offset -16
1035637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz    r2, 1f                 @ success if no exception is pending
10361984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1037637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx      lr                     @ return on success
1038637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
10391984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1040dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers    DELIVER_PENDING_EXCEPTION
10419329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_proxy_invoke_handler
1042dfcdf1a0d2d8d75b4c701317e4a092498a8d1e9eIan Rogers
104388474b416eb257078e590bf9bc7957cee604a186Jeff Hao    /*
104488474b416eb257078e590bf9bc7957cee604a186Jeff Hao     * Called to resolve an imt conflict. r12 is a hidden argument that holds the target method's
104588474b416eb257078e590bf9bc7957cee604a186Jeff Hao     * dex method index.
104688474b416eb257078e590bf9bc7957cee604a186Jeff Hao     */
104788474b416eb257078e590bf9bc7957cee604a186Jeff HaoENTRY art_quick_imt_conflict_trampoline
104888474b416eb257078e590bf9bc7957cee604a186Jeff Hao    ldr    r0, [sp, #0]            @ load caller Method*
104988474b416eb257078e590bf9bc7957cee604a186Jeff Hao    ldr    r0, [r0, #METHOD_DEX_CACHE_METHODS_OFFSET]  @ load dex_cache_resolved_methods
105088474b416eb257078e590bf9bc7957cee604a186Jeff Hao    add    r0, #OBJECT_ARRAY_DATA_OFFSET  @ get starting address of data
105188474b416eb257078e590bf9bc7957cee604a186Jeff Hao    ldr    r0, [r0, r12, lsl 2]    @ load the target method
105288474b416eb257078e590bf9bc7957cee604a186Jeff Hao    b art_quick_invoke_interface_trampoline
105388474b416eb257078e590bf9bc7957cee604a186Jeff HaoEND art_quick_imt_conflict_trampoline
105488474b416eb257078e590bf9bc7957cee604a186Jeff Hao
1055468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickResolutionTrampoline
1056468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_resolution_trampoline
1057468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
1058468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    mov     r2, r9                 @ pass Thread::Current
1059468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    mov     r3, sp                 @ pass SP
1060468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    blx     artQuickResolutionTrampoline  @ (Method* called, receiver, Thread*, SP)
1061637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbz     r0, 1f                 @ is code pointer null? goto exception
1062468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    mov     r12, r0
1063468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    ldr  r0, [sp, #0]              @ load resolved method in r0
10641984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1065468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    bx      r12                    @ tail-call into actual code
1066468532ea115657709bc32ee498e701a4c71762d4Ian Rogers1:
1067468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1068468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    DELIVER_PENDING_EXCEPTION
1069468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_resolution_trampoline
1070468532ea115657709bc32ee498e701a4c71762d4Ian Rogers
1071468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .extern artQuickToInterpreterBridge
1072468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_to_interpreter_bridge
10737db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
10747db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    mov     r1, r9                 @ pass Thread::Current
10757db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    mov     r2, sp                 @ pass SP
1076468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    blx     artQuickToInterpreterBridge    @ (Method* method, Thread*, SP)
1077637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    ldr     r2, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
10781984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    add     sp, #16                @ skip r1-r3, 4 bytes padding.
10791984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    .cfi_adjust_cfa_offset -16
1080637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz    r2, 1f                 @ success if no exception is pending
10811984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1082637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx    lr                       @ return on success
1083637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:
10841984152ac92aad244ae15184d12f9ceade686b7bMathieu Chartier    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
10857db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers    DELIVER_PENDING_EXCEPTION
1086468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_to_interpreter_bridge
10877db619bb2a4e01e8532a04b613745d4926b205d7Ian Rogers
1088e343b76af81a005ef64f5e75a555389fd9147dabjeffhao    /*
10890791adc2249366c50684935a4c42ba5e58bc3746jeffhao     * Routine that intercepts method calls and returns.
1090e343b76af81a005ef64f5e75a555389fd9147dabjeffhao     */
10919329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artInstrumentationMethodEntryFromCode
10929329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artInstrumentationMethodExitFromCode
1093468532ea115657709bc32ee498e701a4c71762d4Ian RogersENTRY art_quick_instrumentation_entry
109462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
109562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    str   r0, [sp, #4]     @ preserve r0
109662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r12, sp          @ remember sp
109762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    str   lr, [sp, #-16]!  @ expand the frame and pass LR
109862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    .pad #16
10999329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
110062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    .cfi_rel_offset lr, 0
110162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r2, r9         @ pass Thread::Current
110262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r3, r12        @ pass SP
110362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    blx   artInstrumentationMethodEntryFromCode  @ (Method*, Object*, Thread*, SP, LR)
110462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    add   sp, #16        @ remove out argument and padding from stack
11059329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -16
110662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r12, r0        @ r12 holds reference to code
110762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    ldr   r0, [sp, #4]   @ restore r0
110862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1109468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    blx   r12            @ call method with lr set to art_quick_instrumentation_exit
1110468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_entry
1111468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .type art_quick_instrumentation_exit, #function
1112468532ea115657709bc32ee498e701a4c71762d4Ian Rogers    .global art_quick_instrumentation_exit
1113468532ea115657709bc32ee498e701a4c71762d4Ian Rogersart_quick_instrumentation_exit:
11149329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_startproc
11159329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .fnstart
111662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   lr, #0         @ link register is to here, so clobber with 0 for later checks
111762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME
1118306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    mov   r12, sp        @ remember bottom of caller's frame
1119e343b76af81a005ef64f5e75a555389fd9147dabjeffhao    push  {r0-r1}        @ save return value
11209329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r0-r1}
11219329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
11229329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r0, 0
11239329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r1, 4
112462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    sub   sp, #8         @ space for return value argument
11259329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .pad #8
11269329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
112762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    strd r0, [sp]        @ r0/r1 -> [sp] for fpr_res
112862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r2, r0         @ pass return value as gpr_res
112962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov   r3, r1
1130306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    mov   r0, r9         @ pass Thread::Current
1131306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    mov   r1, r12        @ pass SP
113262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    blx   artInstrumentationMethodExitFromCode  @ (Thread*, SP, gpr_res, fpr_res)
1133306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    add   sp, #8
11349329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -8
113562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers
1136306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    mov   r2, r0         @ link register saved by instrumentation
1137306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    mov   lr, r1         @ r1 is holding link register if we're to bounce to deoptimize
1138e343b76af81a005ef64f5e75a555389fd9147dabjeffhao    pop   {r0, r1}       @ restore return value
113962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    add sp, #32          @ remove callee save frame
114062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    .cfi_adjust_cfa_offset -32
1141306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    bx    r2             @ return
1142468532ea115657709bc32ee498e701a4c71762d4Ian RogersEND art_quick_instrumentation_exit
1143306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers
1144306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers    /*
114562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization
114662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers     * will long jump to the upcall with a special exception of -1.
1147306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers     */
11489329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .extern artDeoptimize
11499329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_deoptimize
115014dd5a82ad85a28612bf86e755ff929d767cea4cJeff Hao    SETUP_SAVE_ALL_CALLEE_SAVE_FRAME
115162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov    r0, r9         @ Set up args.
115262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    mov    r1, sp
115362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    blx    artDeoptimize  @ artDeoptimize(Thread*, SP)
11549329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_deoptimize
1155e343b76af81a005ef64f5e75a555389fd9147dabjeffhao
1156324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    /*
1157324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * Signed 64-bit integer multiply.
1158324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *
1159324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * Consider WXxYZ (r1r0 x r3r2) with a long multiply:
1160324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *        WX
1161324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *      x YZ
1162324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *  --------
1163324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *     ZW ZX
1164324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *  YW YX
1165324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *
1166324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * The low word of the result holds ZX, the high word holds
1167324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * (ZW+YX) + (the high overflow from ZX).  YW doesn't matter because
1168324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * it doesn't fit in the low 64 bits.
1169324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     *
1170324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * Unlike most ARM math operations, multiply instructions have
1171324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * restrictions on using the same register more than once (Rd and Rm
1172324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     * cannot be the same).
1173324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers     */
1174324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    /* mul-long vAA, vBB, vCC */
11759329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_mul_long
1176324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    push    {r9 - r10}
11779329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r9 - r10}
11789329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 8
11799329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 0
11809329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r10, 4
1181324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    mul     ip, r2, r1                  @  ip<- ZxW
1182324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    umull   r9, r10, r2, r0             @  r9/r10 <- ZxX
1183324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    mla     r2, r0, r3, ip              @  r2<- YxX + (ZxW)
1184324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    add     r10, r2, r10                @  r10<- r10 + low(ZxW + (YxX))
1185324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    mov     r0,r9
1186324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    mov     r1,r10
1187324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    pop     {r9 - r10}
11889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset -8
1189324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers    bx      lr
11909329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_mul_long
1191324e190e9de0d81d39d88474e189acef9b10bcc8Ian Rogers
11925433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
11935433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
11945433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
11955433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
11965433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
11975433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
11985433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
11995433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
12005433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
12015433072f589b61413e042eddf76e8190a048f71dbuzbee     */
12025433072f589b61413e042eddf76e8190a048f71dbuzbee    /* shl-long vAA, vBB, vCC */
1203637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan RogersARM_ENTRY art_quick_shl_long            @ ARM code as thumb code requires spills
12045433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r2<- r2 & 0x3f
12055433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, asl r2              @  r1<- r1 << r2
12065433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
12075433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r1, r1, r0, lsr r3          @  r1<- r1 | (r0 << (32-r2))
12085433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
12095433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r1, r0, asl ip              @  if r2 >= 32, r1<- r0 << (r2-32)
12105433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, asl r2              @  r0<- r0 << r2
12115433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
12129329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_shl_long
12135433072f589b61413e042eddf76e8190a048f71dbuzbee
12145433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
12155433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
12165433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
12175433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
12185433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
12195433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
12205433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
12215433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
12225433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
12235433072f589b61413e042eddf76e8190a048f71dbuzbee     */
12245433072f589b61413e042eddf76e8190a048f71dbuzbee    /* shr-long vAA, vBB, vCC */
1225637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan RogersARM_ENTRY art_quick_shr_long            @ ARM code as thumb code requires spills
12265433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r0<- r0 & 0x3f
12275433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, lsr r2              @  r0<- r2 >> r2
12285433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
12295433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r0, r0, r1, asl r3          @  r0<- r0 | (r1 << (32-r2))
12305433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
12315433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r0, r1, asr ip              @  if r2 >= 32, r0<-r1 >> (r2-32)
12325433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, asr r2              @  r1<- r1 >> r2
12335433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
12349329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_shr_long
12355433072f589b61413e042eddf76e8190a048f71dbuzbee
12365433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
12375433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
12385433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
12395433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
12405433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
12415433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
12425433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
12435433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
12445433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
12455433072f589b61413e042eddf76e8190a048f71dbuzbee     */
12465433072f589b61413e042eddf76e8190a048f71dbuzbee    /* ushr-long vAA, vBB, vCC */
1247637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan RogersARM_ENTRY art_quick_ushr_long           @ ARM code as thumb code requires spills
12485433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r0<- r0 & 0x3f
12495433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, lsr r2              @  r0<- r2 >> r2
12505433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
12515433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r0, r0, r1, asl r3          @  r0<- r0 | (r1 << (32-r2))
12525433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
12535433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r0, r1, lsr ip              @  if r2 >= 32, r0<-r1 >>> (r2-32)
12545433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, lsr r2              @  r1<- r1 >>> r2
12555433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
12569329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_ushr_long
1257fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1258fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /*
1259fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * String's indexOf.
1260fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *
1261fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * On entry:
1262fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r0:   string object (known non-null)
126386e4671975752b112b2e8969ac6652c72c8e86c7jeffhao     *    r1:   char to match (known <= 0xFFFF)
1264fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r2:   Starting offset in string data
1265fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     */
12669329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_indexof
1267fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    push {r4, r10-r11, lr} @ 4 words of callee saves
12689329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r4, r10-r11, lr}
12699329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 16
12709329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r4, 0
12719329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r10, 4
12729329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r11, 8
12739329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset lr, 12
1274fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr   r3, [r0, #STRING_COUNT_OFFSET]
1275fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr   r12, [r0, #STRING_OFFSET_OFFSET]
1276fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr   r0, [r0, #STRING_VALUE_OFFSET]
1277fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1278fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Clamp start to [0..count] */
1279fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r2, #0
1280637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    lt
1281fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    movlt r2, #0
1282fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r2, r3
1283637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    gt
1284fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    movgt r2, r3
1285fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1286fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Build a pointer to the start of string data */
1287fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    add   r0, #STRING_DATA_OFFSET
1288fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    add   r0, r0, r12, lsl #1
1289fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1290fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Save a copy in r12 to later compute result */
1291fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r12, r0
1292fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1293fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Build pointer to start of data to compare and pre-bias */
1294fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    add   r0, r0, r2, lsl #1
1295fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, #2
1296fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1297fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Compute iteration count */
1298fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r2, r3, r2
1299fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1300fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /*
1301fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * At this point we have:
1302fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *   r0: start of data to test
1303fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *   r1: char to compare
1304fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *   r2: iteration count
1305fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *   r12: original start of string data
1306fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *   r3, r4, r10, r11 available for loading string data
1307fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     */
1308fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1309fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r2, #4
1310fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    blt   indexof_remainder
1311fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1312fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeindexof_loop4:
1313fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r3, [r0, #2]!
1314fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r4, [r0, #2]!
1315fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r10, [r0, #2]!
1316fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r11, [r0, #2]!
1317fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r3, r1
1318fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   match_0
1319fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r4, r1
1320fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   match_1
1321fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r10, r1
1322fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   match_2
1323fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r11, r1
1324fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   match_3
1325fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r2, #4
1326fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bge   indexof_loop4
1327fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1328fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeindexof_remainder:
1329fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    adds    r2, #4
1330fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq     indexof_nomatch
1331fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1332fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeindexof_loop1:
1333fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r3, [r0, #2]!
1334fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r3, r1
1335fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   match_3
1336fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r2, #1
1337fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne   indexof_loop1
1338fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1339fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeindexof_nomatch:
1340fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r0, #-1
1341fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop {r4, r10-r11, pc}
1342fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1343fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeematch_0:
1344fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, #6
1345fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, r12
1346fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    asr   r0, r0, #1
1347fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop {r4, r10-r11, pc}
1348fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeematch_1:
1349fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, #4
1350fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, r12
1351fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    asr   r0, r0, #1
1352fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop {r4, r10-r11, pc}
1353fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeematch_2:
1354fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, #2
1355fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, r12
1356fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    asr   r0, r0, #1
1357fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop {r4, r10-r11, pc}
1358fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeematch_3:
1359fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    sub   r0, r12
1360fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    asr   r0, r0, #1
1361fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop {r4, r10-r11, pc}
13629329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_indexof
1363fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1364fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee   /*
1365fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * String's compareTo.
1366fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *
1367fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * Requires rARG0/rARG1 to have been previously checked for null.  Will
1368fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * return negative if this's string is < comp, 0 if they are the
1369fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * same and positive if >.
1370fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *
1371fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * On entry:
1372fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r0:   this object pointer
1373fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r1:   comp object pointer
1374fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *
1375fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     */
1376fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    .extern __memcmp16
13779329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersENTRY art_quick_string_compareto
1378fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov    r2, r0         @ this to r2, opening up r0 for return value
1379637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    sub    r0, r2, r1     @ Same?
1380637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    cbnz   r0,1f
1381637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    bx     lr
1382637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers1:                        @ Same strings, return.
1383fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1384fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    push {r4, r7-r12, lr} @ 8 words - keep alignment
13859329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .save {r4, r7-r12, lr}
13869329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_adjust_cfa_offset 32
13879329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r4, 0
13889329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r7, 4
13899329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r8, 8
13909329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r9, 12
13919329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r10, 16
13929329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r11, 20
13939329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset r12, 24
13949329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian Rogers    .cfi_rel_offset lr, 28
1395fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1396fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r4, [r2, #STRING_OFFSET_OFFSET]
1397fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r9, [r1, #STRING_OFFSET_OFFSET]
1398fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r7, [r2, #STRING_COUNT_OFFSET]
1399fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r10, [r1, #STRING_COUNT_OFFSET]
1400fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r2, [r2, #STRING_VALUE_OFFSET]
1401fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldr    r1, [r1, #STRING_VALUE_OFFSET]
1402fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1403fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /*
1404fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * At this point, we have:
1405fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    value:  r2/r1
1406fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    offset: r4/r9
1407fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    count:  r7/r10
1408fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     * We're going to compute
1409fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r11 <- countDiff
1410fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     *    r10 <- minCount
1411fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     */
1412fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     subs  r11, r7, r10
1413637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers     it    ls
1414fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     movls r10, r7
1415fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1416fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     /* Now, build pointers to the string data */
1417fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     add   r2, r2, r4, lsl #1
1418fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     add   r1, r1, r9, lsl #1
1419fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     /*
1420fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      * Note: data pointers point to previous element so we can use pre-index
1421fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      * mode with base writeback.
1422fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      */
1423fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     add   r2, #STRING_DATA_OFFSET-2   @ offset to contents[-1]
1424fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     add   r1, #STRING_DATA_OFFSET-2   @ offset to contents[-1]
1425fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1426fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee     /*
1427fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      * At this point we have:
1428fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r2: *this string data
1429fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r1: *comp string data
1430fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r10: iteration count for comparison
1431fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r11: value to return if the first part of the string is equal
1432fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r0: reserved for result
1433fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      *   r3, r4, r7, r8, r9, r12 available for loading string data
1434fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      */
1435fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1436fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r10, #2
1437fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    blt   do_remainder2
1438fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1439fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee      /*
1440fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee       * Unroll the first two checks so we can quickly catch early mismatch
1441fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee       * on long strings (but preserve incoming alignment)
1442fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee       */
1443fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1444fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r3, [r2, #2]!
1445fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r4, [r1, #2]!
1446fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r7, [r2, #2]!
1447fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r8, [r1, #2]!
1448fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r0, r3, r4
1449637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    eq
1450637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    subseq  r0, r7, r8
1451fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne   done
1452fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r10, #28
1453fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bgt   do_memcmp16
1454fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r10, #3
1455fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    blt   do_remainder
1456fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1457fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeloopback_triple:
1458fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r3, [r2, #2]!
1459fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r4, [r1, #2]!
1460fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r7, [r2, #2]!
1461fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r8, [r1, #2]!
1462fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r9, [r2, #2]!
1463fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r12,[r1, #2]!
1464fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r0, r3, r4
1465637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    eq
1466637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    subseq  r0, r7, r8
1467637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    eq
1468637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    subseq  r0, r9, r12
1469fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne   done
1470fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r10, #3
1471fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bge   loopback_triple
1472fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1473fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeedo_remainder:
1474fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    adds  r10, #3
1475fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    beq   returnDiff
1476fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1477fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeeloopback_single:
1478fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r3, [r2, #2]!
1479fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    ldrh  r4, [r1, #2]!
1480fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r0, r3, r4
1481fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne   done
1482fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    subs  r10, #1
1483fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne     loopback_single
1484fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1485fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeereturnDiff:
1486fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r0, r11
1487fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop   {r4, r7-r12, pc}
1488fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1489fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeedo_remainder2:
1490fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    adds  r10, #2
1491fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bne   loopback_single
1492fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r0, r11
1493fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop   {r4, r7-r12, pc}
1494fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee
1495fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    /* Long string case */
1496fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeedo_memcmp16:
1497fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r7, r11
1498fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    add   r0, r2, #2
1499fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    add   r1, r1, #2
1500fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    mov   r2, r10
1501fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    bl    __memcmp16
1502fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    cmp   r0, #0
1503637859cef76e7d41f7fdfd1f1aea7d60b4a315dcIan Rogers    it    eq
1504fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    moveq r0, r7
1505fc9e6fabed89d948fa8c0e9d673e430076712c60buzbeedone:
1506fc9e6fabed89d948fa8c0e9d673e430076712c60buzbee    pop   {r4, r7-r12, pc}
15079329bbb44d19866a70c6f2ff1657eafe399c5bf5Ian RogersEND art_quick_string_compareto
1508