• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Main interpreter entry point and support functions.
19  *
20  * The entry point selects the "standard" or "debug" interpreter and
21  * facilitates switching between them.  The standard interpreter may
22  * use the "fast" or "portable" implementation.
23  *
24  * Some debugger support functions are included here.  Ideally their
25  * entire existence would be "#ifdef WITH_DEBUGGER", but we're not that
26  * aggressive in other parts of the code yet.
27  */
28 #include "Dalvik.h"
29 #include "interp/InterpDefs.h"
30 
31 
32 /*
33  * ===========================================================================
34  *      Debugger support
35  * ===========================================================================
36  */
37 
38 /*
39  * Initialize the breakpoint address lookup table when the debugger attaches.
40  *
41  * This shouldn't be necessary -- the global area is initially zeroed out,
42  * and the events should be cleaning up after themselves.
43  */
dvmInitBreakpoints(void)44 void dvmInitBreakpoints(void)
45 {
46 #ifdef WITH_DEBUGGER
47     memset(gDvm.debugBreakAddr, 0, sizeof(gDvm.debugBreakAddr));
48 #else
49     assert(false);
50 #endif
51 }
52 
53 /*
54  * Add an address to the list, putting it in the first non-empty slot.
55  *
56  * Sometimes the debugger likes to add two entries for one breakpoint.
57  * We add two entries here, so that we get the right behavior when it's
58  * removed twice.
59  *
60  * This will only be run from the JDWP thread, and it will happen while
61  * we are updating the event list, which is synchronized.  We're guaranteed
62  * to be the only one adding entries, and the lock ensures that nobody
63  * will be trying to remove them while we're in here.
64  *
65  * "addr" is the absolute address of the breakpoint bytecode.
66  */
dvmAddBreakAddr(Method * method,int instrOffset)67 void dvmAddBreakAddr(Method* method, int instrOffset)
68 {
69 #ifdef WITH_DEBUGGER
70     const u2* addr = method->insns + instrOffset;
71     const u2** ptr = gDvm.debugBreakAddr;
72     int i;
73 
74     LOGV("BKP: add %p %s.%s (%s:%d)\n",
75         addr, method->clazz->descriptor, method->name,
76         dvmGetMethodSourceFile(method), dvmLineNumFromPC(method, instrOffset));
77 
78     method->debugBreakpointCount++;
79     for (i = 0; i < MAX_BREAKPOINTS; i++, ptr++) {
80         if (*ptr == NULL) {
81             *ptr = addr;
82             break;
83         }
84     }
85     if (i == MAX_BREAKPOINTS) {
86         /* no room; size is too small or we're not cleaning up properly */
87         LOGE("ERROR: max breakpoints exceeded\n");
88         assert(false);
89     }
90 #else
91     assert(false);
92 #endif
93 }
94 
95 /*
96  * Remove an address from the list by setting the entry to NULL.
97  *
98  * This can be called from the JDWP thread (because the debugger has
99  * cancelled the breakpoint) or from an event thread (because it's a
100  * single-shot breakpoint, e.g. "run to line").  We only get here as
101  * the result of removing an entry from the event list, which is
102  * synchronized, so it should not be possible for two threads to be
103  * updating breakpoints at the same time.
104  */
dvmClearBreakAddr(Method * method,int instrOffset)105 void dvmClearBreakAddr(Method* method, int instrOffset)
106 {
107 #ifdef WITH_DEBUGGER
108     const u2* addr = method->insns + instrOffset;
109     const u2** ptr = gDvm.debugBreakAddr;
110     int i;
111 
112     LOGV("BKP: clear %p %s.%s (%s:%d)\n",
113         addr, method->clazz->descriptor, method->name,
114         dvmGetMethodSourceFile(method), dvmLineNumFromPC(method, instrOffset));
115 
116     method->debugBreakpointCount--;
117     assert(method->debugBreakpointCount >= 0);
118     for (i = 0; i < MAX_BREAKPOINTS; i++, ptr++) {
119         if (*ptr == addr) {
120             *ptr = NULL;
121             break;
122         }
123     }
124     if (i == MAX_BREAKPOINTS) {
125         /* didn't find it */
126         LOGE("ERROR: breakpoint on %p not found\n", addr);
127         assert(false);
128     }
129 #else
130     assert(false);
131 #endif
132 }
133 
134 /*
135  * Add a single step event.  Currently this is a global item.
136  *
137  * We set up some initial values based on the thread's current state.  This
138  * won't work well if the thread is running, so it's up to the caller to
139  * verify that it's suspended.
140  *
141  * This is only called from the JDWP thread.
142  */
dvmAddSingleStep(Thread * thread,int size,int depth)143 bool dvmAddSingleStep(Thread* thread, int size, int depth)
144 {
145 #ifdef WITH_DEBUGGER
146     StepControl* pCtrl = &gDvm.stepControl;
147 
148     if (pCtrl->active && thread != pCtrl->thread) {
149         LOGW("WARNING: single-step active for %p; adding %p\n",
150             pCtrl->thread, thread);
151 
152         /*
153          * Keep going, overwriting previous.  This can happen if you
154          * suspend a thread in Object.wait, hit the single-step key, then
155          * switch to another thread and do the same thing again.
156          * The first thread's step is still pending.
157          *
158          * TODO: consider making single-step per-thread.  Adds to the
159          * overhead, but could be useful in rare situations.
160          */
161     }
162 
163     pCtrl->size = size;
164     pCtrl->depth = depth;
165     pCtrl->thread = thread;
166 
167     /*
168      * We may be stepping into or over method calls, or running until we
169      * return from the current method.  To make this work we need to track
170      * the current line, current method, and current stack depth.  We need
171      * to be checking these after most instructions, notably those that
172      * call methods, return from methods, or are on a different line from the
173      * previous instruction.
174      *
175      * We have to start with a snapshot of the current state.  If we're in
176      * an interpreted method, everything we need is in the current frame.  If
177      * we're in a native method, possibly with some extra JNI frames pushed
178      * on by PushLocalFrame, we want to use the topmost native method.
179      */
180     const StackSaveArea* saveArea;
181     void* fp;
182     void* prevFp = NULL;
183 
184     for (fp = thread->curFrame; fp != NULL; fp = saveArea->prevFrame) {
185         const Method* method;
186 
187         saveArea = SAVEAREA_FROM_FP(fp);
188         method = saveArea->method;
189 
190         if (!dvmIsBreakFrame(fp) && !dvmIsNativeMethod(method))
191             break;
192         prevFp = fp;
193     }
194     if (fp == NULL) {
195         LOGW("Unexpected: step req in native-only threadid=%d\n",
196             thread->threadId);
197         return false;
198     }
199     if (prevFp != NULL) {
200         /*
201          * First interpreted frame wasn't the one at the bottom.  Break
202          * frames are only inserted when calling from native->interp, so we
203          * don't need to worry about one being here.
204          */
205         LOGV("##### init step while in native method\n");
206         fp = prevFp;
207         assert(!dvmIsBreakFrame(fp));
208         assert(dvmIsNativeMethod(SAVEAREA_FROM_FP(fp)->method));
209         saveArea = SAVEAREA_FROM_FP(fp);
210     }
211 
212     /*
213      * Pull the goodies out.  "xtra.currentPc" should be accurate since
214      * we update it on every instruction while the debugger is connected.
215      */
216     pCtrl->method = saveArea->method;
217     // Clear out any old address set
218     if (pCtrl->pAddressSet != NULL) {
219         // (discard const)
220         free((void *)pCtrl->pAddressSet);
221         pCtrl->pAddressSet = NULL;
222     }
223     if (dvmIsNativeMethod(pCtrl->method)) {
224         pCtrl->line = -1;
225     } else {
226         pCtrl->line = dvmLineNumFromPC(saveArea->method,
227                         saveArea->xtra.currentPc - saveArea->method->insns);
228         pCtrl->pAddressSet
229                 = dvmAddressSetForLine(saveArea->method, pCtrl->line);
230     }
231     pCtrl->frameDepth = dvmComputeVagueFrameDepth(thread, thread->curFrame);
232     pCtrl->active = true;
233 
234     LOGV("##### step init: thread=%p meth=%p '%s' line=%d frameDepth=%d depth=%s size=%s\n",
235         pCtrl->thread, pCtrl->method, pCtrl->method->name,
236         pCtrl->line, pCtrl->frameDepth,
237         dvmJdwpStepDepthStr(pCtrl->depth),
238         dvmJdwpStepSizeStr(pCtrl->size));
239 
240     return true;
241 #else
242     assert(false);
243     return false;
244 #endif
245 }
246 
247 /*
248  * Disable a single step event.
249  */
dvmClearSingleStep(Thread * thread)250 void dvmClearSingleStep(Thread* thread)
251 {
252 #ifdef WITH_DEBUGGER
253     UNUSED_PARAMETER(thread);
254 
255     gDvm.stepControl.active = false;
256 #else
257     assert(false);
258 #endif
259 }
260 
261 
262 /*
263  * Recover the "this" pointer from the current interpreted method.  "this"
264  * is always in "in0" for non-static methods.
265  *
266  * The "ins" start at (#of registers - #of ins).  Note in0 != v0.
267  *
268  * This works because "dx" guarantees that it will work.  It's probably
269  * fairly common to have a virtual method that doesn't use its "this"
270  * pointer, in which case we're potentially wasting a register.  However,
271  * the debugger doesn't treat "this" as just another argument.  For
272  * example, events (such as breakpoints) can be enabled for specific
273  * values of "this".  There is also a separate StackFrame.ThisObject call
274  * in JDWP that is expected to work for any non-native non-static method.
275  *
276  * Because we need it when setting up debugger event filters, we want to
277  * be able to do this quickly.
278  */
dvmGetThisPtr(const Method * method,const u4 * fp)279 Object* dvmGetThisPtr(const Method* method, const u4* fp)
280 {
281     if (dvmIsStaticMethod(method))
282         return NULL;
283     return (Object*)fp[method->registersSize - method->insSize];
284 }
285 
286 
287 #if defined(WITH_TRACKREF_CHECKS)
288 /*
289  * Verify that all internally-tracked references have been released.  If
290  * they haven't, print them and abort the VM.
291  *
292  * "debugTrackedRefStart" indicates how many refs were on the list when
293  * we were first invoked.
294  */
dvmInterpCheckTrackedRefs(Thread * self,const Method * method,int debugTrackedRefStart)295 void dvmInterpCheckTrackedRefs(Thread* self, const Method* method,
296     int debugTrackedRefStart)
297 {
298     if (dvmReferenceTableEntries(&self->internalLocalRefTable)
299         != (size_t) debugTrackedRefStart)
300     {
301         char* desc;
302         Object** top;
303         int count;
304 
305         count = dvmReferenceTableEntries(&self->internalLocalRefTable);
306 
307         LOGE("TRACK: unreleased internal reference (prev=%d total=%d)\n",
308             debugTrackedRefStart, count);
309         desc = dexProtoCopyMethodDescriptor(&method->prototype);
310         LOGE("       current method is %s.%s %s\n", method->clazz->descriptor,
311             method->name, desc);
312         free(desc);
313         top = self->internalLocalRefTable.table + debugTrackedRefStart;
314         while (top < self->internalLocalRefTable.nextEntry) {
315             LOGE("  %p (%s)\n",
316                  *top,
317                  ((*top)->clazz != NULL) ? (*top)->clazz->descriptor : "");
318             top++;
319         }
320         dvmDumpThread(self, false);
321 
322         dvmAbort();
323     }
324     //LOGI("TRACK OK\n");
325 }
326 #endif
327 
328 
329 #ifdef LOG_INSTR
330 /*
331  * Dump the v-registers.  Sent to the ILOG log tag.
332  */
dvmDumpRegs(const Method * method,const u4 * framePtr,bool inOnly)333 void dvmDumpRegs(const Method* method, const u4* framePtr, bool inOnly)
334 {
335     int i, localCount;
336 
337     localCount = method->registersSize - method->insSize;
338 
339     LOG(LOG_VERBOSE, LOG_TAG"i", "Registers (fp=%p):\n", framePtr);
340     for (i = method->registersSize-1; i >= 0; i--) {
341         if (i >= localCount) {
342             LOG(LOG_VERBOSE, LOG_TAG"i", "  v%-2d in%-2d : 0x%08x\n",
343                 i, i-localCount, framePtr[i]);
344         } else {
345             if (inOnly) {
346                 LOG(LOG_VERBOSE, LOG_TAG"i", "  [...]\n");
347                 break;
348             }
349             const char* name = "";
350             int j;
351 #if 0   // "locals" structure has changed -- need to rewrite this
352             DexFile* pDexFile = method->clazz->pDexFile;
353             const DexCode* pDexCode = dvmGetMethodCode(method);
354             int localsSize = dexGetLocalsSize(pDexFile, pDexCode);
355             const DexLocal* locals = dvmDexGetLocals(pDexFile, pDexCode);
356             for (j = 0; j < localsSize, j++) {
357                 if (locals[j].registerNum == (u4) i) {
358                     name = dvmDexStringStr(locals[j].pName);
359                     break;
360                 }
361             }
362 #endif
363             LOG(LOG_VERBOSE, LOG_TAG"i", "  v%-2d      : 0x%08x %s\n",
364                 i, framePtr[i], name);
365         }
366     }
367 }
368 #endif
369 
370 
371 /*
372  * ===========================================================================
373  *      Entry point and general support functions
374  * ===========================================================================
375  */
376 
377 /*
378  * Construct an s4 from two consecutive half-words of switch data.
379  * This needs to check endianness because the DEX optimizer only swaps
380  * half-words in instruction stream.
381  *
382  * "switchData" must be 32-bit aligned.
383  */
384 #if __BYTE_ORDER == __LITTLE_ENDIAN
s4FromSwitchData(const void * switchData)385 static inline s4 s4FromSwitchData(const void* switchData) {
386     return *(s4*) switchData;
387 }
388 #else
s4FromSwitchData(const void * switchData)389 static inline s4 s4FromSwitchData(const void* switchData) {
390     u2* data = switchData;
391     return data[0] | (((s4) data[1]) << 16);
392 #endif
393 
394 /*
395  * Find the matching case.  Returns the offset to the handler instructions.
396  *
397  * Returns 3 if we don't find a match (it's the size of the packed-switch
398  * instruction).
399  */
400 s4 dvmInterpHandlePackedSwitch(const u2* switchData, s4 testVal)
401 {
402     const int kInstrLen = 3;
403     u2 size;
404     s4 firstKey;
405     const s4* entries;
406 
407     /*
408      * Packed switch data format:
409      *  ushort ident = 0x0100   magic value
410      *  ushort size             number of entries in the table
411      *  int first_key           first (and lowest) switch case value
412      *  int targets[size]       branch targets, relative to switch opcode
413      *
414      * Total size is (4+size*2) 16-bit code units.
415      */
416     if (*switchData++ != kPackedSwitchSignature) {
417         /* should have been caught by verifier */
418         dvmThrowException("Ljava/lang/InternalError;",
419             "bad packed switch magic");
420         return kInstrLen;
421     }
422 
423     size = *switchData++;
424     assert(size > 0);
425 
426     firstKey = *switchData++;
427     firstKey |= (*switchData++) << 16;
428 
429     if (testVal < firstKey || testVal >= firstKey + size) {
430         LOGVV("Value %d not found in switch (%d-%d)\n",
431             testVal, firstKey, firstKey+size-1);
432         return kInstrLen;
433     }
434 
435     /* The entries are guaranteed to be aligned on a 32-bit boundary;
436      * we can treat them as a native int array.
437      */
438     entries = (const s4*) switchData;
439     assert(((u4)entries & 0x3) == 0);
440 
441     assert(testVal - firstKey >= 0 && testVal - firstKey < size);
442     LOGVV("Value %d found in slot %d (goto 0x%02x)\n",
443         testVal, testVal - firstKey,
444         s4FromSwitchData(&entries[testVal - firstKey]));
445     return s4FromSwitchData(&entries[testVal - firstKey]);
446 }
447 
448 /*
449  * Find the matching case.  Returns the offset to the handler instructions.
450  *
451  * Returns 3 if we don't find a match (it's the size of the sparse-switch
452  * instruction).
453  */
454 s4 dvmInterpHandleSparseSwitch(const u2* switchData, s4 testVal)
455 {
456     const int kInstrLen = 3;
457     u2 ident, size;
458     const s4* keys;
459     const s4* entries;
460     int i;
461 
462     /*
463      * Sparse switch data format:
464      *  ushort ident = 0x0200   magic value
465      *  ushort size             number of entries in the table; > 0
466      *  int keys[size]          keys, sorted low-to-high; 32-bit aligned
467      *  int targets[size]       branch targets, relative to switch opcode
468      *
469      * Total size is (2+size*4) 16-bit code units.
470      */
471 
472     if (*switchData++ != kSparseSwitchSignature) {
473         /* should have been caught by verifier */
474         dvmThrowException("Ljava/lang/InternalError;",
475             "bad sparse switch magic");
476         return kInstrLen;
477     }
478 
479     size = *switchData++;
480     assert(size > 0);
481 
482     /* The keys are guaranteed to be aligned on a 32-bit boundary;
483      * we can treat them as a native int array.
484      */
485     keys = (const s4*) switchData;
486     assert(((u4)keys & 0x3) == 0);
487 
488     /* The entries are guaranteed to be aligned on a 32-bit boundary;
489      * we can treat them as a native int array.
490      */
491     entries = keys + size;
492     assert(((u4)entries & 0x3) == 0);
493 
494     /*
495      * Run through the list of keys, which are guaranteed to
496      * be sorted low-to-high.
497      *
498      * Most tables have 3-4 entries.  Few have more than 10.  A binary
499      * search here is probably not useful.
500      */
501     for (i = 0; i < size; i++) {
502         s4 k = s4FromSwitchData(&keys[i]);
503         if (k == testVal) {
504             LOGVV("Value %d found in entry %d (goto 0x%02x)\n",
505                 testVal, i, s4FromSwitchData(&entries[i]));
506             return s4FromSwitchData(&entries[i]);
507         } else if (k > testVal) {
508             break;
509         }
510     }
511 
512     LOGVV("Value %d not found in switch\n", testVal);
513     return kInstrLen;
514 }
515 
516 /*
517  * Fill the array with predefined constant values.
518  *
519  * Returns true if job is completed, otherwise false to indicate that
520  * an exception has been thrown.
521  */
522 bool dvmInterpHandleFillArrayData(ArrayObject* arrayObj, const u2* arrayData)
523 {
524     u2 width;
525     u4 size;
526 
527     if (arrayObj == NULL) {
528         dvmThrowException("Ljava/lang/NullPointerException;", NULL);
529         return false;
530     }
531 
532     /*
533      * Array data table format:
534      *  ushort ident = 0x0300   magic value
535      *  ushort width            width of each element in the table
536      *  uint   size             number of elements in the table
537      *  ubyte  data[size*width] table of data values (may contain a single-byte
538      *                          padding at the end)
539      *
540      * Total size is 4+(width * size + 1)/2 16-bit code units.
541      */
542     if (arrayData[0] != kArrayDataSignature) {
543         dvmThrowException("Ljava/lang/InternalError;", "bad array data magic");
544         return false;
545     }
546 
547     width = arrayData[1];
548     size = arrayData[2] | (((u4)arrayData[3]) << 16);
549 
550     if (size > arrayObj->length) {
551         dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", NULL);
552         return false;
553     }
554     memcpy(arrayObj->contents, &arrayData[4], size*width);
555     return true;
556 }
557 
558 /*
559  * Find the concrete method that corresponds to "methodIdx".  The code in
560  * "method" is executing invoke-method with "thisClass" as its first argument.
561  *
562  * Returns NULL with an exception raised on failure.
563  */
564 Method* dvmInterpFindInterfaceMethod(ClassObject* thisClass, u4 methodIdx,
565     const Method* method, DvmDex* methodClassDex)
566 {
567     Method* absMethod;
568     Method* methodToCall;
569     int i, vtableIndex;
570 
571     /*
572      * Resolve the method.  This gives us the abstract method from the
573      * interface class declaration.
574      */
575     absMethod = dvmDexGetResolvedMethod(methodClassDex, methodIdx);
576     if (absMethod == NULL) {
577         absMethod = dvmResolveInterfaceMethod(method->clazz, methodIdx);
578         if (absMethod == NULL) {
579             LOGV("+ unknown method\n");
580             return NULL;
581         }
582     }
583 
584     /* make sure absMethod->methodIndex means what we think it means */
585     assert(dvmIsAbstractMethod(absMethod));
586 
587     /*
588      * Run through the "this" object's iftable.  Find the entry for
589      * absMethod's class, then use absMethod->methodIndex to find
590      * the method's entry.  The value there is the offset into our
591      * vtable of the actual method to execute.
592      *
593      * The verifier does not guarantee that objects stored into
594      * interface references actually implement the interface, so this
595      * check cannot be eliminated.
596      */
597     for (i = 0; i < thisClass->iftableCount; i++) {
598         if (thisClass->iftable[i].clazz == absMethod->clazz)
599             break;
600     }
601     if (i == thisClass->iftableCount) {
602         /* impossible in verified DEX, need to check for it in unverified */
603         dvmThrowException("Ljava/lang/IncompatibleClassChangeError;",
604             "interface not implemented");
605         return NULL;
606     }
607 
608     assert(absMethod->methodIndex <
609         thisClass->iftable[i].clazz->virtualMethodCount);
610 
611     vtableIndex =
612         thisClass->iftable[i].methodIndexArray[absMethod->methodIndex];
613     assert(vtableIndex >= 0 && vtableIndex < thisClass->vtableCount);
614     methodToCall = thisClass->vtable[vtableIndex];
615 
616 #if 0
617     /* this can happen when there's a stale class file */
618     if (dvmIsAbstractMethod(methodToCall)) {
619         dvmThrowException("Ljava/lang/AbstractMethodError;",
620             "interface method not implemented");
621         return NULL;
622     }
623 #else
624     assert(!dvmIsAbstractMethod(methodToCall) ||
625         methodToCall->nativeFunc != NULL);
626 #endif
627 
628     LOGVV("+++ interface=%s.%s concrete=%s.%s\n",
629         absMethod->clazz->descriptor, absMethod->name,
630         methodToCall->clazz->descriptor, methodToCall->name);
631     assert(methodToCall != NULL);
632 
633     return methodToCall;
634 }
635 
636 
637 /*
638  * Main interpreter loop entry point.  Select "standard" or "debug"
639  * interpreter and switch between them as required.
640  *
641  * This begins executing code at the start of "method".  On exit, "pResult"
642  * holds the return value of the method (or, if "method" returns NULL, it
643  * holds an undefined value).
644  *
645  * The interpreted stack frame, which holds the method arguments, has
646  * already been set up.
647  */
648 void dvmInterpret(Thread* self, const Method* method, JValue* pResult)
649 {
650     InterpState interpState;
651     bool change;
652 
653 #if defined(WITH_TRACKREF_CHECKS)
654     interpState.debugTrackedRefStart =
655         dvmReferenceTableEntries(&self->internalLocalRefTable);
656 #endif
657 #if defined(WITH_PROFILER) || defined(WITH_DEBUGGER)
658     interpState.debugIsMethodEntry = true;
659 #endif
660 
661     /*
662      * Initialize working state.
663      *
664      * No need to initialize "retval".
665      */
666     interpState.method = method;
667     interpState.fp = (u4*) self->curFrame;
668     interpState.pc = method->insns;
669     interpState.entryPoint = kInterpEntryInstr;
670 
671     if (dvmDebuggerOrProfilerActive())
672         interpState.nextMode = INTERP_DBG;
673     else
674         interpState.nextMode = INTERP_STD;
675 
676     assert(!dvmIsNativeMethod(method));
677 
678     /*
679      * Make sure the class is ready to go.  Shouldn't be possible to get
680      * here otherwise.
681      */
682     if (method->clazz->status < CLASS_INITIALIZING ||
683         method->clazz->status == CLASS_ERROR)
684     {
685         LOGE("ERROR: tried to execute code in unprepared class '%s' (%d)\n",
686             method->clazz->descriptor, method->clazz->status);
687         dvmDumpThread(self, false);
688         dvmAbort();
689     }
690 
691     typedef bool (*Interpreter)(Thread*, InterpState*);
692     Interpreter stdInterp;
693     if (gDvm.executionMode == kExecutionModeInterpFast)
694         stdInterp = dvmMterpStd;
695     else
696         stdInterp = dvmInterpretStd;
697 
698     change = true;
699     while (change) {
700         switch (interpState.nextMode) {
701         case INTERP_STD:
702             LOGVV("threadid=%d: interp STD\n", self->threadId);
703             change = (*stdInterp)(self, &interpState);
704             break;
705 #if defined(WITH_PROFILER) || defined(WITH_DEBUGGER)
706         case INTERP_DBG:
707             LOGVV("threadid=%d: interp DBG\n", self->threadId);
708             change = dvmInterpretDbg(self, &interpState);
709             break;
710 #endif
711         default:
712             dvmAbort();
713         }
714     }
715 
716     *pResult = interpState.retval;
717 }
718 
719