RFR: 8248149: G1: change _cleaning_claimed from int to bool

Kim Barrett kbarrett at openjdk.org
Thu Jun 15 18:32:31 UTC 2023


On Thu, 15 Jun 2023 11:01:18 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> src/hotspot/share/gc/g1/g1ParallelCleaning.cpp line 43:
>> 
>>> 41:   }
>>> 42: 
>>> 43:   return !Atomic::cmpxchg(&_cleaning_claimed, false, true);
>> 
>> It might be an int because making it a bool may involve a byte-sized cmpxchg, which has a not very
>> nice implementation on some platforms.  Though even with that the claim cost is likely dwarfed by
>> other costs here.
>
> I prefer to believe that when this has been implemented, there has been no cmpxchg overload for bools before the atomics refactoring. We did not go back and look for these kind of mismatches.
> 
> There should be no visible performance difference, so I prefer using the more appropriate type.

Yeah, that's probably correct.  We used to have a cmpxchg overload for jbyte, but never explicitly bool.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14487#discussion_r1231399226


More information about the hotspot-gc-dev mailing list