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    .text
18
19/*
20 * Interpreter entry point.
21 * On entry:
22 *  x0  Thread* self/
23 *  x1  insns_
24 *  x2  ShadowFrame
25 *  x3  JValue* result_register
26 *
27 */
28ENTRY ExecuteMterpImpl
29    SAVE_TWO_REGS_INCREASE_FRAME xPROFILE, x27, 80
30    SAVE_TWO_REGS                xIBASE, xREFS, 16
31    SAVE_TWO_REGS                xSELF, xINST, 32
32    SAVE_TWO_REGS                xPC, xFP, 48
33    SAVE_TWO_REGS                fp, lr, 64
34    add     fp, sp, #64
35
36    /* Remember the return register */
37    str     x3, [x2, #SHADOWFRAME_RESULT_REGISTER_OFFSET]
38
39    /* Remember the dex instruction pointer */
40    str     x1, [x2, #SHADOWFRAME_DEX_INSTRUCTIONS_OFFSET]
41
42    /* set up "named" registers */
43    mov     xSELF, x0
44    ldr     w0, [x2, #SHADOWFRAME_NUMBER_OF_VREGS_OFFSET]
45    add     xFP, x2, #SHADOWFRAME_VREGS_OFFSET     // point to vregs.
46    add     xREFS, xFP, w0, lsl #2                 // point to reference array in shadow frame
47    ldr     w0, [x2, #SHADOWFRAME_DEX_PC_OFFSET]   // Get starting dex_pc.
48    add     xPC, x1, w0, lsl #1                    // Create direct pointer to 1st dex opcode
49    CFI_DEFINE_DEX_PC_WITH_OFFSET(CFI_TMP, CFI_DEX, 0)
50    EXPORT_PC
51
52    /* Starting ibase */
53    ldr     xIBASE, [xSELF, #THREAD_CURRENT_IBASE_OFFSET]
54
55    /* Set up for backwards branches & osr profiling */
56    ldr     x0, [xFP, #OFF_FP_METHOD]
57    add     x1, xFP, #OFF_FP_SHADOWFRAME
58    mov     x2, xSELF
59    bl      MterpSetUpHotnessCountdown
60    mov     wPROFILE, w0                // Starting hotness countdown to xPROFILE
61
62    /* start executing the instruction at rPC */
63    FETCH_INST                          // load wINST from rPC
64    GET_INST_OPCODE ip                  // extract opcode from wINST
65    GOTO_OPCODE ip                      // jump to next instruction
66    /* NOTE: no fallthrough */
67