Integrated: 8370031: Make RegMask copy constructor explicit and replace RegMask operator= with named function
Daniel Lundén
dlunden at openjdk.org
Tue Oct 21 13:20:16 UTC 2025
On Mon, 20 Oct 2025 07:42:01 GMT, Daniel Lundén <dlunden at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: 2af4d20a
Author: Daniel Lundén <dlunden at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2af4d20abfda4113a2bfcf34dfad87187c0f584d
Stats: 257 lines in 14 files changed: 34 ins; 35 del; 188 mod
8370031: Make RegMask copy constructor explicit and replace RegMask operator= with named function
Reviewed-by: mhaessig, rcastanedalo
-------------
PR: https://git.openjdk.org/jdk/pull/27891
More information about the hotspot-compiler-dev
mailing list