RFR: 8370031: Make RegMask copy constructor explicit and replace RegMask operator= with named function [v2]
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Tue Oct 21 08:36:38 UTC 2025
On Mon, 20 Oct 2025 11:59:58 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.
>
> Daniel Lundén has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
>
> - Merge remote-tracking branch 'upstream/master' into regmask-explicit-8370031
> - Fix issue
Looks good, thanks.
-------------
Marked as reviewed by rcastanedalo (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/27891#pullrequestreview-3359414515
More information about the hotspot-compiler-dev
mailing list