RFR: 8370031: Make RegMask copy constructor explicit and replace RegMask operator= with named function

Daniel Lundén dlunden at openjdk.org
Mon Oct 20 07:48:16 UTC 2025


The `RegMask` copy constructor is currently non-explicit. We should make it explicit so that we do not unintentionally copy register masks.

Additionally, we currently overload `operator=` in `RegMask` to do a deep copy. It is preferable to use an explicit named function instead, according to the HotSpot coding style.

### Changeset

- Make the `RegMask` copy constructor explicit.
- Fix compilation errors as a result of the now explicit constructor. Specifically, the methods `Matcher::divI_proj_mask`, `Matcher::modI_proj_mask`, `Matcher::divL_proj_mask`, and `Matcher::modL_proj_mask` all use implicit copy construction (likely unintended). Change the methods to return `const RegMask&` instead of `RegMask` and correspondingly change the return value from `RegMask()` to `RegMask::Empty` on some platforms.
- Rename the old method `RegMask::copy` to `RegMask::assignFrom` to better describe its functionality, and make it public instead of private.
- Delete `RegMask` copy assignment (`operator=`) and change all uses to the named function `assignFrom` instead.
- Fix various syntax issues at lines touched by the changeset.

### Testing

- [GitHub Actions](https://github.com/dlunde/jdk/actions/runs/18589208499)
- `tier1` to `tier4` (and additional Oracle-internal testing) on Windows x64, Linux x64, Linux aarch64, macOS x64, and macOS aarch64.

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

Commit messages:
 - Fix issue

Changes: https://git.openjdk.org/jdk/pull/27891/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27891&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8370031
  Stats: 257 lines in 14 files changed: 34 ins; 35 del; 188 mod
  Patch: https://git.openjdk.org/jdk/pull/27891.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27891/head:pull/27891

PR: https://git.openjdk.org/jdk/pull/27891


More information about the hotspot-compiler-dev mailing list