8287661: Fix and improve BitMap::print_on(outputStream*)
Reviewed-by: stefank
This commit is contained in:
parent
b544b8b7d4
commit
625821dae7
@ -691,11 +691,18 @@ void BitMap::write_to(bm_word_t* buffer, size_t buffer_size_in_bytes) const {
|
||||
#ifndef PRODUCT
|
||||
|
||||
void BitMap::print_on(outputStream* st) const {
|
||||
tty->print("Bitmap(" SIZE_FORMAT "):", size());
|
||||
st->print("Bitmap (" SIZE_FORMAT " bits):", size());
|
||||
for (idx_t index = 0; index < size(); index++) {
|
||||
tty->print("%c", at(index) ? '1' : '0');
|
||||
if ((index % 64) == 0) {
|
||||
st->cr();
|
||||
st->print(SIZE_FORMAT_W(5) ":", index);
|
||||
}
|
||||
if ((index % 8) == 0) {
|
||||
st->print(" ");
|
||||
}
|
||||
st->print("%c", at(index) ? 'S' : '.');
|
||||
}
|
||||
tty->cr();
|
||||
st->cr();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "utilities/bitMap.inline.hpp"
|
||||
#include "unittest.hpp"
|
||||
@ -95,6 +96,21 @@ class BitMapTest {
|
||||
EXPECT_TRUE(map.is_same(map2)) << "With init_size " << init_size;
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
static void testPrintOn(BitMap::idx_t size) {
|
||||
ResourceMark rm;
|
||||
|
||||
ResourceBitMap map(size);
|
||||
if (size > 0) {
|
||||
map.set_bit(size / 2);
|
||||
}
|
||||
|
||||
LogStreamHandle(Info, test) stream;
|
||||
map.print_on(&stream);
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
TEST_VM(BitMap, resize_grow) {
|
||||
@ -148,3 +164,13 @@ TEST_VM(BitMap, reinitialize) {
|
||||
BitMapTest::testReinitialize(BitMapTest::BITMAP_SIZE >> 3);
|
||||
BitMapTest::testReinitialize(BitMapTest::BITMAP_SIZE);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
TEST_VM(BitMap, print_on) {
|
||||
BitMapTest::testPrintOn(0);
|
||||
BitMapTest::testPrintOn(BitMapTest::BITMAP_SIZE >> 3);
|
||||
BitMapTest::testPrintOn(BitMapTest::BITMAP_SIZE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user