[8] RFR (XS): 8031695: CHA ignores default methods during analysis leading to incorrect code generation

John Rose john.r.rose at oracle.com
Wed Jan 22 10:09:29 PST 2014


Good fix; reviewed.  — John

On Jan 22, 2014, at 9:29 AM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:

> http://cr.openjdk.java.net/~vlivanov/8031695/webrev.00/
> https://bugs.openjdk.java.net/browse/JDK-8031695
> 
> CHA erroneously ignores default methods when looking for different versions of a method in a class hierarchy.
> 
> Consider the following hierarchy:
>  interface I { default void m() { ... }}
>  class A implements I {}
> 
>  class C extends A { }
>  class D extends A { public void m() { ... } }
> 
> Call site: invokevirtual A.m()
> 
> A.m resolves to I.m. Searching from A, CHA finds only D.m and concludes that D.m is the only implementation of I.m, since Dependencies::is_concrete_method returns false for I.m.
> 
> But there is C with default implementation from I. So, if VM inlines D.m and then C's instance is passed as objectref, the wrong method is invoked (D.m instead of I.m).
> 
> The fix is to take default methods into account doing CHA analysis and treat the call site as non-monomorphic when a concrete method is found for a default method.
> 
> Conservative approach is chosen, since the fix is targeted for 8.
> 
> Testing: failing application, regression test, vm.defmeth.testlist, JDK regression tests (java/util/, java/lang)
> 
> Thanks!
> 
> Best regards,
> Vladimir Ivanov



More information about the hotspot-dev mailing list