From 3211c255a54b2956b345ba85e7be371548264e7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 24 Jan 2018 01:10:52 +0100 Subject: [PATCH] Do not devirtualize shared default interface methods (#15979) The result of the devirtualization for a method on a generic type should be an instantiating stub, but this doesn't seem to work right. Fixing that is a perf issue (that can be triaged/punted - #15977). This commit is a correctness fix to avoid bad codegen for that case. Resolves #15591. --- src/vm/jitinterface.cpp | 8 ++++++++ tests/issues.targets | 3 --- tests/testsFailingOutsideWindows.txt | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 874beae..d08ba0c 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -8870,6 +8870,14 @@ CORINFO_METHOD_HANDLE CEEInfo::resolveVirtualMethodHelper(CORINFO_METHOD_HANDLE { return nullptr; } + + // If we devirtualized into a default interface method on a generic type, we should actually return an + // instantiating stub but this is not happening. + // Making this work is tracked by https://github.com/dotnet/coreclr/issues/15977 + if (pDevirtMD->GetMethodTable()->IsInterface() && pDevirtMD->HasClassInstantiation()) + { + return nullptr; + } } else { diff --git a/tests/issues.targets b/tests/issues.targets index 6736700..1ebf4cd 100644 --- a/tests/issues.targets +++ b/tests/issues.targets @@ -169,9 +169,6 @@ 15591 - - 15591 - 15353 diff --git a/tests/testsFailingOutsideWindows.txt b/tests/testsFailingOutsideWindows.txt index 47acd42..4a10b2f 100644 --- a/tests/testsFailingOutsideWindows.txt +++ b/tests/testsFailingOutsideWindows.txt @@ -72,7 +72,6 @@ GC/Features/LOHFragmentation/lohfragmentation/lohfragmentation.sh GC/Features/SustainedLowLatency/scenario/scenario.sh GC/Regressions/dev10bugs/536168/536168/536168.sh Loader/classloader/DefaultInterfaceMethods/diamondshape/diamondshape/diamondshape.sh -Loader/classloader/DefaultInterfaceMethods/sharedgenerics/sharedgenerics/sharedgenerics.sh Loader/classloader/DefaultInterfaceMethods/constrainedcall/constrainedcall/constrainedcall.sh Loader/classloader/TypeGeneratorTests/TypeGeneratorTest612/Generated612/Generated612.sh Loader/classloader/TypeGeneratorTests/TypeGeneratorTest613/Generated613/Generated613.sh -- 2.7.4