OSDN Git Service

Fix various bugs found when debugger is attached to the VM.
authorBen Cheng <bccheng@google.com>
Wed, 7 Oct 2009 23:41:46 +0000 (16:41 -0700)
committerBen Cheng <bccheng@google.com>
Wed, 7 Oct 2009 23:41:46 +0000 (16:41 -0700)
See b/2161257 for details.

13 files changed:
vm/compiler/Frontend.c
vm/interp/Jit.c
vm/mterp/armv5te/footer.S
vm/mterp/out/InterpAsm-armv4t.S
vm/mterp/out/InterpAsm-armv5te-vfp.S
vm/mterp/out/InterpAsm-armv5te.S
vm/mterp/out/InterpAsm-armv7-a.S
vm/mterp/out/InterpC-portdbg.c
vm/mterp/out/InterpC-portstd.c
vm/mterp/portable/entry.c
vm/mterp/portable/portdbg.c
vm/mterp/portable/portstd.c
vm/mterp/portable/stubdefs.c

index b224614..163cdf8 100644 (file)
@@ -47,6 +47,8 @@ static inline int parseInsn(const u2 *codePtr, DecodedInstruction *decInsn,
     return insnWidth;
 }
 
+#define UNKNOWN_TARGET 0xffffffff
+
 /*
  * Identify block-ending instructions and collect supplemental information
  * regarding the following instructions.
@@ -63,6 +65,8 @@ static inline bool findBlockBoundary(const Method *caller, MIR *insn,
         case OP_RETURN_WIDE:
         case OP_RETURN_OBJECT:
         case OP_THROW:
+          *target = UNKNOWN_TARGET;
+          break;
         case OP_INVOKE_VIRTUAL:
         case OP_INVOKE_VIRTUAL_RANGE:
         case OP_INVOKE_INTERFACE:
@@ -146,7 +150,8 @@ static inline bool findBlockBoundary(const Method *caller, MIR *insn,
 
         default:
             return false;
-    } return true;
+    }
+    return true;
 }
 
 /*
@@ -524,7 +529,8 @@ bool dvmCompileTrace(JitTraceDescription *desc, int numMaxInsts,
 
         /* Target block not included in the trace */
         if (curBB->taken == NULL &&
-            (isInvoke || (targetOffset != curOffset))) {
+            (isInvoke || (targetOffset != UNKNOWN_TARGET &&
+                          targetOffset != curOffset))) {
             BasicBlock *newBB;
             if (isInvoke) {
                 /* Monomorphic callee */
index 5147e9c..68137a0 100644 (file)
@@ -644,7 +644,11 @@ int dvmCheckJit(const u2* pc, Thread* self, InterpState* interpState)
             break;
 #endif
         default:
-            dvmAbort();
+            if (!debugOrProfile) {
+                LOGE("Unexpected JIT state: %d", interpState->jitState);
+                dvmAbort();
+            }
+            break;
     }
     return switchInterp;
 }
@@ -908,6 +912,7 @@ bool dvmJitCheckTraceRequest(Thread* self, InterpState* interpState)
 #endif
                 break;
             default:
+                LOGE("Unexpected JIT state: %d", interpState->jitState);
                 dvmAbort();
         }
     }
