RFR: 8256306: ObjectMonitor::_contentions field should not be 'jint'

Daniel D.Daugherty dcubed at openjdk.java.net
Tue Jun 22 15:50:34 UTC 2021


On Mon, 21 Jun 2021 23:56:36 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> I changed the _contentions and _waiters fields from jint to int and ran tests tier1-3.  Tested tier1 with linux, mac, windows platforms. Also changed the _previous_owner_tid to unintptr_t from jlong, since that's what the cast did.
>
> src/hotspot/share/runtime/objectMonitor.cpp line 575:
> 
>> 573:     // Make a zero contentions field negative to force any contending threads
>> 574:     // to retry. This is the second part of the async deflation dance.
>> 575:     if (Atomic::cmpxchg(&_contentions, (int)0, INT32_MIN) != 0) {
> 
> INT_MIN
> 
> Do we really need the cast on 0?

The original cast of `(jint)0` was to get the right `cmpxchg()` selected.
I _think_ that with the switch to INT32_MIN, a regular `0` instead of `(int)0`
should compile.

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

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


More information about the serviceability-dev mailing list