简体   繁体   中英

Where can I find information about the inner workings of Sun's JVM?

As a developer, I want to know what the cost is of invoking a virtual method vs. interface method. Now, I know why invokeinterface can be slower than invokevirtual , but I wonder if Sun has adopted new mechanisms in the last versions of the JVMs they released that improved invokeinterface . How can I find such information?

Oracle, which acquired Sun, has the old Sun white papers about the HotSpot JVM available on their website here at this site:

http://java.sun.com/products/hotspot/docs/whitepaper/Java_HotSpot_WP_Final_4_30_01.html

As for your initial question about invokevirtual versus invokeinterface , Sun has done a lot of very aggressive performance optimizations to try to improve this. One of the many techniques they use is called polymorphic inline caching and can dramatically simplify the runtime overhead of interface dispatches down to a level at or better than regular invokevirtual dispatches. The idea is to keep track of a small table near each invocation site tracking what types are often used at the call site. Whenever an interface method is invoked, the object that the method is invoked on can then have its type compared against the known types, and if it matches the call can be made quickly by looking up in a small cache which method ought to be invoked.

Additionally, I believe that HotSpot uses dynamic analysis to try to prove that at certain program points, the type of an object referred to by an interface pointer is exactly of some particular type. If so, then the call can be inlined entirely or can be resolved without needing any further dynamic lookup.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM