Interface call devirtualization: jit side of changes
authorAndy Ayers <andya@microsoft.com>
Thu, 16 Mar 2017 15:30:58 +0000 (08:30 -0700)
committerAndy Ayers <andya@microsoft.com>
Thu, 16 Mar 2017 20:51:37 +0000 (13:51 -0700)
Unblock VM queries where the base class is an interface (queries
where the implementing class is also an interface are still blocked
as no resolution is possible). Pass along the context handle that
the jit got from getCallInfo.

Commit migrated from https://github.com/dotnet/coreclr/commit/2c8b3ae4c1786968f387af9c78a343e0a561869b

src/coreclr/src/jit/importer.cpp

index e285fed..9d1daac 100644 (file)
@@ -18488,16 +18488,15 @@ void Compiler::impDevirtualizeCall(GenTreeCall*            call,
         return;
     }
 
-    // Bail (for now) if base class is an interface.
     if (isInterface)
     {
         assert(call->IsVirtualStub());
-        JITDUMP("--- base class is interface, sorry\n");
-        return;
+        JITDUMP("--- base class is interface\n");
     }
 
     // Fetch the method that would be called based on the declared type of 'this'
-    CORINFO_METHOD_HANDLE derivedMethod = info.compCompHnd->resolveVirtualMethod(baseMethod, objClass);
+    CORINFO_CONTEXT_HANDLE ownerType     = callInfo->contextHandle;
+    CORINFO_METHOD_HANDLE  derivedMethod = info.compCompHnd->resolveVirtualMethod(baseMethod, objClass, ownerType);
 
     // If we failed to get a handle, we can't devirtualize.  This can
     // happen when prejitting, if the devirtualization crosses