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

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Jan 22 12:34:41 PST 2014


John, Karen, thanks for review!

Special thanks goes to Lois for initial analysis and instructions how to 
reproduce the issue. It saved me lots of time.

Best regards,
Vladimir Ivanov

On 1/22/14 11:16 PM, Karen Kinnear wrote:
> Looks good.
>
> many thanks,
> Karen
>
> On Jan 22, 2014, at 12:29 PM, Vladimir Ivanov 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