Fix single-stepping resume mode in the interpreter.

(cherry-picked from master)

When a resume attempt is cancelled due to other pending request make sure
the old native resume PC is cleared. Otherwise the JIT code cache may be
re-entered with mismatching Dalvik PC.

Also fix a code bloat problem where single-step count is not set properly
after executing a return instruction.

BUG: 5208786

Change-Id: I54775215b11eae29ccdb6111dc0fdfa99e41e08d
diff --git a/vm/interp/Interp.cpp b/vm/interp/Interp.cpp
index 85d06db..f78b7a4 100644
--- a/vm/interp/Interp.cpp
+++ b/vm/interp/Interp.cpp
@@ -1839,6 +1839,9 @@
                 // Doesn't return
                 dvmAbort();
             }
+            // In case resume is blocked by non-zero breakFlags, clear
+            // jitResumeNPC here.
+            self->jitResumeNPC = NULL;
             self->jitResumeDPC = NULL;
             self->inJitCodeCache = NULL;
 #endif
diff --git a/vm/interp/Jit.cpp b/vm/interp/Jit.cpp
index d4c5a79..494aae1 100644
--- a/vm/interp/Jit.cpp
+++ b/vm/interp/Jit.cpp
@@ -976,9 +976,12 @@
      if (allDone) {
          dvmDisableSubMode(self, kSubModeJitTraceBuild);
          if (stayOneMoreInst) {
+             // Clear jitResumeNPC explicitly since we know we don't need it
+             // here.
+             self->jitResumeNPC = NULL;
              // Keep going in single-step mode for at least one more inst
-             assert(self->jitResumeNPC == NULL);
-             self->singleStepCount = MIN(1, self->singleStepCount);
+             if (self->singleStepCount == 0)
+                 self->singleStepCount = 1;
              dvmEnableSubMode(self, kSubModeCountedStep);
          }
      }