blob: 66989597bcaff6c5a1ece2c41b26302d822ba700 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
2 * Main interpreter loop.
3 *
4 * This was written with an ARM implementation in mind.
5 */
6bool INTERP_FUNC_NAME(Thread* self, InterpState* interpState)
7{
8#if defined(EASY_GDB)
9 StackSaveArea* debugSaveArea = SAVEAREA_FROM_FP(self->curFrame);
10#endif
11#if INTERP_TYPE == INTERP_DBG
12 bool debugIsMethodEntry = interpState->debugIsMethodEntry;
13#endif
14#if defined(WITH_TRACKREF_CHECKS)
15 int debugTrackedRefStart = interpState->debugTrackedRefStart;
16#endif
17 DvmDex* methodClassDex; // curMethod->clazz->pDvmDex
18 JValue retval;
19
20 /* core state */
21 const Method* curMethod; // method we're interpreting
22 const u2* pc; // program counter
23 u4* fp; // frame pointer
24 u2 inst; // current instruction
25 /* instruction decoding */
26 u2 ref; // 16-bit quantity fetched directly
27 u2 vsrc1, vsrc2, vdst; // usually used for register indexes
28 /* method call setup */
29 const Method* methodToCall;
30 bool methodCallRange;
31
32#if defined(THREADED_INTERP)
33 /* static computed goto table */
34 DEFINE_GOTO_TABLE(handlerTable);
35#endif
36
37 /* copy state in */
38 curMethod = interpState->method;
39 pc = interpState->pc;
40 fp = interpState->fp;
41 retval = interpState->retval; /* only need for kInterpEntryReturn? */
42
43 methodClassDex = curMethod->clazz->pDvmDex;
44
45 LOGVV("threadid=%d: entry(%s) %s.%s pc=0x%x fp=%p ep=%d\n",
46 self->threadId, (interpState->nextMode == INTERP_STD) ? "STD" : "DBG",
47 curMethod->clazz->descriptor, curMethod->name, pc - curMethod->insns,
48 fp, interpState->entryPoint);
49
50 /*
51 * DEBUG: scramble this to ensure we're not relying on it.
52 */
53 methodToCall = (const Method*) -1;
54
55#if INTERP_TYPE == INTERP_DBG
56 if (debugIsMethodEntry) {
57 ILOGD("|-- Now interpreting %s.%s", curMethod->clazz->descriptor,
58 curMethod->name);
59 DUMP_REGS(curMethod, interpState->fp, false);
60 }
61#endif
62
63 switch (interpState->entryPoint) {
64 case kInterpEntryInstr:
65 /* just fall through to instruction loop or threaded kickstart */
66 break;
67 case kInterpEntryReturn:
68 goto returnFromMethod;
69 case kInterpEntryThrow:
70 goto exceptionThrown;
71 default:
72 dvmAbort();
73 }
74
75#ifdef THREADED_INTERP
76 FINISH(0); /* fetch and execute first instruction */
77#else
78 while (1) {
79 CHECK_DEBUG_AND_PROF(); /* service debugger and profiling */
80 CHECK_TRACKED_REFS(); /* check local reference tracking */
81
82 /* fetch the next 16 bits from the instruction stream */
83 inst = FETCH(0);
84
85 switch (INST_INST(inst)) {
86#endif
87
88/*--- start of opcodes ---*/