diff options
author | Andreas Gampe <agampe@google.com> | 2015-08-07 08:29:13 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-08-10 13:09:00 -0700 |
commit | f695a009725c8c840d916d01c14998f5c5f816d2 (patch) | |
tree | aead903f2740b4dd4aa3d3b286c0fa25a4c4f8ff /runtime/base | |
parent | 6e9c66e099654b63ed3648bda2daeaf0a862f047 (diff) | |
download | art-f695a009725c8c840d916d01c14998f5c5f816d2.zip art-f695a009725c8c840d916d01c14998f5c5f816d2.tar.gz art-f695a009725c8c840d916d01c14998f5c5f816d2.tar.bz2 |
ART: Change UnresolvedMergedType internal representation
Squashed cherry-picks:
* 067f1ed7816cf4eb5d6258ca31b387ddb2073ab7
* 750f7c2827318f6d07620f2ef0321218ea4d8670
* 2f90b3415aadc2587d26c767c6bfb235797119a8
* 2ea7b70b2347969f3735bd0ec1b462bd6d2ff1bd
Bug: 22881413
Diffstat (limited to 'runtime/base')
-rw-r--r-- | runtime/base/bit_vector.cc | 37 | ||||
-rw-r--r-- | runtime/base/bit_vector.h | 13 | ||||
-rw-r--r-- | runtime/base/bit_vector_test.cc | 4 |
3 files changed, 41 insertions, 13 deletions
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc index 39ce0d2..cfd3d24 100644 --- a/runtime/base/bit_vector.cc +++ b/runtime/base/bit_vector.cc @@ -24,11 +24,7 @@ namespace art { -// TODO: replace excessive argument defaulting when we are at gcc 4.7 -// or later on host with delegating constructor support. Specifically, -// starts_bits and storage_size/storage are mutually exclusive. -BitVector::BitVector(uint32_t start_bits, - bool expandable, +BitVector::BitVector(bool expandable, Allocator* allocator, uint32_t storage_size, uint32_t* storage) @@ -36,12 +32,31 @@ BitVector::BitVector(uint32_t start_bits, storage_size_(storage_size), allocator_(allocator), expandable_(expandable) { + DCHECK(storage_ != nullptr); + static_assert(sizeof(*storage_) == kWordBytes, "word bytes"); static_assert(sizeof(*storage_) * 8u == kWordBits, "word bits"); - if (storage_ == nullptr) { - storage_size_ = BitsToWords(start_bits); - storage_ = static_cast<uint32_t*>(allocator_->Alloc(storage_size_ * kWordBytes)); - } +} + +BitVector::BitVector(uint32_t start_bits, + bool expandable, + Allocator* allocator) + : BitVector(expandable, + allocator, + BitsToWords(start_bits), + static_cast<uint32_t*>(allocator->Alloc(BitsToWords(start_bits) * kWordBytes))) { +} + + +BitVector::BitVector(const BitVector& src, + bool expandable, + Allocator* allocator) + : BitVector(expandable, + allocator, + src.storage_size_, + static_cast<uint32_t*>(allocator->Alloc(src.storage_size_ * kWordBytes))) { + // Direct memcpy would be faster, but this should be fine too and is cleaner. + Copy(&src); } BitVector::~BitVector() { @@ -357,4 +372,8 @@ void BitVector::EnsureSize(uint32_t idx) { } } +Allocator* BitVector::GetAllocator() const { + return allocator_; +} + } // namespace art diff --git a/runtime/base/bit_vector.h b/runtime/base/bit_vector.h index 17835f5..237bc90 100644 --- a/runtime/base/bit_vector.h +++ b/runtime/base/bit_vector.h @@ -112,9 +112,16 @@ class BitVector { BitVector(uint32_t start_bits, bool expandable, + Allocator* allocator); + + BitVector(bool expandable, Allocator* allocator, - uint32_t storage_size = 0, - uint32_t* storage = nullptr); + uint32_t storage_size, + uint32_t* storage); + + BitVector(const BitVector& src, + bool expandable, + Allocator* allocator); virtual ~BitVector(); @@ -231,6 +238,8 @@ class BitVector { void Dump(std::ostream& os, const char* prefix) const; + Allocator* GetAllocator() const; + private: /** * @brief Dump the bitvector into buffer in a 00101..01 format. diff --git a/runtime/base/bit_vector_test.cc b/runtime/base/bit_vector_test.cc index c51b9b0..76095c2 100644 --- a/runtime/base/bit_vector_test.cc +++ b/runtime/base/bit_vector_test.cc @@ -71,7 +71,7 @@ TEST(BitVector, NoopAllocator) { uint32_t bits[kWords]; memset(bits, 0, sizeof(bits)); - BitVector bv(0U, false, Allocator::GetNoopAllocator(), kWords, bits); + BitVector bv(false, Allocator::GetNoopAllocator(), kWords, bits); EXPECT_EQ(kWords, bv.GetStorageSize()); EXPECT_EQ(kWords * sizeof(uint32_t), bv.GetSizeOf()); EXPECT_EQ(bits, bv.GetRawStorage()); @@ -128,7 +128,7 @@ TEST(BitVector, SetInitialBits) { uint32_t bits[kWords]; memset(bits, 0, sizeof(bits)); - BitVector bv(0U, false, Allocator::GetNoopAllocator(), kWords, bits); + BitVector bv(false, Allocator::GetNoopAllocator(), kWords, bits); bv.SetInitialBits(0u); EXPECT_EQ(0u, bv.NumSetBits()); bv.SetInitialBits(1u); |