2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * Mterp entry point and support functions.
20 #include "mterp/Mterp.h"
26 * Verify some constants used by the mterp interpreter.
28 bool dvmCheckAsmConstants(void)
30 extern char dvmAsmInstructionStart[];
31 extern char dvmAsmInstructionEnd[];
32 extern char dvmAsmSisterStart[];
33 extern char dvmAsmSisterEnd[];
37 #define ASM_DEF_VERIFY
38 #include "mterp/common/asm-constants.h"
41 LOGE("Please correct the values in mterp/common/asm-constants.h\n");
46 * If an instruction overflows the 64-byte handler size limit, it will
47 * push everything up and alter the total size. Check it here.
50 int interpSize = dvmAsmInstructionEnd - dvmAsmInstructionStart;
51 if (interpSize != 0 && interpSize != 256*width) {
52 LOGE("ERROR: unexpected asm interp size %d\n", interpSize);
53 LOGE("(did an instruction handler exceed %d bytes?)\n", width);
56 int sisterSize = dvmAsmSisterEnd - dvmAsmSisterStart;
57 LOGV("mterp: interp is %d bytes, sisters are %d bytes\n",
58 interpSize, sisterSize);
65 * "Standard" mterp entry point. This sets up a "glue" structure and then
66 * calls into the assembly interpreter implementation.
68 * (There is presently no "debug" entry point.)
70 bool dvmMterpStd(Thread* self, InterpState* glue)
74 /* configure mterp items */
76 glue->methodClassDex = glue->method->clazz->pDvmDex;
78 glue->interpStackEnd = self->interpStackEnd;
79 glue->pSelfSuspendCount = &self->suspendCount;
80 #if defined(WITH_DEBUGGER)
81 glue->pDebuggerActive = &gDvm.debuggerActive;
83 #if defined(WITH_PROFILER)
84 glue->pActiveProfilers = &gDvm.activeProfilers;
88 char* desc = dexProtoCopyMethodDescriptor(&glue->method->prototype);
89 LOGVV("mterp threadid=%d entry %d: %s.%s %s\n",
90 dvmThreadSelf()->threadId,
92 glue->method->clazz->descriptor,
97 //LOGI("glue is %p, pc=%p, fp=%p\n", glue, glue->pc, glue->fp);
98 //LOGI("first instruction is 0x%04x\n", glue->pc[0]);
100 changeInterp = dvmMterpStdRun(glue);
102 /* this is a "normal" exit; we're not coming back */
104 LOGD("|-- Leaving interpreter loop");
108 /* we're "standard", so switch to "debug" */
109 LOGVV(" mterp returned, changeInterp=%d\n", changeInterp);
110 glue->nextMode = INTERP_DBG;