Skip to content

Commit cca7283

Browse files
author
Thomas Schatzl
committed
some perf attempts
1 parent ec17a21 commit cca7283

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,24 @@ void BitMap::set_range_within_word(idx_t beg, idx_t end) {
372372
void BitMap::set_range(idx_t beg, idx_t end) {
373373
verify_range(beg, end);
374374

375-
idx_t beg_full_word = to_words_align_up(beg);
376-
idx_t end_full_word = to_words_align_down(end);
377-
378-
if (beg_full_word < end_full_word) {
379-
// The range includes at least one full word.
380-
set_range_within_word(beg, bit_index(beg_full_word));
381-
set_range_of_words(beg_full_word, end_full_word);
382-
set_range_within_word(bit_index(end_full_word), end);
375+
if (((beg^end) >> LogBitsPerWord) == 0) { // begin and end in same word?
376+
bm_word_t mask = (((bm_word_t)1 << (end - beg)) - 1) << (beg & (BitsPerWord - 1));
377+
*word_addr(beg) |= mask;
383378
} else {
384-
// The range spans at most 2 partial words.
385-
idx_t boundary = MIN2(bit_index(beg_full_word), end);
386-
set_range_within_word(beg, boundary);
387-
set_range_within_word(boundary, end);
379+
idx_t beg_full_word = to_words_align_up(beg);
380+
idx_t end_full_word = to_words_align_down(end);
381+
382+
if (beg_full_word < end_full_word) {
383+
// The range includes at least one full word.
384+
set_range_within_word(beg, bit_index(beg_full_word));
385+
set_range_of_words(beg_full_word, end_full_word);
386+
set_range_within_word(bit_index(end_full_word), end);
387+
} else {
388+
// The range spans at most 2 partial words.
389+
idx_t boundary = MIN2(bit_index(beg_full_word), end);
390+
set_range_within_word(beg, boundary);
391+
set_range_within_word(boundary, end);
392+
}
388393
}
389394
}
390395

0 commit comments

Comments
 (0)