Make unlikely check always on, move hot code to header file.

Change-Id: I23b6f9d98d61eb6d3e2fd8254ebe7d2b513fe781
diff --git a/src/mark_sweep.cc b/src/mark_sweep.cc
index 4a3bcbc..cf49605 100644
--- a/src/mark_sweep.cc
+++ b/src/mark_sweep.cc
@@ -100,15 +100,13 @@
 
   // Try to take advantage of locality of references within a space, failing this find the space
   // the hard way.
-  if (!current_mark_bitmap_->HasAddress(obj)) {
+  if (UNLIKELY(!current_mark_bitmap_->HasAddress(obj))) {
     current_mark_bitmap_ = heap_->GetMarkBitmap()->GetSpaceBitmap(obj);
-#ifndef NDEBUG
-    if (current_mark_bitmap_ == NULL) {
-      LOG(WARNING) << obj;
+    if (UNLIKELY(current_mark_bitmap_ == NULL)) {
+      LOG(ERROR) << "Failed to find space bitmap for object: " << obj;
       GetHeap()->DumpSpaces();
       LOG(FATAL) << "space_bitmap == NULL";
     }
-#endif
   }
 
   bool is_marked = current_mark_bitmap_->Test(obj);
diff --git a/src/space_bitmap.cc b/src/space_bitmap.cc
index 7a4c48d..cd07a81 100644
--- a/src/space_bitmap.cc
+++ b/src/space_bitmap.cc
@@ -76,15 +76,6 @@
   std::copy(source_bitmap->Begin(), source_bitmap->Begin() + source_bitmap->Size() / kWordSize, Begin());
 }
 
-// Return true iff <obj> is within the range of pointers that this bitmap could potentially cover,
-// even if a bit has not been set for it.
-bool SpaceBitmap::HasAddress(const void* obj) const {
-  // If obj < heap_begin_ then offset underflows to some very large value past the end of the bitmap.
-  const uintptr_t offset = (uintptr_t)obj - heap_begin_;
-  const size_t index = OffsetToIndex(offset);
-  return index < bitmap_size_ / kWordSize;
-}
-
 // Visits set bits in address order.  The callback is not permitted to
 // change the bitmap bits or max during the traversal.
 void SpaceBitmap::Walk(SpaceBitmap::Callback* callback, void* arg) {
diff --git a/src/space_bitmap.h b/src/space_bitmap.h
index 02f0034..68a014b 100644
--- a/src/space_bitmap.h
+++ b/src/space_bitmap.h
@@ -82,7 +82,15 @@
     return (bitmap_begin_[OffsetToIndex(offset)] & OffsetToMask(offset)) != 0;
   }
 
-  bool HasAddress(const void* addr) const;
+  // Return true iff <obj> is within the range of pointers that this bitmap could potentially cover,
+  // even if a bit has not been set for it.
+  bool HasAddress(const void* obj) const {
+    // If obj < heap_begin_ then offset underflows to some very large value past the end of the
+    // bitmap.
+    const uintptr_t offset = (uintptr_t)obj - heap_begin_;
+    const size_t index = OffsetToIndex(offset);
+    return index < bitmap_size_ / kWordSize;
+  }
 
   void VisitRange(uintptr_t base, uintptr_t max, Callback* visitor, void* arg) const;