RFR 8242263: Diagnose synchronization on primitive wrappers

Patricio Chilano patricio.chilano.mateo at oracle.com
Tue Jul 28 19:16:14 UTC 2020

Hi all,

Please review the following change that adds diagnostic capabilities 
when synchronizing on primitive wrapper classes.

Bug: https://bugs.openjdk.java.net/browse/JDK-8242263
Webrev: http://cr.openjdk.java.net/~pchilanomate/8242263/v1/webrev/

The new flag allows to identify synchronization on these classes and to 
take one of the following actions: exit the VM with fatal error, log a 
warning message, or issue a JFR event. The implementation uses a simple 
approach where a check is added at the beginning of the monitorenter 
generated code when the flag is enabled to check whether the object is 
of a primitive wrapper class. If it is, we jump to the slow path, 
otherwise we just continue as always. The extra instructions will be: 
load the klass of the object, load the _access_flags field for that 
klass, AND with a constant, and branch based on the result. The code 
will only be generated whenever the new opt-in diagnostic flag is 
enabled so performance won't be affected when off.

In addition to the purpose described in the description of the bug, this 
flag will also be useful when trying to diagnose possible 
synchronization issues if these classes ever become inline types as part 
of the Valhalla project.

I added test SyncOnPrimitiveWrapperTest.java that tests for the exit and 
logging cases. I added test TestSyncOnPrimitiveWrapperEvent.java to test 
for the JFR event case.
I tested the patch running tiers1-6 in mach5 with the flag set to 
I checked it builds with arm32 and ppc but can't run any tests on those 
platforms, so it would be good if somebody can run the new test included 
in the patch.

Let me know if you think I should run or add any more tests.



More information about the hotspot-runtime-dev mailing list