diff options
author | Ian Rogers <irogers@google.com> | 2014-05-23 18:03:11 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-23 18:03:11 +0000 |
commit | ec23021ceb9f91a424c524fbfbcc9de6fb21f2b1 (patch) | |
tree | f357f025008f6b3bac1c4881ee77ff4999bbd951 /runtime | |
parent | ccddc49852a69094aecf9eb7c7de67a9c2c5c31a (diff) | |
parent | 520f37bb5c34c5d86ad0091cb84a84c163a2fa9c (diff) | |
download | android_art-ec23021ceb9f91a424c524fbfbcc9de6fb21f2b1.tar.gz android_art-ec23021ceb9f91a424c524fbfbcc9de6fb21f2b1.tar.bz2 android_art-ec23021ceb9f91a424c524fbfbcc9de6fb21f2b1.zip |
Merge "ART: Added print indices back to BitVector Dumper"
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/base/bit_vector.cc | 33 | ||||
-rw-r--r-- | runtime/base/bit_vector.h | 29 |
2 files changed, 56 insertions, 6 deletions
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc index 7dad55ec46..0053389b47 100644 --- a/runtime/base/bit_vector.cc +++ b/runtime/base/bit_vector.cc @@ -398,14 +398,12 @@ uint32_t BitVector::NumSetBits(const uint32_t* storage, uint32_t end) { void BitVector::Dump(std::ostream& os, const char *prefix) const { std::ostringstream buffer; - DumpHelper(buffer, prefix); + DumpHelper(prefix, buffer); os << buffer.str() << std::endl; } -void BitVector::DumpDot(FILE* file, const char* prefix, bool last_entry) const { - std::ostringstream buffer; - Dump(buffer, prefix); +void BitVector::DumpDotHelper(bool last_entry, FILE* file, std::ostringstream& buffer) const { // Now print it to the file. fprintf(file, " {%s}", buffer.str().c_str()); @@ -418,7 +416,32 @@ void BitVector::DumpDot(FILE* file, const char* prefix, bool last_entry) const { fprintf(file, "\\\n"); } -void BitVector::DumpHelper(std::ostringstream& buffer, const char* prefix) const { +void BitVector::DumpDot(FILE* file, const char* prefix, bool last_entry) const { + std::ostringstream buffer; + DumpHelper(prefix, buffer); + DumpDotHelper(last_entry, file, buffer); +} + +void BitVector::DumpIndicesDot(FILE* file, const char* prefix, bool last_entry) const { + std::ostringstream buffer; + DumpIndicesHelper(prefix, buffer); + DumpDotHelper(last_entry, file, buffer); +} + +void BitVector::DumpIndicesHelper(const char* prefix, std::ostringstream& buffer) const { + // Initialize it. + if (prefix != nullptr) { + buffer << prefix; + } + + for (size_t i = 0; i < number_of_bits_; i++) { + if (IsBitSet(i)) { + buffer << i << " "; + } + } +} + +void BitVector::DumpHelper(const char* prefix, std::ostringstream& buffer) const { // Initialize it. if (prefix != nullptr) { buffer << prefix; diff --git a/runtime/base/bit_vector.h b/runtime/base/bit_vector.h index 426d7c4ae0..8f9afff47d 100644 --- a/runtime/base/bit_vector.h +++ b/runtime/base/bit_vector.h @@ -207,10 +207,37 @@ class BitVector { bool EnsureSizeAndClear(unsigned int num); void Dump(std::ostream& os, const char* prefix) const; + + /** + * @brief last_entry is this the last entry for the dot dumping + * @details if not, a "|" is appended to the dump. + */ void DumpDot(FILE* file, const char* prefix, bool last_entry = false) const; + /** + * @brief last_entry is this the last entry for the dot dumping + * @details if not, a "|" is appended to the dump. + */ + void DumpIndicesDot(FILE* file, const char* prefix, bool last_entry = false) const; + protected: - void DumpHelper(std::ostringstream& buffer, const char* prefix) const; + /** + * @brief Dump the bitvector into buffer in a 00101..01 format. + * @param buffer the ostringstream used to dump the bitvector into. + */ + void DumpHelper(const char* prefix, std::ostringstream& buffer) const; + + /** + * @brief Dump the bitvector in a 1 2 5 8 format, where the numbers are the bit set. + * @param buffer the ostringstream used to dump the bitvector into. + */ + void DumpIndicesHelper(const char* prefix, std::ostringstream& buffer) const; + + /** + * @brief Wrapper to perform the bitvector dumping with the .dot format. + * @param buffer the ostringstream used to dump the bitvector into. + */ + void DumpDotHelper(bool last_entry, FILE* file, std::ostringstream& buffer) const; private: static constexpr uint32_t kWordBytes = sizeof(uint32_t); |