[10] RFR: 8182487: Add Unsafe.objectFieldOffset(Class, String)

Claes Redestad claes.redestad at oracle.com
Tue Jun 20 13:14:26 UTC 2017


as a startup optimization, we can avoid a number of reflective 
operations on
variouscore classes by adding a specialized objectFieldOffset method taking
Class and String rather than Field:

Webrev: https://bugs.openjdk.java.net/browse/JDK-8182487
Hotspot: http://cr.openjdk.java.net/~redestad/8182487/hotspot.00
JDK: http://cr.openjdk.java.net/~redestad/8182487/jdk.00

On startup tests this reduces executed instructions by ~1-2M, depending on
how many of the touched classes are loaded.

Since all uses of this would throw an Error, InternalError or
ExceptionInInitializerError if the field was missing - effectively
aborting VM execution - it felt reasonable to simplify the code to
consistently throw InternalError and remove a number of distracting
try-catch blocks.



More information about the hotspot-runtime-dev mailing list