On Sep 8, 2010, at 12:08 AM, Charles Oliver Nutter wrote:

> Why is Hotspot able to cope with the
> cast+invokevirtual when it can't cope with invokeinterface always
> resolving to the same method?

Here's a possible answer, which could lead to JVM tweaks or bug fixes:  Class 
hierarchy analysis allows devirtualization of the call, but only if the 
receiver is a real class.  The JVM keeps some records about implementors of 
interfaces, but I don't think the compiler connects all the dots properly.

Note that if the call site is monomorphic then class hierarchy analysis doesn't 
apply at all, and calls are trivially devirtualized, since the receiver is an 
"exact" type (not quantified over a set of subtypes). This happens whether the 
receiver is a class or interface.  But our current type profiles don't scale 
well beyond one or two exact types.

So a test case for this theory would have to make a call site which witnesses 
multiple receiver types but where all the types resolve to a common method (and 
that method has a single definition within the set of the receiver's subtypes). 
 And the set of subtypes would have to be bounded by an interface, not a class. 

-- John

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to