Check consistency of mterp vregs before every opcode for slow debug.

Test: ./art/test.py -b -r -t 525 --runtime-option=-XX:SlowDebug=true
Change-Id: Ia156567fb454dc547191941a1bc999a289cd39ed
diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc
index 878d921..912c444 100644
--- a/runtime/interpreter/mterp/mterp.cc
+++ b/runtime/interpreter/mterp/mterp.cc
@@ -539,6 +539,11 @@
   return MoveToExceptionHandler(self, *shadow_frame, instrumentation);
 }
 
+struct MterpCheckHelper {
+  DECLARE_RUNTIME_DEBUG_FLAG(kSlowMode);
+};
+DEFINE_RUNTIME_DEBUG_FLAG(MterpCheckHelper, kSlowMode);
+
 extern "C" void MterpCheckBefore(Thread* self, ShadowFrame* shadow_frame, uint16_t* dex_pc_ptr)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   // Check that we are using the right interpreter.
@@ -563,6 +568,9 @@
     // Save invalid dex pc to force segfault if improperly used.
     shadow_frame->SetDexPCPtr(reinterpret_cast<uint16_t*>(kExportPCPoison));
   }
+  if (MterpCheckHelper::kSlowMode) {
+    shadow_frame->CheckConsistentVRegs();
+  }
 }
 
 extern "C" void MterpLogDivideByZeroException(Thread* self, ShadowFrame* shadow_frame)