Additional check to catch BooksTablet monkey issue

Change-Id: I9dfe695b008b2ca23998d2cfb29e5ba04354a029
diff --git a/src/compiler.cc b/src/compiler.cc
index 3388f72..b3d6367 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -963,8 +963,10 @@
   }
 
   void Run() {
+    Thread* self = Thread::Current();
     for (size_t i = begin_; i < end_; i += stripe_) {
       callback_(context_, i);
+      CHECK(!self->IsExceptionPending()) << PrettyTypeOf(self->GetException()) << " " << i;
     }
   }
 
@@ -981,6 +983,8 @@
 };
 
 void ForAll(Context* context, size_t begin, size_t end, Callback callback, size_t thread_count) {
+  Thread* self = Thread::Current();
+  CHECK(!self->IsExceptionPending()) << PrettyTypeOf(self->GetException());
   CHECK_GT(thread_count, 0U);
 
   std::vector<WorkerThread*> threads;
@@ -990,7 +994,7 @@
   threads[0]->Go();
 
   // Switch to kVmWait while we're blocked waiting for the other threads to finish.
-  ScopedThreadStateChange tsc(Thread::Current(), Thread::kVmWait);
+  ScopedThreadStateChange tsc(self, Thread::kVmWait);
   STLDeleteElements(&threads);
 }
 
diff --git a/src/monitor.cc b/src/monitor.cc
index 6887010..dcb3c04 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -237,6 +237,12 @@
   va_list args;
   va_start(args, fmt);
   Thread::Current()->ThrowNewExceptionV("Ljava/lang/IllegalMonitorStateException;", fmt, args);
+  if (!Runtime::Current()->IsStarted()) {
+    std::ostringstream ss;
+    Thread::Current()->Dump(ss);
+    std::string str(ss.str());
+    LOG(ERROR) << "IllegalMonitorStateException: " << str;
+  }
   va_end(args);
 }
 
diff --git a/src/object_utils.h b/src/object_utils.h
index d22098d..249fffb 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -71,7 +71,7 @@
   }
 
   void ChangeClass(const Class* new_c) {
-    DCHECK(new_c != NULL);
+    CHECK(new_c != NULL);
     if (dex_cache_ != NULL) {
       DexCache* new_c_dex_cache = new_c->GetDexCache();
       if (new_c_dex_cache != dex_cache_) {