[9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Jun 17 16:38:04 UTC 2015


http://cr.openjdk.java.net/~vlivanov/8078629/webrev.00/
https://bugs.openjdk.java.net/browse/JDK-8078629

Direct(getfield/getstatic) read operations are faster than unsafe reads 
from constant Java fields, since VM doesn't constant fold unsafe loads. 
Though VM tries hard to recover field metadata from its offset, it 
doesn't optimize unsafe ones even if it has all necessary info in its hands.

The fix is to align the behavior and share relevant code between C2 
parser and intrinsic expansion logic.

For testing purposes, I extended whitebox API to check whether a value 
is a compile-time constant. The whitebox test enumerates all 
combinations of a field and ensures that the behavior is consistent 
between bytecode and unsafe reads.

Testing: focused whitebox tests, hotspot/test/compiler, 
jdk/test/java/lang/invoke, octane (for performance measurements)

Thanks!

Best regards,
Vladimir Ivanov


More information about the hotspot-compiler-dev mailing list