1/*
2 * Copyright (C) 2016 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 * Interpreter entry point.
18 */
19
20    .text
21    .global SYMBOL(ExecuteMterpImpl)
22    FUNCTION_TYPE(ExecuteMterpImpl)
23
24/*
25 * On entry:
26 *  0  Thread* self
27 *  1  code_item
28 *  2  ShadowFrame
29 *  3  JValue* result_register
30 *
31 */
32
33SYMBOL(ExecuteMterpImpl):
34    .cfi_startproc
35    .cfi_def_cfa esp, 4
36
37    /* Spill callee save regs */
38    PUSH    %ebp
39    PUSH    %edi
40    PUSH    %esi
41    PUSH    %ebx
42
43    /* Allocate frame */
44    subl    $$FRAME_SIZE, %esp
45    .cfi_adjust_cfa_offset FRAME_SIZE
46
47    /* Load ShadowFrame pointer */
48    movl    IN_ARG2(%esp), %edx
49
50    /* Remember the return register */
51    movl    IN_ARG3(%esp), %eax
52    movl    %eax, SHADOWFRAME_RESULT_REGISTER_OFFSET(%edx)
53
54    /* Remember the code_item */
55    movl    IN_ARG1(%esp), %ecx
56    movl    %ecx, SHADOWFRAME_CODE_ITEM_OFFSET(%edx)
57
58    /* set up "named" registers */
59    movl    SHADOWFRAME_NUMBER_OF_VREGS_OFFSET(%edx), %eax
60    leal    SHADOWFRAME_VREGS_OFFSET(%edx), rFP
61    leal    (rFP, %eax, 4), rREFS
62    movl    SHADOWFRAME_DEX_PC_OFFSET(%edx), %eax
63    lea     CODEITEM_INSNS_OFFSET(%ecx), rPC
64    lea     (rPC, %eax, 2), rPC
65    EXPORT_PC
66
67    /* Set up for backwards branches & osr profiling */
68    movl    OFF_FP_METHOD(rFP), %eax
69    movl    %eax, OUT_ARG0(%esp)
70    leal    OFF_FP_SHADOWFRAME(rFP), %ecx
71    movl    %ecx, OUT_ARG1(%esp)
72    call    SYMBOL(MterpSetUpHotnessCountdown)
73
74    /* Starting ibase */
75    REFRESH_IBASE
76
77    /* start executing the instruction at rPC */
78    FETCH_INST
79    GOTO_NEXT
80    /* NOTE: no fallthrough */
81