quick_entrypoints_arm.S revision ce9eca6de042f26e9eebc41c9bee8b4d14f753aa
19651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers#include "asm_support.h"
29651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
35433072f589b61413e042eddf76e8190a048f71dbuzbee#if defined(__arm__)
45433072f589b61413e042eddf76e8190a048f71dbuzbee
55433072f589b61413e042eddf76e8190a048f71dbuzbee    .balign 4
64a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee
7ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /* Deliver the given exception */
8ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artDeliverExceptionFromCode
9ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /* Deliver an exception pending on a thread */
10ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artDeliverPendingException
11ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
124f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
134f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
144f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Runtime::CreateCalleeSaveMethod(kSaveAll)
154f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
1615fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers.macro SETUP_CALLEE_SAVE_FRAME
174f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    push {r4-r11, lr} @ 9 words of callee saves
1815fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    vpush {s0-s31}
194f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    sub sp, #12       @ 3 words of space, bottom word will hold Method*
204f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
214f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
224f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
234f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
244f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Runtime::CreateCalleeSaveMethod(kRefsOnly)
254f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
264f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
274f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    push {r5-r8, r10-r11, lr} @ 7 words of callee saves
284f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    sub sp, #4                @ bottom word will hold Method*
294f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
304f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
314f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
324f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    add sp, #4
334f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    pop {r5-r8, r10-r11, lr}  @ 7 words of callee saves
344f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
354f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
364f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
374f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    add sp, #4
384f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    pop {r5-r8, r10-r11, pc}  @ 7 words of callee saves
394f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
404f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
414f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
424f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Macro that sets up the callee save frame to conform with
434f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Runtime::CreateCalleeSaveMethod(kRefsAndArgs)
444f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
454f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
464f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
474f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    sub sp, #8                       @ 2 words of space, bottom word will hold Method*
484f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.endm
494f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
504f0d07c783afef89703dce32c94440fc8621a29bIan Rogers.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
514f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    add sp, #8
524f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    pop {r1-r3, r5-r8, r10-r11, lr}  @ 10 words of callee saves
5315fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers.endm
5415fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers
55ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
56ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
57ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * exception is Thread::Current()->exception_
58ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
59ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers.macro DELIVER_PENDING_EXCEPTION
60ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_CALLEE_SAVE_FRAME                    @ save callee saves for throw
61ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r0, r9                              @ pass Thread::Current
62ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r1, sp                              @ pass SP
63ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    b      artDeliverPendingExceptionFromCode  @ artDeliverPendingExceptionFromCode(Thread*, SP)
64ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers.endm
65ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
66ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .global art_deliver_exception_from_code
67bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers    /*
68ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
69ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
70ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * the bottom of the thread. On entry r0 holds Throwable*
71bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers     */
72ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_deliver_exception_from_code:
7315fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
74ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r1, r9                      @ pass Thread::Current
75ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r2, sp                      @ pass SP
76ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    b   artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
779651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
789651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    .global art_throw_null_pointer_exception_from_code
79ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artThrowNullPointerExceptionFromCode
809651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
81ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Called by managed code to create and deliver a NullPointerException
829651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
839651f425f7413772a7b5352da2b04eb7de7d416fIan Rogersart_throw_null_pointer_exception_from_code:
8415fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
85ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r0, r9                               @ pass Thread::Current
86ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r1, sp                               @ pass SP
87ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    b   artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
889651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
899651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    .global art_throw_div_zero_from_code
90ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artThrowDivZeroFromCode
919651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
92ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Called by managed code to create and deliver an ArithmeticException
939651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
949651f425f7413772a7b5352da2b04eb7de7d416fIan Rogersart_throw_div_zero_from_code:
9515fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
96ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r0, r9                  @ pass Thread::Current
97ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r1, sp                  @ pass SP
98ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    b   artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
999651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers
1009651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    .global art_throw_array_bounds_from_code
101ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artThrowArrayBoundsFromCode
1029651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers    /*
103ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
1049651f425f7413772a7b5352da2b04eb7de7d416fIan Rogers     */
1059651f425f7413772a7b5352da2b04eb7de7d416fIan Rogersart_throw_array_bounds_from_code:
10615fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
107ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r2, r9                      @ pass Thread::Current
108ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    mov r3, sp                      @ pass SP
109ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    b   artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
110bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers
111932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers    .global art_throw_stack_overflow_from_code
112932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers    .extern artThrowStackOverflowFromCode
113932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogersart_throw_stack_overflow_from_code:
11415fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
115932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers    mov r1, r9                        @ pass Thread::Current
116932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers    mov r2, sp                        @ pass SP
117932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers    b   artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
118932746a4f22951abcba7b7c4c94c27b1bf164272Ian Rogers
119c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .global art_throw_neg_array_size_from_code
120c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .extern artThrowNegArraySizeFromCode
121c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogersart_throw_neg_array_size_from_code:
12215fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
123c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r1, r9                        @ pass Thread::Current
124c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r2, sp                        @ pass SP
125c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    b   artThrowNegArraySizeFromCode  @ artThrowNegArraySizeFromCode(size, Thread*, SP)
126c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers
127c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .global art_throw_no_such_method_from_code
128c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .extern artThrowNoSuchMethodFromCode
129c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogersart_throw_no_such_method_from_code:
13015fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
131c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r1, r9                        @ pass Thread::Current
132c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r2, sp                        @ pass SP
133c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    b   artThrowNoSuchMethodFromCode  @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
134c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers
135c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .global art_throw_verification_error_from_code
136c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    .extern artThrowVerificationErrorFromCode
137c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogersart_throw_verification_error_from_code:
13815fdb8cfb5b2e3fc882113ec0648d492cebf852cIan Rogers    SETUP_CALLEE_SAVE_FRAME
139c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r2, r9                            @ pass Thread::Current
140c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers    mov r3, sp                            @ pass SP
1416c8867daab4af4667e0e816f6beafa7c5d13e043Elliott Hughes    b   artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
142c0c8dc8e677957d167066a2d06973126f108a6aaIan Rogers
1434a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee    .global art_invoke_interface_trampoline
144ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artFindInterfaceMethodInCacheFromCode
1454a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee    /*
146ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * All generated callsites for interface invokes will load arguments as usual - except instead
147ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx.  This
148ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
149ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * artFindInterfaceMethodInCacheFromCode(idx, this, method);
150ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
1514a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
152ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
153ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
1544a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
155ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
156ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * a pending exception in the thread and we branch to another stub to deliver it.
1574a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     *
158ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
159ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * pointing back to the original caller.
1604a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee     */
161ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_invoke_interface_trampoline:
1624f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME  @ save callee saves in case allocation triggers GC
1634f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                                 @ pass Thread::Current
1644f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                                 @ pass SP
1654f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artFindInterfaceMethodInCacheFromCode  @ (method_idx, this, Thread*, SP)
1664f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r12, r1                                @ save r0->code_
1674f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
1684f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                                 @ did we find the target?
1694f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bxne   r12                                    @ tail call to target if so
170ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
171ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
172ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .global art_handle_fill_data_from_code
173ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artHandleFillArrayDataFromCode
174ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /*
175ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
176ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * failure.
177ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
178ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_handle_fill_data_from_code:
1794f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case exception allocation triggers GC
1804f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                          @ pass Thread::Current
1814f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                          @ pass SP
1824f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artHandleFillArrayDataFromCode  @ (Array* array, const uint16_t* table, Thread*, SP)
1834f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
1844f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                          @ success?
1854f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    moveq  pc, lr                          @ return on success
186ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
1874f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
1884f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    .global art_lock_object_from_code
1894f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    .extern artLockObjectFromCode
1904f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    /*
1914f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     * Entry from managed code that calls artLockObjectFromCode, may block for GC
1924f0d07c783afef89703dce32c94440fc8621a29bIan Rogers     */
1934f0d07c783afef89703dce32c94440fc8621a29bIan Rogersart_lock_object_from_code:
1944f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case we block
1954f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r1, r9                     @ pass Thread::Current
1964f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, sp                     @ pass SP
1974f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artLockObjectFromCode      @ (Object* obj, Thread*, SP)
1984f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
199ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
200ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .global art_unlock_object_from_code
201ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artUnlockObjectFromCode
202ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /*
203ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
204ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
205ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_unlock_object_from_code:
2064f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case exception allocation triggers GC
2074f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r1, r9                   @ pass Thread::Current
2084f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, sp                   @ pass SP
2094f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artUnlockObjectFromCode  @ (Object* obj, Thread*, SP)
2104f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
2114f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                   @ success?
2124f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    moveq  pc, lr                   @ return on success
213ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
214ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
215ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .global art_check_cast_from_code
216ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artCheckCastFromCode
217ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    /*
218ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
219ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     */
220ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_check_cast_from_code:
2214f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME    @ save callee saves in case exception allocation triggers GC
2224f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                       @ pass Thread::Current
2234f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                       @ pass SP
2244f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artCheckCastFromCode         @ (Class* a, Class* b, Thread*, SP)
2254f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
2264f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                       @ success?
2274f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    moveq  pc, lr                       @ return on success
228ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
229e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers
230e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers    .global art_can_put_array_element_from_code
231e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers    .extern artCanPutArrayElementFromCode
232e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers    /*
233e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers     * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
234e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers     * failure.
235e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers     */
236e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogersart_can_put_array_element_from_code:
2374f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                         @ return if element == NULL
238e51a511ccee3f3c0120807321bcc160fcaa664beIan Rogers    moveq  pc, lr
2394f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME    @ save callee saves in case exception allocation triggers GC
2404f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                         @ pass Thread::Current
2414f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                         @ pass SP
2424f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artCanPutArrayElementFromCode  @ (Object* element, Class* array_class, Thread*, SP)
2434f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
2444f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                         @ success?
2454f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    moveq  pc, lr                         @ return on success
246ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
247cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers
248cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers    .global art_initialize_static_storage_from_code
2494f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    .extern artInitializeStaticStorageFromCode
250cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers    /*
251cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * Entry from managed code when uninitialized static storage, this stub will run the class
252cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * initializer and deliver the exception on error. On success the static storage base is
253cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     * returned.
254cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogers     */
255cbba6ac9bf9a6c630a7aafae6d8767b5ddbb6fd5Ian Rogersart_initialize_static_storage_from_code:
2564f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME           @ save callee saves in case of GC
2574f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                              @ pass Thread::Current
2584f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                              @ pass SP
2594f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    @ ClassLinker::InitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
2604f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artInitializeStaticStorageFromCode
2614f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
2624f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                              @ success if result is non-null
2634f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    movne  pc, lr                              @ return on success
264ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
265ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
266ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_find_instance_field_from_code
267ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artFindInstanceFieldFromCode
268ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
269ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a field of an object
270ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
271ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_find_instance_field_from_code:
272ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
273ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
274ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
275ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artFindInstanceFieldFromCode  @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
276ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
277ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r0, #0                        @ success if result is non-null
278ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    movne  pc, lr                        @ return on success
279ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
280ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
281ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_get32_static_from_code
282ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artGet32StaticFromCode
283ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
284ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and load a 32-bit primitive value
285ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
286ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_get32_static_from_code:
287ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
288ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
289ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
290ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGet32StaticFromCode        @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
291ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    ldr    r12, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
292ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
293ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r12, #0                       @ success if no exception is pending
294ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
295ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
296ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
297ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_get64_static_from_code
298ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artGet64StaticFromCode
299ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
300ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and load a 64-bit primitive value
301ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
302ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_get64_static_from_code:
303ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
304ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
305ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
306ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGet64StaticFromCode        @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
307ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    ldr    r12, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
308ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
309ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r12, #0                       @ success if no exception is pending
310ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
311ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
312ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
313ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_get_obj_static_from_code
314ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artGetObjStaticFromCode
315ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
316ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and load an object reference
317ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
318ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_get_obj_static_from_code:
319ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
320ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r2, r9                        @ pass Thread::Current
321ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, sp                        @ pass SP
322ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artGetObjStaticFromCode       @ (uint32_t field_idx, const Method* referrer, Thread*, SP)
323ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    ldr    r12, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
324ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
325ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r12, #0                       @ success if no exception is pending
326ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
327ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
328ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
329ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_set32_static_from_code
330ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artSet32StaticFromCode
331ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
332ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and store a 32-bit primitive value
333ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
334ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_set32_static_from_code:
335ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
336ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, r9                        @ pass Thread::Current
337ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    str    sp, [sp, #0]                  @ pass SP
338ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artSet32StaticFromCode        @ (field_idx, referrer, new_val, Thread*, SP)
339ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
340ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r0, #0                        @ success if result is 0
341ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
342ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
343ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
344ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_set64_static_from_code
345ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artSet32StaticFromCode
346ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
347ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and store a 64-bit primitive value
348ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
349ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_set64_static_from_code:
350ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
351ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r12, sp                       @ save SP
352ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    sub    sp, #8                        @ grow frame for alignment with stack args
353ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    push   {r9, r12}                     @ pass Thread::Current and SP
354ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artSet64StaticFromCode        @ (field_idx, referrer, new_val, Thread*, SP)
355ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    add    sp, #16                       @ release out args
356ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME   @ TODO: we can clearly save an add here
357ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r0, #0                        @ success if result is 0
358ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
359ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
360ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers
361ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .global art_set_obj_static_from_code
362ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    .extern artSetObjStaticFromCode
363ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    /*
364ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     * Called by managed code to resolve a static field and store an object reference
365ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers     */
366ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogersart_set_obj_static_from_code:
367ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME     @ save callee saves in case of GC
368ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    mov    r3, r9                        @ pass Thread::Current
369ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    str    sp, [sp, #0]                  @ pass SP
370ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    bl     artSetObjStaticFromCode       @ (field_idx, referrer, new_val, Thread*, SP)
371ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
372ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r0, #0                        @ success if result is 0
373ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    moveq  pc, lr                        @ return on success
374ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
3754a3164faefd255b1c1e911e7ad7c3d57749caaf6buzbee
37621d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers    .global art_alloc_object_from_code
37721d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers    .extern artAllocObjectFromCode
37821d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers    /*
37921d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers     * Called by managed code to allocate an object
38021d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers     */
38121d9e8323124a832a21679ca83808bc9c68ed365Ian Rogersart_alloc_object_from_code:
3824f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
3834f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r2, r9                     @ pass Thread::Current
3844f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, sp                     @ pass SP
3854f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artAllocObjectFromCode     @ (uint32_t type_idx, Method* method, Thread*, SP)
3864f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
3874f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                     @ success if result is non-null
3884f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    movne  pc, lr                     @ return on success
389ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
39021d9e8323124a832a21679ca83808bc9c68ed365Ian Rogers
391b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughes    .global art_alloc_array_from_code
392b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughes    .extern artAllocArrayFromCode
393b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers    /*
394b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     * Called by managed code to allocate an array
395b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     */
396b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughesart_alloc_array_from_code:
3974f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
3984f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, r9                     @ pass Thread::Current
3994f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    str    sp, [sp, #0]               @ pass SP
4004f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
4014f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artAllocArrayFromCode
4024f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
4034f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                     @ success if result is non-null
4044f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    movne  pc, lr                     @ return on success
405ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
406b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers
407b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughes    .global art_check_and_alloc_array_from_code
408b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughes    .extern artCheckAndAllocArrayFromCode
409b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers    /*
410b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     * Called by managed code to allocate an array
411b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers     */
412b408de744566a5c5a80be1ba7f5c88407e816945Elliott Hughesart_check_and_alloc_array_from_code:
4134f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME  @ save callee saves in case of GC
4144f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r3, r9                     @ pass Thread::Current
4154f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    str    sp, [sp, #0]               @ pass SP
4164f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
4174f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artCheckAndAllocArrayFromCode
4184f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
419ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    cmp    r0, #0                     @ success if result is non-null
420ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    movne  pc, lr                     @ return on success
421ce9eca6de042f26e9eebc41c9bee8b4d14f753aaIan Rogers    DELIVER_PENDING_EXCEPTION
422b886da8e3c26443ab4d2aa63268bd673c354c3d2Ian Rogers
4234f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    .global art_test_suspend
4244f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    .extern artCheckSuspendFromCode
4254f0d07c783afef89703dce32c94440fc8621a29bIan Rogersart_test_suspend:
4264f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    ldr    r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
4274f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    rSUSPEND, #SUSPEND_CHECK_INTERVAL  @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
4284f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    cmp    r0, #0                             @ check Thread::Current()->suspend_count_ == 0
4294f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bxeq   rLR                                @ return if suspend_count_ == 0
4304f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r0, rSELF
4314f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    mov    r1, sp
4324f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    SETUP_REF_ONLY_CALLEE_SAVE_FRAME          @ save callee saves for stack crawl
4334f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    bl     artCheckSuspendFromCode            @ (Thread*, SP)
4344f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
4354f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
4365433072f589b61413e042eddf76e8190a048f71dbuzbee    .global art_shl_long
4375433072f589b61413e042eddf76e8190a048f71dbuzbeeart_shl_long:
4385433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
4395433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
4405433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
4415433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
4425433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
4435433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
4445433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
4455433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
4465433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
4475433072f589b61413e042eddf76e8190a048f71dbuzbee     */
4485433072f589b61413e042eddf76e8190a048f71dbuzbee    /* shl-long vAA, vBB, vCC */
4495433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r2<- r2 & 0x3f
4505433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, asl r2              @  r1<- r1 << r2
4515433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
4525433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r1, r1, r0, lsr r3          @  r1<- r1 | (r0 << (32-r2))
4535433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
4545433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r1, r0, asl ip              @  if r2 >= 32, r1<- r0 << (r2-32)
4555433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, asl r2              @  r0<- r0 << r2
4565433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
4575433072f589b61413e042eddf76e8190a048f71dbuzbee
4585433072f589b61413e042eddf76e8190a048f71dbuzbee    .balign 4
4595433072f589b61413e042eddf76e8190a048f71dbuzbee    .global art_shr_long
4605433072f589b61413e042eddf76e8190a048f71dbuzbeeart_shr_long:
4615433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
4625433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
4635433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
4645433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
4655433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
4665433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
4675433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
4685433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
4695433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
4705433072f589b61413e042eddf76e8190a048f71dbuzbee     */
4715433072f589b61413e042eddf76e8190a048f71dbuzbee    /* shr-long vAA, vBB, vCC */
4725433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r0<- r0 & 0x3f
4735433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, lsr r2              @  r0<- r2 >> r2
4745433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
4755433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r0, r0, r1, asl r3          @  r0<- r0 | (r1 << (32-r2))
4765433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
4775433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r0, r1, asr ip              @  if r2 >= 32, r0<-r1 >> (r2-32)
4785433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, asr r2              @  r1<- r1 >> r2
4795433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
4805433072f589b61413e042eddf76e8190a048f71dbuzbee
4815433072f589b61413e042eddf76e8190a048f71dbuzbee    .balign 4
4825433072f589b61413e042eddf76e8190a048f71dbuzbee    .global art_ushr_long
4835433072f589b61413e042eddf76e8190a048f71dbuzbeeart_ushr_long:
4845433072f589b61413e042eddf76e8190a048f71dbuzbee    /*
4855433072f589b61413e042eddf76e8190a048f71dbuzbee     * Long integer shift.  This is different from the generic 32/64-bit
4865433072f589b61413e042eddf76e8190a048f71dbuzbee     * binary operations because vAA/vBB are 64-bit but vCC (the shift
4875433072f589b61413e042eddf76e8190a048f71dbuzbee     * distance) is 32-bit.  Also, Dalvik requires us to ignore all but the low
4885433072f589b61413e042eddf76e8190a048f71dbuzbee     * 6 bits.
4895433072f589b61413e042eddf76e8190a048f71dbuzbee     * On entry:
4905433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r0: low word
4915433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r1: high word
4925433072f589b61413e042eddf76e8190a048f71dbuzbee     *   r2: shift count
4935433072f589b61413e042eddf76e8190a048f71dbuzbee     */
4945433072f589b61413e042eddf76e8190a048f71dbuzbee    /* ushr-long vAA, vBB, vCC */
4955433072f589b61413e042eddf76e8190a048f71dbuzbee    and     r2, r2, #63                 @ r0<- r0 & 0x3f
4965433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r0, r0, lsr r2              @  r0<- r2 >> r2
4975433072f589b61413e042eddf76e8190a048f71dbuzbee    rsb     r3, r2, #32                 @  r3<- 32 - r2
4985433072f589b61413e042eddf76e8190a048f71dbuzbee    orr     r0, r0, r1, asl r3          @  r0<- r0 | (r1 << (32-r2))
4995433072f589b61413e042eddf76e8190a048f71dbuzbee    subs    ip, r2, #32                 @  ip<- r2 - 32
5005433072f589b61413e042eddf76e8190a048f71dbuzbee    movpl   r0, r1, lsr ip              @  if r2 >= 32, r0<-r1 >>> (r2-32)
5015433072f589b61413e042eddf76e8190a048f71dbuzbee    mov     r1, r1, lsr r2              @  r1<- r1 >>> r2
5025433072f589b61413e042eddf76e8190a048f71dbuzbee    bx      lr
5035433072f589b61413e042eddf76e8190a048f71dbuzbee
5045433072f589b61413e042eddf76e8190a048f71dbuzbee#endif
50567375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers
50667375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers#if defined(__i386__)
50767375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers
508ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .global art_deliver_exception_from_code
509ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    .extern artDeliverExceptionFromCode
51067375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    /*
511ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers     * Called by managed code, saves callee saves and then calls artThrowException
51267375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers     * that will place a mock Method* at the bottom of the stack.
51367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers     * EAX holds the exception.
51467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers     */
515ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersart_deliver_exception_from_code:
51667375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    // Create frame
51767375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl %edi  // Save callee saves
51867375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl %esi
51967375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl %ebp
52067375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl %ebx
52167375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl $0
52267375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl $0
52367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    pushl $0   // Will be clobbered to be Method*
52467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    mov %esp, %ecx
52567375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    // Outgoing argument set up
526ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    pushl $0  // Alignment padding
527ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    pushl %ecx                        // pass SP
528ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    pushl %fs:THREAD_SELF_OFFSET      // pass fs:offsetof(Thread,self_)
529ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    pushl %eax                        // pass Throwable*
530ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers    call artDeliverExceptionFromCode  // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
53167375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers    int3
53267375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers
53367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers#endif
534