RFR: 8257069: C2: Clarify and sanity test RegMask/RegMaskIterator

Claes Redestad redestad at openjdk.java.net
Wed Nov 25 15:28:05 UTC 2020


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.

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

Commit messages:
 - Back-peddle a bit..
 - Assert we don't trigger UB by shifting too much
 - More clarity. More test.
 - Merge branch 'master' into regmask_clarity
 - More tests, clean-ups
 - 8257069: C2: Clarify and sanity test RegMask/RegMaskIterator

Changes: https://git.openjdk.java.net/jdk/pull/1437/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1437&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8257069
  Stats: 197 lines in 3 files changed: 181 ins; 0 del; 16 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1437.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1437/head:pull/1437

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


More information about the hotspot-compiler-dev mailing list