index c204470..d92c537 100644 (file)
@@ -218,6 +218,8 @@ common_updateProfile:
 common_selectTrace:
     mov     r2,#kJitTSelectRequest      @ ask for trace selection
     str     r2,[rGLUE,#offGlue_jitState]
+    mov     r2,#kInterpEntryInstr       @ normal entry reason
+    str     r2,[rGLUE,#offGlue_entryPoint]
     mov     r1,#1                       @ set changeInterp
     b       common_gotoBail
 
@@ -306,6 +308,9 @@ common_backwardBranch:
 common_periodicChecks:
     ldr     r3, [rGLUE, #offGlue_pSelfSuspendCount] @ r3<- &suspendCount
 
+    @ speculatively store r0 before it is clobbered by dvmCheckSuspendPending
+    str     r0, [rGLUE, #offGlue_entryPoint]
+
 #if defined(WITH_DEBUGGER)
     ldr     r1, [rGLUE, #offGlue_pDebuggerActive]   @ r1<- &debuggerActive
 #endif
@@ -346,7 +351,6 @@ common_periodicChecks:
 
 3:  @ debugger/profiler enabled, bail out
     add     rPC, rPC, r9                @ update rPC
-    str     r0, [rGLUE, #offGlue_entryPoint]
     mov     r1, #1                      @ "want switch" = true
     b       common_gotoBail
 
index 3f9d371..9c7fcdc 100644 (file)
@@ -9690,6 +9690,8 @@ common_updateProfile:
 common_selectTrace:
     mov     r2,#kJitTSelectRequest      @ ask for trace selection
     str     r2,[rGLUE,#offGlue_jitState]
+    mov     r2,#kInterpEntryInstr       @ normal entry reason
+    str     r2,[rGLUE,#offGlue_entryPoint]
     mov     r1,#1                       @ set changeInterp
     b       common_gotoBail
 
@@ -9778,6 +9780,9 @@ common_backwardBranch:
 common_periodicChecks:
     ldr     r3, [rGLUE, #offGlue_pSelfSuspendCount] @ r3<- &suspendCount
 
+    @ speculatively store r0 before it is clobbered by dvmCheckSuspendPending
+    str     r0, [rGLUE, #offGlue_entryPoint]
+
 #if defined(WITH_DEBUGGER)
     ldr     r1, [rGLUE, #offGlue_pDebuggerActive]   @ r1<- &debuggerActive
 #endif
@@ -9818,7 +9823,6 @@ common_periodicChecks:
 
 3:  @ debugger/profiler enabled, bail out
     add     rPC, rPC, r9                @ update rPC
-    str     r0, [rGLUE, #offGlue_entryPoint]
     mov     r1, #1                      @ "want switch" = true
     b       common_gotoBail
 
index f36575b..d367124 100644 (file)
@@ -9208,6 +9208,8 @@ common_updateProfile:
 common_selectTrace:
     mov     r2,#kJitTSelectRequest      @ ask for trace selection
     str     r2,[rGLUE,#offGlue_jitState]
+    mov     r2,#kInterpEntryInstr       @ normal entry reason
+    str     r2,[rGLUE,#offGlue_entryPoint]
     mov     r1,#1                       @ set changeInterp
     b       common_gotoBail
 
@@ -9296,6 +9298,9 @@ common_backwardBranch:
 common_periodicChecks:
     ldr     r3, [rGLUE, #offGlue_pSelfSuspendCount] @ r3<- &suspendCount
 
+    @ speculatively store r0 before it is clobbered by dvmCheckSuspendPending
+    str     r0, [rGLUE, #offGlue_entryPoint]
+
 #if defined(WITH_DEBUGGER)
     ldr     r1, [rGLUE, #offGlue_pDebuggerActive]   @ r1<- &debuggerActive
 #endif
@@ -9336,7 +9341,6 @@ common_periodicChecks:
 
 3:  @ debugger/profiler enabled, bail out
     add     rPC, rPC, r9                @ update rPC
-    str     r0, [rGLUE, #offGlue_entryPoint]
     mov     r1, #1                      @ "want switch" = true
     b       common_gotoBail
 
index d05ccbb..1ff0d19 100644 (file)
@@ -9684,6 +9684,8 @@ common_updateProfile:
 common_selectTrace:
     mov     r2,#kJitTSelectRequest      @ ask for trace selection
     str     r2,[rGLUE,#offGlue_jitState]
+    mov     r2,#kInterpEntryInstr       @ normal entry reason
+    str     r2,[rGLUE,#offGlue_entryPoint]
     mov     r1,#1                       @ set changeInterp
     b       common_gotoBail
 
@@ -9772,6 +9774,9 @@ common_backwardBranch:
 common_periodicChecks:
     ldr     r3, [rGLUE, #offGlue_pSelfSuspendCount] @ r3<- &suspendCount
 
+    @ speculatively store r0 before it is clobbered by dvmCheckSuspendPending
+    str     r0, [rGLUE, #offGlue_entryPoint]
+
 #if defined(WITH_DEBUGGER)
     ldr     r1, [rGLUE, #offGlue_pDebuggerActive]   @ r1<- &debuggerActive
 #endif
@@ -9812,7 +9817,6 @@ common_periodicChecks:
 
 3:  @ debugger/profiler enabled, bail out
     add     rPC, rPC, r9                @ update rPC
-    str     r0, [rGLUE, #offGlue_entryPoint]
     mov     r1, #1                      @ "want switch" = true
     b       common_gotoBail
 
index 9c77641..e3ed962 100644 (file)
@@ -9144,6 +9144,8 @@ common_updateProfile:
 common_selectTrace:
     mov     r2,#kJitTSelectRequest      @ ask for trace selection
     str     r2,[rGLUE,#offGlue_jitState]
+    mov     r2,#kInterpEntryInstr       @ normal entry reason
+    str     r2,[rGLUE,#offGlue_entryPoint]
     mov     r1,#1                       @ set changeInterp
     b       common_gotoBail
 
@@ -9232,6 +9234,9 @@ common_backwardBranch:
 common_periodicChecks:
     ldr     r3, [rGLUE, #offGlue_pSelfSuspendCount] @ r3<- &suspendCount
 
+    @ speculatively store r0 before it is clobbered by dvmCheckSuspendPending
+    str     r0, [rGLUE, #offGlue_entryPoint]
+
 #if defined(WITH_DEBUGGER)
     ldr     r1, [rGLUE, #offGlue_pDebuggerActive]   @ r1<- &debuggerActive
 #endif
@@ -9272,7 +9277,6 @@ common_periodicChecks:
 
 3:  @ debugger/profiler enabled, bail out
     add     rPC, rPC, r9                @ update rPC
-    str     r0, [rGLUE, #offGlue_entryPoint]
     mov     r1, #1                      @ "want switch" = true
     b       common_gotoBail
 
index c2ae63c..03fe00e 100644 (file)
@@ -421,11 +421,9 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
     checkDebugAndProf(pc, fp, self, curMethod, &debugIsMethodEntry)
 
 #if defined(WITH_JIT)
-#define CHECK_JIT() \
-    if (dvmCheckJit(pc, self, interpState)) GOTO_bail_switch()
+#define CHECK_JIT() (dvmCheckJit(pc, self, interpState))
 #else
-#define CHECK_JIT() \
-    ((void)0)
+#define CHECK_JIT() (0)
 #endif
 
 /* File: portable/stubdefs.c */
@@ -459,7 +457,7 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
         inst = FETCH(0);                                                    \
         CHECK_DEBUG_AND_PROF();                                             \
         CHECK_TRACKED_REFS();                                               \
-        CHECK_JIT();                                                        \
+        if (CHECK_JIT()) GOTO_bail_switch();                                \
         goto *handlerTable[INST_INST(inst)];                                \
     }
 #else
@@ -520,7 +518,6 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
         }                                                                   \
     }
 
-
 /* File: c/opcommon.c */
 /* forward declarations of goto targets */
 GOTO_TARGET_DECL(filledNewArray, bool methodCallRange);
@@ -1546,6 +1543,7 @@ bool INTERP_FUNC_NAME(Thread* self, InterpState* interpState)
         /* just fall through to instruction loop or threaded kickstart */
         break;
     case kInterpEntryReturn:
+        CHECK_JIT();
         goto returnFromMethod;
     case kInterpEntryThrow:
         goto exceptionThrown;
index b695b43..a092da0 100644 (file)
@@ -419,7 +419,7 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
 
 #define CHECK_DEBUG_AND_PROF() ((void)0)
 
-#define CHECK_JIT() ((void)0)
+#define CHECK_JIT() (0)
 
 /* File: portable/stubdefs.c */
 /*
@@ -452,7 +452,7 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
         inst = FETCH(0);                                                    \
         CHECK_DEBUG_AND_PROF();                                             \
         CHECK_TRACKED_REFS();                                               \
-        CHECK_JIT();                                                        \
+        if (CHECK_JIT()) GOTO_bail_switch();                                \
         goto *handlerTable[INST_INST(inst)];                                \
     }
 #else
@@ -513,7 +513,6 @@ static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
         }                                                                   \
     }
 
-
 /* File: c/opcommon.c */
 /* forward declarations of goto targets */
 GOTO_TARGET_DECL(filledNewArray, bool methodCallRange);
@@ -1260,6 +1259,7 @@ bool INTERP_FUNC_NAME(Thread* self, InterpState* interpState)
         /* just fall through to instruction loop or threaded kickstart */
         break;
     case kInterpEntryReturn:
+        CHECK_JIT();
         goto returnFromMethod;
     case kInterpEntryThrow:
         goto exceptionThrown;
index f0e63f1..4a6ed4e 100644 (file)
@@ -95,6 +95,7 @@ bool INTERP_FUNC_NAME(Thread* self, InterpState* interpState)
         /* just fall through to instruction loop or threaded kickstart */
         break;
     case kInterpEntryReturn:
+        CHECK_JIT();
         goto returnFromMethod;
     case kInterpEntryThrow:
         goto exceptionThrown;
index 04132cb..014d866 100644 (file)
@@ -5,9 +5,7 @@
     checkDebugAndProf(pc, fp, self, curMethod, &debugIsMethodEntry)
 
 #if defined(WITH_JIT)
-#define CHECK_JIT() \
-    if (dvmCheckJit(pc, self, interpState)) GOTO_bail_switch()
+#define CHECK_JIT() (dvmCheckJit(pc, self, interpState))
 #else
-#define CHECK_JIT() \
-    ((void)0)
+#define CHECK_JIT() (0)
 #endif
index f55e8e7..f13bca7 100644 (file)
@@ -3,4 +3,4 @@
 
 #define CHECK_DEBUG_AND_PROF() ((void)0)
 
-#define CHECK_JIT() ((void)0)
+#define CHECK_JIT() (0)
index 305aebb..717e746 100644 (file)
@@ -28,7 +28,7 @@
         inst = FETCH(0);                                                    \
         CHECK_DEBUG_AND_PROF();                                             \
         CHECK_TRACKED_REFS();                                               \
-        CHECK_JIT();                                                        \
+        if (CHECK_JIT()) GOTO_bail_switch();                                \
         goto *handlerTable[INST_INST(inst)];                                \
     }
 #else
@@ -88,4 +88,3 @@
             GOTO_bail_switch();                                             \
         }                                                                   \
     }
-