RFR: 8257069: C2: Clarify and sanity test RegMask/RegMaskIterator [v2]

Vladimir Kozlov kvn at openjdk.java.net
Wed Nov 25 21:20:58 UTC 2020


On Wed, 25 Nov 2020 20:42:11 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> This patch adds a sanity test to RegMask. It's not (yet) exhaustive, but it covers most common operations and iteration.
>> 
>> While implementing this test I noticed that the code have a strong, implied assumption that RM_SIZE is even on 64-bit platforms, and a few things could have broken badly if RM_SIZE was odd (mismatch between set_AllStack/is_AllStack, extra bits after CHUNK_SIZE). That RM_SIZE is even is thankfully an invariant, since the AD preprocessor aligns up RM_SIZE. Add a static assert to this effect, and prefer _RM_SIZE for clarity.
>> 
>> The iteration algorithm in RegMaskIterator, which I borrowed from IndexSetIterator, has garnered a few raised eyebrows. I think the quirky scheme of not shifting out the bit of interest but instead clear is mainly explained by the need to avoid undefined behavior in the corner case when only the highest bit is set. I've added some commentary to try and clarify the quirks.
>
> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Simplify and use type declared constants, minor cleanups

Good.

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

Marked as reviewed by kvn (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1437


More information about the hotspot-compiler-dev mailing list