Make unlikely check always on, move hot code to header file.
Change-Id: I23b6f9d98d61eb6d3e2fd8254ebe7d2b513fe781
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;