RFR: 8342102: ZGC: Optimize copy constructors in ZPhysicalMemory

Kim Barrett kbarrett at openjdk.org
Wed Oct 16 07:39:13 UTC 2024


On Wed, 16 Oct 2024 05:23:02 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> src/hotspot/share/gc/z/zPhysicalMemory.cpp line 58:
>> 
>>> 56: 
>>> 57: const ZPhysicalMemory& ZPhysicalMemory::operator=(const ZPhysicalMemory& pmem) {
>>> 58:   // Free and copy segments
>> 
>> pre-existing: Seems like this ought to be checking for self-assign.  I'd be okay with asserting against, even
>> though that's often frowned on in various writings on the subject.
>
> Checking and returning `*this` seems fine to me. Seems like the least surprising solution. 
> 
> The copy assignment operator is currently only ever used in a gtest.

Agreed that checking, and returning `*this` is the preferable way to handle it.  I offered the assert option in
case there was some concern about doing that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21523#discussion_r1802522498


More information about the hotspot-gc-dev mailing list