Skip to content

Commit 2116928

Browse files
author
Kim Barrett
committed
8303900: Rename BitMap search functions
Reviewed-by: stefank, aboldtch
1 parent d7f4221 commit 2116928

12 files changed

+75
-75
lines changed

src/hotspot/share/gc/g1/g1CardSetContainers.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -230,7 +230,7 @@ class G1CardSetBitMap : public G1CardSetContainer {
230230

231231
uint next(uint const idx, size_t const size_in_bits) {
232232
BitMapView bm(_bits, size_in_bits);
233-
return static_cast<uint>(bm.get_next_one_offset(idx));
233+
return static_cast<uint>(bm.find_first_set_bit(idx));
234234
}
235235

236236
static size_t header_size_in_bytes();

src/hotspot/share/gc/g1/g1CommittedRegionMap.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -99,13 +99,13 @@ void G1CommittedRegionMap::uncommit(uint start, uint end) {
9999

100100
HeapRegionRange G1CommittedRegionMap::next_active_range(uint offset) const {
101101
// Find first active index from offset.
102-
uint start = (uint) _active.get_next_one_offset(offset);
102+
uint start = (uint) _active.find_first_set_bit(offset);
103103
if (start == max_length()) {
104104
// Early out when no active regions are found.
105105
return HeapRegionRange(max_length(), max_length());
106106
}
107107

108-
uint end = (uint) _active.get_next_zero_offset(start);
108+
uint end = (uint) _active.find_first_clear_bit(start);
109109
verify_active_range(start, end);
110110

111111
return HeapRegionRange(start, end);
@@ -116,28 +116,28 @@ HeapRegionRange G1CommittedRegionMap::next_committable_range(uint offset) const
116116
verify_no_inactive_regons();
117117

118118
// Find first free region from offset.
119-
uint start = (uint) _active.get_next_zero_offset(offset);
119+
uint start = (uint) _active.find_first_clear_bit(offset);
120120
if (start == max_length()) {
121121
// Early out when no free regions are found.
122122
return HeapRegionRange(max_length(), max_length());
123123
}
124124

125-
uint end = (uint) _active.get_next_one_offset(start);
125+
uint end = (uint) _active.find_first_set_bit(start);
126126
verify_free_range(start, end);
127127

128128
return HeapRegionRange(start, end);
129129
}
130130

131131
HeapRegionRange G1CommittedRegionMap::next_inactive_range(uint offset) const {
132132
// Find first inactive region from offset.
133-
uint start = (uint) _inactive.get_next_one_offset(offset);
133+
uint start = (uint) _inactive.find_first_set_bit(offset);
134134

135135
if (start == max_length()) {
136136
// Early when no inactive regions are found.
137137
return HeapRegionRange(max_length(), max_length());
138138
}
139139

140-
uint end = (uint) _inactive.get_next_zero_offset(start);
140+
uint end = (uint) _inactive.find_first_clear_bit(start);
141141
verify_inactive_range(start, end);
142142

143143
return HeapRegionRange(start, end);
@@ -232,7 +232,7 @@ void G1CommittedRegionMap::verify_free_range(uint start, uint end) const {
232232
}
233233

234234
void G1CommittedRegionMap::verify_no_inactive_regons() const {
235-
BitMap::idx_t first_inactive = _inactive.get_next_one_offset(0);
235+
BitMap::idx_t first_inactive = _inactive.find_first_set_bit(0);
236236
assert(first_inactive == _inactive.size(), "Should be no inactive regions, but was at index: " SIZE_FORMAT, first_inactive);
237237
}
238238

src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,15 +39,15 @@ inline bool G1CMBitMap::iterate(G1CMBitMapClosure* cl, MemRegion mr) {
3939
p2i(mr.start()), p2i(mr.end()));
4040

4141
BitMap::idx_t const end_offset = addr_to_offset(mr.end());
42-
BitMap::idx_t offset = _bm.get_next_one_offset(addr_to_offset(mr.start()), end_offset);
42+
BitMap::idx_t offset = _bm.find_first_set_bit(addr_to_offset(mr.start()), end_offset);
4343

4444
while (offset < end_offset) {
4545
HeapWord* const addr = offset_to_addr(offset);
4646
if (!cl->do_addr(addr)) {
4747
return false;
4848
}
4949
size_t const obj_size = cast_to_oop(addr)->size();
50-
offset = _bm.get_next_one_offset(offset + (obj_size >> _shifter), end_offset);
50+
offset = _bm.find_first_set_bit(offset + (obj_size >> _shifter), end_offset);
5151
}
5252
return true;
5353
}

src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ size_t G1PageBasedVirtualSpace::addr_to_page_index(char* addr) const {
106106

107107
bool G1PageBasedVirtualSpace::is_area_committed(size_t start_page, size_t size_in_pages) const {
108108
size_t end_page = start_page + size_in_pages;
109-
return _committed.get_next_zero_offset(start_page, end_page) >= end_page;
109+
return _committed.find_first_clear_bit(start_page, end_page) >= end_page;
110110
}
111111

112112
bool G1PageBasedVirtualSpace::is_area_uncommitted(size_t start_page, size_t size_in_pages) const {
113113
size_t end_page = start_page + size_in_pages;
114-
return _committed.get_next_one_offset(start_page, end_page) >= end_page;
114+
return _committed.find_first_set_bit(start_page, end_page) >= end_page;
115115
}
116116

117117
char* G1PageBasedVirtualSpace::page_start(size_t index) const {
@@ -188,7 +188,7 @@ bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) {
188188

189189
if (_special) {
190190
// Check for dirty pages and update zero_filled if any found.
191-
if (_dirty.get_next_one_offset(start_page, end_page) < end_page) {
191+
if (_dirty.find_first_set_bit(start_page, end_page) < end_page) {
192192
zero_filled = false;
193193
_dirty.par_clear_range(start_page, end_page, BitMap::unknown_range);
194194
}

src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -81,12 +81,12 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
8181

8282
bool is_range_committed(uint start_idx, size_t num_regions) {
8383
BitMap::idx_t end = start_idx + num_regions;
84-
return _region_commit_map.get_next_zero_offset(start_idx, end) == end;
84+
return _region_commit_map.find_first_clear_bit(start_idx, end) == end;
8585
}
8686

8787
bool is_range_uncommitted(uint start_idx, size_t num_regions) {
8888
BitMap::idx_t end = start_idx + num_regions;
89-
return _region_commit_map.get_next_one_offset(start_idx, end) == end;
89+
return _region_commit_map.find_first_set_bit(start_idx, end) == end;
9090
}
9191

9292
virtual void commit_regions(uint start_idx, size_t num_regions, WorkerThreads* pretouch_workers) {
@@ -146,7 +146,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
146146
size_t region = page_idx * _regions_per_page;
147147
size_t region_limit = region + _regions_per_page;
148148
// Committed if there is a bit set in the range.
149-
return _region_commit_map.get_next_one_offset(region, region_limit) != region_limit;
149+
return _region_commit_map.find_first_set_bit(region, region_limit) != region_limit;
150150
}
151151

152152
void numa_request_on_node(size_t page_idx) {
@@ -175,7 +175,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
175175
virtual void commit_regions(uint start_idx, size_t num_regions, WorkerThreads* pretouch_workers) {
176176
uint region_limit = (uint)(start_idx + num_regions);
177177
assert(num_regions > 0, "Must commit at least one region");
178-
assert(_region_commit_map.get_next_one_offset(start_idx, region_limit) == region_limit,
178+
assert(_region_commit_map.find_first_set_bit(start_idx, region_limit) == region_limit,
179179
"Should be no committed regions in the range [%u, %u)", start_idx, region_limit);
180180

181181
size_t const NoPage = ~(size_t)0;
@@ -228,7 +228,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
228228
virtual void uncommit_regions(uint start_idx, size_t num_regions) {
229229
uint region_limit = (uint)(start_idx + num_regions);
230230
assert(num_regions > 0, "Must uncommit at least one region");
231-
assert(_region_commit_map.get_next_zero_offset(start_idx, region_limit) == region_limit,
231+
assert(_region_commit_map.find_first_clear_bit(start_idx, region_limit) == region_limit,
232232
"Should only be committed regions in the range [%u, %u)", start_idx, region_limit);
233233

234234
size_t start_page = region_idx_to_page_idx(start_idx);

src/hotspot/share/gc/parallel/parMarkBitMap.inline.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ inline size_t ParMarkBitMap::obj_size(HeapWord* beg_addr, HeapWord* end_addr) co
118118
}
119119

120120
inline size_t ParMarkBitMap::obj_size(idx_t beg_bit) const {
121-
const idx_t end_bit = _end_bits.get_next_one_offset(beg_bit, size());
121+
const idx_t end_bit = _end_bits.find_first_set_bit(beg_bit, size());
122122
assert(is_marked(beg_bit), "obj not marked");
123123
assert(end_bit < size(), "end bit missing");
124124
return obj_size(beg_bit, end_bit);
@@ -165,11 +165,11 @@ inline ParMarkBitMap::idx_t ParMarkBitMap::align_range_end(idx_t range_end) cons
165165
}
166166

167167
inline ParMarkBitMap::idx_t ParMarkBitMap::find_obj_beg(idx_t beg, idx_t end) const {
168-
return _beg_bits.get_next_one_offset_aligned_right(beg, end);
168+
return _beg_bits.find_first_set_bit_aligned_right(beg, end);
169169
}
170170

171171
inline ParMarkBitMap::idx_t ParMarkBitMap::find_obj_end(idx_t beg, idx_t end) const {
172-
return _end_bits.get_next_one_offset_aligned_right(beg, end);
172+
return _end_bits.find_first_set_bit_aligned_right(beg, end);
173173
}
174174

175175
inline HeapWord* ParMarkBitMap::find_obj_beg(HeapWord* beg, HeapWord* end) const {

src/hotspot/share/gc/shared/markBitMap.inline.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* const addr,
3939
// Round addr up to a possible object boundary to be safe.
4040
size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
4141
size_t const limit_offset = addr_to_offset(limit);
42-
size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset);
42+
size_t const nextOffset = _bm.find_first_set_bit(addr_offset, limit_offset);
4343
return offset_to_addr(nextOffset);
4444
}
4545

src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ void ShenandoahFreeSet::assert_bounds() const {
690690
assert (_mutator_leftmost == _max || is_mutator_free(_mutator_leftmost), "leftmost region should be free: " SIZE_FORMAT, _mutator_leftmost);
691691
assert (_mutator_rightmost == 0 || is_mutator_free(_mutator_rightmost), "rightmost region should be free: " SIZE_FORMAT, _mutator_rightmost);
692692

693-
size_t beg_off = _mutator_free_bitmap.get_next_one_offset(0);
694-
size_t end_off = _mutator_free_bitmap.get_next_one_offset(_mutator_rightmost + 1);
693+
size_t beg_off = _mutator_free_bitmap.find_first_set_bit(0);
694+
size_t end_off = _mutator_free_bitmap.find_first_set_bit(_mutator_rightmost + 1);
695695
assert (beg_off >= _mutator_leftmost, "free regions before the leftmost: " SIZE_FORMAT ", bound " SIZE_FORMAT, beg_off, _mutator_leftmost);
696696
assert (end_off == _max, "free regions past the rightmost: " SIZE_FORMAT ", bound " SIZE_FORMAT, end_off, _mutator_rightmost);
697697

@@ -701,8 +701,8 @@ void ShenandoahFreeSet::assert_bounds() const {
701701
assert (_collector_leftmost == _max || is_collector_free(_collector_leftmost), "leftmost region should be free: " SIZE_FORMAT, _collector_leftmost);
702702
assert (_collector_rightmost == 0 || is_collector_free(_collector_rightmost), "rightmost region should be free: " SIZE_FORMAT, _collector_rightmost);
703703

704-
beg_off = _collector_free_bitmap.get_next_one_offset(0);
705-
end_off = _collector_free_bitmap.get_next_one_offset(_collector_rightmost + 1);
704+
beg_off = _collector_free_bitmap.find_first_set_bit(0);
705+
end_off = _collector_free_bitmap.find_first_set_bit(_collector_rightmost + 1);
706706
assert (beg_off >= _collector_leftmost, "free regions before the leftmost: " SIZE_FORMAT ", bound " SIZE_FORMAT, beg_off, _collector_leftmost);
707707
assert (end_off == _max, "free regions past the rightmost: " SIZE_FORMAT ", bound " SIZE_FORMAT, end_off, _collector_rightmost);
708708
}

src/hotspot/share/gc/z/zLiveMap.inline.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -81,11 +81,11 @@ inline bool ZLiveMap::claim_segment(BitMap::idx_t segment) {
8181
}
8282

8383
inline BitMap::idx_t ZLiveMap::first_live_segment() const {
84-
return segment_live_bits().get_next_one_offset(0, nsegments);
84+
return segment_live_bits().find_first_set_bit(0, nsegments);
8585
}
8686

8787
inline BitMap::idx_t ZLiveMap::next_live_segment(BitMap::idx_t segment) const {
88-
return segment_live_bits().get_next_one_offset(segment + 1, nsegments);
88+
return segment_live_bits().find_first_set_bit(segment + 1, nsegments);
8989
}
9090

9191
inline BitMap::idx_t ZLiveMap::segment_size() const {
@@ -138,7 +138,7 @@ inline void ZLiveMap::iterate_segment(ObjectClosure* cl, BitMap::idx_t segment,
138138

139139
const BitMap::idx_t start_index = segment_start(segment);
140140
const BitMap::idx_t end_index = segment_end(segment);
141-
BitMap::idx_t index = _bitmap.get_next_one_offset(start_index, end_index);
141+
BitMap::idx_t index = _bitmap.find_first_set_bit(start_index, end_index);
142142

143143
while (index < end_index) {
144144
// Calculate object address
@@ -159,7 +159,7 @@ inline void ZLiveMap::iterate_segment(ObjectClosure* cl, BitMap::idx_t segment,
159159
break;
160160
}
161161

162-
index = _bitmap.get_next_one_offset(next_index, end_index);
162+
index = _bitmap.find_first_set_bit(next_index, end_index);
163163
}
164164
}
165165

src/hotspot/share/utilities/bitMap.hpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ class BitMap {
9494
return raw_to_words_align_down(bit);
9595
}
9696

97-
// Helper for get_next_{zero,one}_bit variants.
97+
// Helper for find_first_{set,clear}_bit variants.
9898
// - flip designates whether searching for 1s or 0s. Must be one of
9999
// find_{zeros,ones}_flip.
100100
// - aligned_right is true if end is a priori on a bm_word_t boundary.
101101
template<bm_word_t flip, bool aligned_right>
102-
inline idx_t get_next_bit_impl(idx_t beg, idx_t end) const;
102+
inline idx_t find_first_bit_impl(idx_t beg, idx_t end) const;
103103

104-
// Values for get_next_bit_impl flip parameter.
104+
// Values for find_first_bit_impl flip parameter.
105105
static const bm_word_t find_ones_flip = 0;
106106
static const bm_word_t find_zeros_flip = ~(bm_word_t)0;
107107

@@ -290,19 +290,19 @@ class BitMap {
290290
// Looking for 1's and 0's at indices equal to or greater than "beg",
291291
// stopping if none has been found before "end", and returning
292292
// "end" (which must be at most "size") in that case.
293-
idx_t get_next_one_offset (idx_t beg, idx_t end) const;
294-
idx_t get_next_zero_offset(idx_t beg, idx_t end) const;
293+
idx_t find_first_set_bit(idx_t beg, idx_t end) const;
294+
idx_t find_first_clear_bit(idx_t beg, idx_t end) const;
295295

296-
idx_t get_next_one_offset(idx_t beg) const {
297-
return get_next_one_offset(beg, size());
296+
idx_t find_first_set_bit(idx_t beg) const {
297+
return find_first_set_bit(beg, size());
298298
}
299-
idx_t get_next_zero_offset(idx_t beg) const {
300-
return get_next_zero_offset(beg, size());
299+
idx_t find_first_clear_bit(idx_t beg) const {
300+
return find_first_clear_bit(beg, size());
301301
}
302302

303-
// Like "get_next_one_offset", except requires that "end" is
303+
// Like "find_first_set_bit", except requires that "end" is
304304
// aligned to bitsizeof(bm_word_t).
305-
idx_t get_next_one_offset_aligned_right(idx_t beg, idx_t end) const;
305+
idx_t find_first_set_bit_aligned_right(idx_t beg, idx_t end) const;
306306

307307
// Returns the number of bits set in the bitmap.
308308
idx_t count_one_bits() const;

src/hotspot/share/utilities/bitMap.inline.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ inline void BitMap::par_clear_range(idx_t beg, idx_t end, RangeSizeHint hint) {
166166
}
167167

168168
template<BitMap::bm_word_t flip, bool aligned_right>
169-
inline BitMap::idx_t BitMap::get_next_bit_impl(idx_t beg, idx_t end) const {
169+
inline BitMap::idx_t BitMap::find_first_bit_impl(idx_t beg, idx_t end) const {
170170
STATIC_ASSERT(flip == find_ones_flip || flip == find_zeros_flip);
171171
verify_range(beg, end);
172172
assert(!aligned_right || is_aligned(end, BitsPerWord), "end not aligned");
@@ -229,18 +229,18 @@ inline BitMap::idx_t BitMap::get_next_bit_impl(idx_t beg, idx_t end) const {
229229
}
230230

231231
inline BitMap::idx_t
232-
BitMap::get_next_one_offset(idx_t beg, idx_t end) const {
233-
return get_next_bit_impl<find_ones_flip, false>(beg, end);
232+
BitMap::find_first_set_bit(idx_t beg, idx_t end) const {
233+
return find_first_bit_impl<find_ones_flip, false>(beg, end);
234234
}
235235

236236
inline BitMap::idx_t
237-
BitMap::get_next_zero_offset(idx_t beg, idx_t end) const {
238-
return get_next_bit_impl<find_zeros_flip, false>(beg, end);
237+
BitMap::find_first_clear_bit(idx_t beg, idx_t end) const {
238+
return find_first_bit_impl<find_zeros_flip, false>(beg, end);
239239
}
240240

241241
inline BitMap::idx_t
242-
BitMap::get_next_one_offset_aligned_right(idx_t beg, idx_t end) const {
243-
return get_next_bit_impl<find_ones_flip, true>(beg, end);
242+
BitMap::find_first_set_bit_aligned_right(idx_t beg, idx_t end) const {
243+
return find_first_bit_impl<find_ones_flip, true>(beg, end);
244244
}
245245

246246
// IterateInvoker supports conditionally stopping iteration early. The
@@ -271,7 +271,7 @@ template <typename Function>
271271
inline bool BitMap::iterate(Function function, idx_t beg, idx_t end) const {
272272
auto invoke = IterateInvoker<decltype(function(beg))>();
273273
for (idx_t index = beg; true; ++index) {
274-
index = get_next_one_offset(index, end);
274+
index = find_first_set_bit(index, end);
275275
if (index >= end) {
276276
return true;
277277
} else if (!invoke(function, index)) {

0 commit comments

Comments
 (0)