RFR: 8263446: Avoid unary minus over unsigned type in ObjectSynchronizer::dec_in_use_list_ceiling
Aleksey Shipilev
shade at openjdk.java.net
Thu Mar 11 15:43:06 UTC 2021
On Thu, 11 Mar 2021 15:32:59 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
> I also think that SonarCloud is wrong about this.
>
> @fisk had good reasons to prefer Atomic::add() of a negative value over
> using Atomic::sub() back when we were working on this ObjectMonitor code.
> Hopefully, he can chime in on this thread.
Sure. The way I see it, `Atomic::sub(loc, v)` ends up doing `Atomic::add(..., -v)` anyway, but with additional checks, and suppressing the compiler warnings there. I think it is a good choice to use clearly mark this operation as subtraction. Otherwise we would want to document how exactly `Atomic::sub` is insufficient compared to `Atomic::add`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2939
More information about the hotspot-runtime-dev
mailing list