entry.S revision 0c2dc522d0e120f346cf0a40c8cf0c93346131c2
1/*
2 * Copyright (C) 2008 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
18    .text
19    .global dvmMterpStdRun
20    .type   dvmMterpStdRun, %function
21/*
22 * bool dvmMterpStdRun(Thread* self)
23 *
24 * Interpreter entry point.  Returns changeInterp.
25 *
26 */
27dvmMterpStdRun:
28    push    %ebp                 # save caller base pointer
29    movl    %esp, %ebp           # set our %ebp
30    movl    rSELF, %ecx          # get incoming rSELF
31/*
32 * At this point we've allocated one slot on the stack
33 * via push and stack is 8-byte aligned.  Allocate space
34 * for 9 spill slots, 4 local slots, 5 arg slots to bring
35 * us to 16-byte alignment
36 */
37    subl    $$(FRAME_SIZE-4), %esp
38
39/* Spill callee save regs */
40    movl    %edi,EDI_SPILL(%ebp)
41    movl    %esi,ESI_SPILL(%ebp)
42    movl    %ebx,EBX_SPILL(%ebp)
43
44/* Set up "named" registers */
45    movl    offThread_pc(%ecx),rPC
46    movl    offThread_curFrame(%ecx),rFP
47    movl    offThread_curHandlerTable(%ecx),rIBASE
48
49    /* Remember %esp for future "longjmp" */
50    movl    %esp,offThread_bailPtr(%ecx)
51
52    /* Fetch next instruction before potential jump */
53    FETCH_INST
54#if defined(WITH_JIT)
55    GET_JIT_PROF_TABLE %ecx %eax
56    movl        $$0, offThread_inJitCodeCache(%ecx)
57    cmpl        $$0, %eax
58    jne         common_updateProfile # set up %ebx & %edx & rPC
59#endif
60
61   /* Normal case: start executing the instruction at rPC */
62    GOTO_NEXT
63
64    .global dvmMterpStdBail
65    .type   dvmMterpStdBail, %function
66/*
67 * void dvmMterpStdBail(Thread* self, bool changeInterp)
68 *
69 * Restore the stack pointer and PC from the save point established on entry.
70 * This is essentially the same as a longjmp, but should be cheaper.  The
71 * last instruction causes us to return to whoever called dvmMterpStdRun.
72 *
73 * We're not going to build a standard frame here, so the arg accesses will
74 * look a little strange.
75 *
76 * On entry:
77 *  esp+4 (arg0)  Thread* self
78 *  esp+8 (arg1)  bool changeInterp
79 */
80dvmMterpStdBail:
81    movl    4(%esp),%ecx                 # grab self
82    movl    8(%esp),%eax                 # changeInterp to return reg
83    movl    offThread_bailPtr(%ecx),%esp # Restore "setjmp" esp
84    movl    %esp,%ebp
85    addl    $$(FRAME_SIZE-4), %ebp       # Restore %ebp at point of setjmp
86    movl    EDI_SPILL(%ebp),%edi
87    movl    ESI_SPILL(%ebp),%esi
88    movl    EBX_SPILL(%ebp),%ebx
89    movl    %ebp, %esp                   # strip frame
90    pop     %ebp                         # restore caller's ebp
91    ret                                  # return to dvmMterpStdRun's caller
92
93
94#ifdef WITH_JIT
95    .global     dvmNcgInvokeInterpreter
96    .type       dvmNcgInvokeInterpreter, %function
97/* input: start of method in %eax */
98dvmNcgInvokeInterpreter:
99    movl        %eax, rPC
100    movl   rSELF, %ecx
101    movl   offThread_curHandlerTable(%ecx),rIBASE
102    FETCH_INST_R %ecx                    # %edx<- opcode
103    GOTO_NEXT_R %ecx                    # start executing the instruction at rPC
104#endif
105
106/*
107 * Strings
108 */
109    .section    .rodata
110.LstrBadEntryPoint:
111    .asciz  "Bad entry point %d\n"
112
113