Skip to content

Commit 13cd1ce

Browse files
committed
8222986: Add parameter to skip clearing CHeapBitMaps when resizing
Reviewed-by: pliden
1 parent 087c03a commit 13cd1ce

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/hotspot/share/utilities/bitMap.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,42 +111,42 @@ void BitMap::free(const Allocator& allocator, bm_word_t* map, idx_t size_in_bit
111111
}
112112

113113
template <class Allocator>
114-
void BitMap::resize(const Allocator& allocator, idx_t new_size_in_bits) {
115-
bm_word_t* new_map = reallocate(allocator, map(), size(), new_size_in_bits);
114+
void BitMap::resize(const Allocator& allocator, idx_t new_size_in_bits, bool clear) {
115+
bm_word_t* new_map = reallocate(allocator, map(), size(), new_size_in_bits, clear);
116116

117117
update(new_map, new_size_in_bits);
118118
}
119119

120120
template <class Allocator>
121-
void BitMap::initialize(const Allocator& allocator, idx_t size_in_bits) {
121+
void BitMap::initialize(const Allocator& allocator, idx_t size_in_bits, bool clear) {
122122
assert(map() == NULL, "precondition");
123123
assert(size() == 0, "precondition");
124124

125-
resize(allocator, size_in_bits);
125+
resize(allocator, size_in_bits, clear);
126126
}
127127

128128
template <class Allocator>
129-
void BitMap::reinitialize(const Allocator& allocator, idx_t new_size_in_bits) {
130-
// Remove previous bits.
131-
resize(allocator, 0);
129+
void BitMap::reinitialize(const Allocator& allocator, idx_t new_size_in_bits, bool clear) {
130+
// Remove previous bits - no need to clear
131+
resize(allocator, 0, false /* clear */);
132132

133-
initialize(allocator, new_size_in_bits);
133+
initialize(allocator, new_size_in_bits, clear);
134134
}
135135

136136
ResourceBitMap::ResourceBitMap(idx_t size_in_bits)
137137
: BitMap(allocate(ResourceBitMapAllocator(), size_in_bits), size_in_bits) {
138138
}
139139

140140
void ResourceBitMap::resize(idx_t new_size_in_bits) {
141-
BitMap::resize(ResourceBitMapAllocator(), new_size_in_bits);
141+
BitMap::resize(ResourceBitMapAllocator(), new_size_in_bits, true /* clear */);
142142
}
143143

144144
void ResourceBitMap::initialize(idx_t size_in_bits) {
145-
BitMap::initialize(ResourceBitMapAllocator(), size_in_bits);
145+
BitMap::initialize(ResourceBitMapAllocator(), size_in_bits, true /* clear */);
146146
}
147147

148148
void ResourceBitMap::reinitialize(idx_t size_in_bits) {
149-
BitMap::reinitialize(ResourceBitMapAllocator(), size_in_bits);
149+
BitMap::reinitialize(ResourceBitMapAllocator(), size_in_bits, true /* clear */);
150150
}
151151

152152
ArenaBitMap::ArenaBitMap(Arena* arena, idx_t size_in_bits)
@@ -161,16 +161,16 @@ CHeapBitMap::~CHeapBitMap() {
161161
free(CHeapBitMapAllocator(_flags), map(), size());
162162
}
163163

164-
void CHeapBitMap::resize(idx_t new_size_in_bits) {
165-
BitMap::resize(CHeapBitMapAllocator(_flags), new_size_in_bits);
164+
void CHeapBitMap::resize(idx_t new_size_in_bits, bool clear) {
165+
BitMap::resize(CHeapBitMapAllocator(_flags), new_size_in_bits, clear);
166166
}
167167

168-
void CHeapBitMap::initialize(idx_t size_in_bits) {
169-
BitMap::initialize(CHeapBitMapAllocator(_flags), size_in_bits);
168+
void CHeapBitMap::initialize(idx_t size_in_bits, bool clear) {
169+
BitMap::initialize(CHeapBitMapAllocator(_flags), size_in_bits, clear);
170170
}
171171

172-
void CHeapBitMap::reinitialize(idx_t size_in_bits) {
173-
BitMap::reinitialize(CHeapBitMapAllocator(_flags), size_in_bits);
172+
void CHeapBitMap::reinitialize(idx_t size_in_bits, bool clear) {
173+
BitMap::reinitialize(CHeapBitMapAllocator(_flags), size_in_bits, clear);
174174
}
175175

176176
#ifdef ASSERT

src/hotspot/share/utilities/bitMap.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ class BitMap {
157157
// Old bits are transfered to the new memory
158158
// and the extended memory is cleared.
159159
template <class Allocator>
160-
void resize(const Allocator& allocator, idx_t new_size_in_bits);
160+
void resize(const Allocator& allocator, idx_t new_size_in_bits, bool clear);
161161

162162
// Set up and clear the bitmap memory.
163163
//
164164
// Precondition: The bitmap was default constructed and has
165165
// not yet had memory allocated via resize or (re)initialize.
166166
template <class Allocator>
167-
void initialize(const Allocator& allocator, idx_t size_in_bits);
167+
void initialize(const Allocator& allocator, idx_t size_in_bits, bool clear);
168168

169169
// Set up and clear the bitmap memory.
170170
//
171171
// Can be called on previously initialized bitmaps.
172172
template <class Allocator>
173-
void reinitialize(const Allocator& allocator, idx_t new_size_in_bits);
173+
void reinitialize(const Allocator& allocator, idx_t new_size_in_bits, bool clear);
174174

175175
// Set the map and size.
176176
void update(bm_word_t* map, idx_t size) {
@@ -384,18 +384,18 @@ class CHeapBitMap : public BitMap {
384384
//
385385
// Old bits are transfered to the new memory
386386
// and the extended memory is cleared.
387-
void resize(idx_t new_size_in_bits);
387+
void resize(idx_t new_size_in_bits, bool clear = true);
388388

389389
// Set up and clear the bitmap memory.
390390
//
391391
// Precondition: The bitmap was default constructed and has
392392
// not yet had memory allocated via resize or initialize.
393-
void initialize(idx_t size_in_bits);
393+
void initialize(idx_t size_in_bits, bool clear = true);
394394

395395
// Set up and clear the bitmap memory.
396396
//
397397
// Can be called on previously initialized bitmaps.
398-
void reinitialize(idx_t size_in_bits);
398+
void reinitialize(idx_t size_in_bits, bool clear = true);
399399
};
400400

401401
// Convenience class wrapping BitMap which provides multiple bits per slot.

0 commit comments

Comments
 (0)