RFR: 8263446: Avoid unary minus over unsigned type in ObjectSynchronizer::dec_in_use_list_ceiling

Erik Österlund eosterlund at openjdk.java.net
Sun Mar 14 20:24:06 UTC 2021


On Fri, 12 Mar 2021 15:52:18 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> SonarCloud complains:
>>   Unary minus should not be applied to an unsigned expression
>> 
>> Here:
>> 
>> void ObjectSynchronizer::dec_in_use_list_ceiling() {
>>   Atomic::add(&_in_use_list_ceiling, -AvgMonitorsPerThreadEstimate);
>> }
>> 
>> We can instead use `Atomic::sub`.
>> 
>> Additional testing:
>>  - [x] Linux x86_64 fastdebug `hotspot:tier1`
>
> Marked as reviewed by eosterlund (Reviewer).

> Since @fisk no longer objects to making that change,
> 
> I withdraw my objection also.
> 
> 
> 
> Historical note: @dholmes-ora had previously requested that I make
> 
> exactly this change in a different code review and I rejected that request
> 
> for the same reason that I objected to this PR.
> 
> 
> 
> My apologies to @dholmes-ora.

For the record, my previous objection was when the bindings for number fiddling was incorrect on PPC. The API claimed conservative memory ordering semantics across the board, but inc/dec were really relaxed on PPC, and add/sub were acquire/release on PPC. So back then we had to do nasty things in the shared code to get the right semantics on PPC. That has been fixed since a while back and is no longer relevant.

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

PR: https://git.openjdk.java.net/jdk/pull/2939


More information about the hotspot-runtime-dev mailing list