RFR: 8327093: Add slice function to BitMap API [v2]

Ioi Lam iklam at openjdk.org
Wed Mar 6 03:32:46 UTC 2024


On Tue, 5 Mar 2024 18:35:58 GMT, Matias Saavedra Silva <matsaave at openjdk.org> wrote:

>> The BitMap does not currently have a "slice" method which can return a subset of the bitmap defined by a start and end bit. This utility can be used to analyze portions of a bitmap or to overwrite the existing map with a shorter, modified map. 
>> 
>> This implementation has two core methods: 
>> `copy_of_range` allocates and returns a new word array as used internally by BitMap
>> `truncate` overwrites the internal array with the one generated by `copy_of_range` so none of the internal workings are exposed to callers outside of BitMap.
>> 
>> This change is verified with an included test.
>
> Matias Saavedra Silva has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Axel comments

Changes requested by iklam (Reviewer).

src/hotspot/share/utilities/bitMap.cpp line 118:

> 116: 
> 117:   // All words need to be shifted by this amount
> 118:   idx_t shift = bit_in_word(start_bit);

`shift` should be const as well.

test/hotspot/gtest/utilities/test_bitMap_truncate.cpp line 83:

> 81:     fillBitMap(map, BITMAP_SIZE);
> 82:     testTruncate<ResizableBitMapClass>(0, BITMAP_SIZE, map);
> 83:   }

`testTruncateOneWord()` is pretty easy to understand, but I found it really hard to follow the logic of the other test cases. For example, it took me a while to understand the variable `map` in `testTruncateSame()` is not the same as the `map` in `testTruncate()`.

Could all the tests be rewritten to the same style of `testTruncateOneWord()`, where the entire logic is inside the same function?

-------------

PR Review: https://git.openjdk.org/jdk/pull/18092#pullrequestreview-1918661249
PR Review Comment: https://git.openjdk.org/jdk/pull/18092#discussion_r1513767301
PR Review Comment: https://git.openjdk.org/jdk/pull/18092#discussion_r1513760844


More information about the hotspot-dev mailing list