开发者

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