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

Coleen Phillimore coleenp at openjdk.java.net
Tue Jun 22 14:56:32 UTC 2021


On Tue, 22 Jun 2021 04:09:48 GMT, Thomas Stuefe <stuefe 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.hpp line 244:
> 
>> 242:     int cnts = contentions(); // read once
>> 243:     if (cnts > 0) {
>> 244:       ret_code |= intptr_t(cnts);
> 
> I know it has nothing to do with your patch, but I am just curious. IIUC this is a strange way of saying "if A!=0 || B!=0 || C!=0..." . Is this for performance reasons? Also, why the "if (cnts > 0)", would that not be superfluous?

I think this code exists like this from when is_busy returned an uintptr_t.  It should be nicely rewritten with if != 0s now and likely would have better performance.  I won't do it with this change because these fields are volatile and I think should have Atomic::loads, which would lead to a lot of discussion that should happen independently.  I'll file an RFE.

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

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


More information about the serviceability-dev mailing list