diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-22 10:25:24 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-22 10:28:50 +0100 |
commit | b556761d14e8dd0d41f1cc0f7d19726fe3497e8f (patch) | |
tree | 5c1ad1cbe81e3fe4f23de7e34e3444bd034ca245 /runtime/base | |
parent | 70f4b9929048e71c4231d7976080be6277c3374b (diff) | |
download | art-b556761d14e8dd0d41f1cc0f7d19726fe3497e8f.zip art-b556761d14e8dd0d41f1cc0f7d19726fe3497e8f.tar.gz art-b556761d14e8dd0d41f1cc0f7d19726fe3497e8f.tar.bz2 |
Fix bug in UnionIfNotIn.
Bug: 18066207
Change-Id: Ib9b24802546403b3d5a4da19996034eb45601f53
Diffstat (limited to 'runtime/base')
-rw-r--r-- | runtime/base/bit_vector.cc | 5 | ||||
-rw-r--r-- | runtime/base/bit_vector_test.cc | 26 |
2 files changed, 27 insertions, 4 deletions
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc index 3d2f0de..1d67962 100644 --- a/runtime/base/bit_vector.cc +++ b/runtime/base/bit_vector.cc @@ -145,10 +145,7 @@ bool BitVector::UnionIfNotIn(const BitVector* union_with, const BitVector* not_i // Is the storage size smaller than src's? if (storage_size_ < union_with_size) { - changed = true; - - // Set it to reallocate. - SetBit(highest_bit); + EnsureSize(highest_bit); // Paranoid: storage size should be big enough to hold this bit now. DCHECK_LT(static_cast<uint32_t> (highest_bit), storage_size_ * kWordBits); diff --git a/runtime/base/bit_vector_test.cc b/runtime/base/bit_vector_test.cc index df5d79d..31fd0e7 100644 --- a/runtime/base/bit_vector_test.cc +++ b/runtime/base/bit_vector_test.cc @@ -141,4 +141,30 @@ TEST(BitVector, SetInitialBits) { EXPECT_EQ(64u, bv.NumSetBits()); } +TEST(BitVector, UnionIfNotIn) { + { + BitVector first(2, true, Allocator::GetMallocAllocator()); + BitVector second(5, true, Allocator::GetMallocAllocator()); + BitVector third(5, true, Allocator::GetMallocAllocator()); + + second.SetBit(64); + third.SetBit(64); + bool changed = first.UnionIfNotIn(&second, &third); + EXPECT_EQ(0u, first.NumSetBits()); + EXPECT_FALSE(changed); + } + + { + BitVector first(2, true, Allocator::GetMallocAllocator()); + BitVector second(5, true, Allocator::GetMallocAllocator()); + BitVector third(5, true, Allocator::GetMallocAllocator()); + + second.SetBit(64); + bool changed = first.UnionIfNotIn(&second, &third); + EXPECT_EQ(1u, first.NumSetBits()); + EXPECT_TRUE(changed); + EXPECT_TRUE(first.IsBitSet(64)); + } +} + } // namespace art |