portable_entrypoints_arm.S revision 848871b4d8481229c32e0d048a9856e5a9a17ef9
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "asm_support_arm.S"
18
19    .cfi_sections   .debug_frame
20
21    /*
22     * Portable invocation stub.
23     * On entry:
24     *   r0 = method pointer
25     *   r1 = argument array or NULL for no argument methods
26     *   r2 = size of argument array in bytes
27     *   r3 = (managed) thread pointer
28     *   [sp] = JValue* result
29     *   [sp + 4] = result type char
30     */
31ENTRY art_portable_invoke_stub
32    push   {r0, r4, r5, r9, r11, lr}       @ spill regs
33    .save  {r0, r4, r5, r9, r11, lr}
34    .pad #24
35    .cfi_adjust_cfa_offset 24
36    .cfi_rel_offset r0, 0
37    .cfi_rel_offset r4, 4
38    .cfi_rel_offset r5, 8
39    .cfi_rel_offset r9, 12
40    .cfi_rel_offset r11, 16
41    .cfi_rel_offset lr, 20
42    mov    r11, sp                         @ save the stack pointer
43    .cfi_def_cfa_register r11
44    mov    r9, r3                          @ move managed thread pointer into r9
45    mov    r4, #SUSPEND_CHECK_INTERVAL     @ reset r4 to suspend check interval
46    add    r5, r2, #16                     @ create space for method pointer in frame
47    and    r5, #0xFFFFFFF0                 @ align frame size to 16 bytes
48    sub    sp, r5                          @ reserve stack space for argument array
49    add    r0, sp, #4                      @ pass stack pointer + method ptr as dest for memcpy
50    bl     memcpy                          @ memcpy (dest, src, bytes)
51    ldr    r0, [r11]                       @ restore method*
52    ldr    r1, [sp, #4]                    @ copy arg value for r1
53    ldr    r2, [sp, #8]                    @ copy arg value for r2
54    ldr    r3, [sp, #12]                   @ copy arg value for r3
55    mov    ip, #0                          @ set ip to 0
56    str    ip, [sp]                        @ store NULL for method* at bottom of frame
57    add    sp, #16                         @ first 4 args are not passed on stack for portable
58    ldr    ip, [r0, #METHOD_CODE_OFFSET]   @ get pointer to the code
59    blx    ip                              @ call the method
60    mov    sp, r11                         @ restore the stack pointer
61    ldr    ip, [sp, #24]                   @ load the result pointer
62    strd   r0, [ip]                        @ store r0/r1 into result pointer
63    pop    {r0, r4, r5, r9, r11, lr}       @ restore spill regs
64    .cfi_adjust_cfa_offset -24
65    bx     lr
66END art_portable_invoke_stub
67
68    .extern artPortableProxyInvokeHandler
69ENTRY art_portable_proxy_invoke_handler
70    @ Fake callee save ref and args frame set up, note portable doesn't use callee save frames.
71    @ TODO: just save the registers that are needed in artPortableProxyInvokeHandler.
72    push {r1-r3, r5-r8, r10-r11, lr}  @ 10 words of callee saves
73    .save {r1-r3, r5-r8, r10-r11, lr}
74    .cfi_adjust_cfa_offset 40
75    .cfi_rel_offset r1, 0
76    .cfi_rel_offset r2, 4
77    .cfi_rel_offset r3, 8
78    .cfi_rel_offset r5, 12
79    .cfi_rel_offset r6, 16
80    .cfi_rel_offset r7, 20
81    .cfi_rel_offset r8, 24
82    .cfi_rel_offset r10, 28
83    .cfi_rel_offset r11, 32
84    .cfi_rel_offset lr, 36
85    sub sp, #8                        @ 2 words of space, bottom word will hold Method*
86    .pad #8
87    .cfi_adjust_cfa_offset 8
88    @ Begin argument set up.
89    str     r0, [sp, #0]           @ place proxy method at bottom of frame
90    mov     r2, r9                 @ pass Thread::Current
91    mov     r3, sp                 @ pass SP
92    blx     artPortableProxyInvokeHandler  @ (Method* proxy method, receiver, Thread*, SP)
93    ldr     r12, [r9, #THREAD_EXCEPTION_OFFSET]  @ load Thread::Current()->exception_
94    ldr     lr,  [sp, #44]         @ restore lr
95    add     sp,  #48               @ pop frame
96    .cfi_adjust_cfa_offset -48
97    bx      lr                     @ return
98END art_portable_proxy_invoke_handler
99
100UNIMPLEMENTED art_portable_resolution_trampoline
101UNIMPLEMENTED art_portable_to_interpreter_bridge
102