RFR: 8213415: BitMap::word_index_round_up overflow problems
Kim Barrett
kim.barrett at oracle.com
Tue Jun 11 01:28:44 UTC 2019
> On Jun 10, 2019, at 9:14 PM, Kim Barrett <kim.barrett at oracle.com> wrote:
>> void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
>> assert(beg_index <= end_index, "BitMap range error");
>> // Note that [0,0) and [size,size) are both valid ranges.
>> - if (end_index != _size) verify_index(end_index);
>> + assert(end_index <= _size, "BitMap range out of bounds");
>> }
>>
>> This allowance to have beg_index outside of the bit range seems dubious to me. It's not something you changed, but I preferred that the old code was explicit that there was an odd special case involved.
>
> I made this change because I found the old code confusing; I had to
> think about it to decide it really would assert iff the range was
> invalid. Also, the old error is confusing since the end of a range is
> not an index. (Further checking is required for use as an index.) The
> change makes the implementation directly correspond to the definition
> of a valid range, e.g. 0 <= begin <= end <= size. (With the negative
> case impossible because of an unsigned type.)
But maybe I should have also removed the not actually helpful comment.
More information about the hotspot-dev
mailing list