Avoid allocating OatFile::OatClass on the heap.
Avoid allocating a BitVector for OatFile::OatClass::bitmap_
with kOatClassSomeCompiled methods. That makes the OatClass
copy-constructible as it doesn't own any memory. We use that
in OatFile::OatDexFile::GetOatClass() to return the result
by value thus avoiding one or two heap allocations per call.
Change-Id: Ic7098109028a5b49e39ef626f877de86e732ed18
diff --git a/runtime/base/bit_vector.h b/runtime/base/bit_vector.h
index c8f285e..a496dbd 100644
--- a/runtime/base/bit_vector.h
+++ b/runtime/base/bit_vector.h
@@ -119,7 +119,9 @@
bool SameBitsSet(const BitVector *src);
uint32_t NumSetBits() const;
- uint32_t NumSetBits(uint32_t num) const;
+
+ // Number of bits set in range [0, end).
+ uint32_t NumSetBits(uint32_t end) const;
Iterator* GetIterator() const;
@@ -135,6 +137,11 @@
*/
int GetHighestBitSet() const;
+ // Is bit set in storage. (No range check.)
+ static bool IsBitSet(const uint32_t* storage, uint32_t num);
+ // Number of bits set in range [0, end) in storage. (No range check.)
+ static uint32_t NumSetBits(const uint32_t* storage, uint32_t end);
+
private:
Allocator* const allocator_;
const bool expandable_; // expand bitmap if we run out?