Fix object verification.

Refactor VERIFY_OBJECT_ENABLED to become less brittle to change enum and global
constant.

Change-Id: Ie405106be81dce9a913730c7f46a5659582fa18b
diff --git a/src/heap.cc b/src/heap.cc
index a3a3a28..d7432a3 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -192,7 +192,7 @@
       total_wait_time_(0),
       measure_allocation_time_(false),
       total_allocation_time_(0),
-      verify_objects_(false) {
+      verify_object_mode_(kHeapVerificationNotPermitted) {
   if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) {
     LOG(INFO) << "Heap() entering";
   }
@@ -587,15 +587,13 @@
   return IsHeapAddress(obj) && GetLiveBitmap()->Test(obj);
 }
 
-#if VERIFY_OBJECT_ENABLED
-void Heap::VerifyObject(const Object* obj) {
-  if (obj == NULL || this == NULL || !verify_objects_ || Thread::Current() == NULL ||
+void Heap::VerifyObjectImpl(const mirror::Object* obj) {
+  if (Thread::Current() == NULL ||
       Runtime::Current()->GetThreadList()->GetLockOwner() == Thread::Current()->GetTid()) {
     return;
   }
   VerifyObjectBody(obj);
 }
-#endif
 
 void Heap::DumpSpaces() {
   // TODO: C++0x auto
@@ -632,7 +630,7 @@
   }
 
   // Ignore early dawn of the universe verifications
-  if (!VERIFY_OBJECT_FAST && GetObjectsAllocated() > 10) {
+  if (verify_object_mode_ != kVerifyAllFast && GetObjectsAllocated() > 10) {
     const byte* raw_addr = reinterpret_cast<const byte*>(obj) +
         mirror::Object::ClassOffset().Int32Value();
     const mirror::Class* c = *reinterpret_cast<mirror::Class* const *>(raw_addr);
@@ -1458,7 +1456,7 @@
   allocation_stack_.swap(live_stack_);
 
   // Sort the live stack so that we can quickly binary search it later.
-  if (VERIFY_OBJECT_ENABLED) {
+  if (verify_object_mode_ > kNoHeapVerification) {
     std::sort(live_stack_->Begin(), live_stack_->End());
   }
 }