Fix crossgen with large version bubble enabled
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 24 Apr 2019 23:07:42 +0000 (01:07 +0200)
committerJan Vorlicek <janvorli@microsoft.com>
Wed, 24 Apr 2019 23:07:42 +0000 (01:07 +0200)
This change fixes about 1483 failing Pri-1 tests when they are
crossgen-ed with large version bubble enabled. Only one failing test
remains.

60% of the test cases were failing due to a failure to find generic
interface in an interface map due to the fact that the interface type
was being passed in canonical form.
The remaining 40% were tests using constrained calls. We were missing
the ENCODE_METHOD_SIG_Constrained in the method flags.

src/vm/zapsig.cpp

index 73cc604..d9a5afc 100644 (file)
@@ -1132,8 +1132,10 @@ BOOL ZapSig::EncodeMethod(
 
     // For methods encoded outside of the version bubble, we use pResolvedToken which describes the metadata token from which the method originated
     // For tokens inside the version bubble we are not constrained by the contents of pResolvedToken and as such we skip this codepath
+    // Generic interfaces in canonical form are an exception, we need to get the real type from the pResolvedToken so that the lookup at runtime
+    // can find the type in interface map.
     // FUTURE: This condition should likely be changed or reevaluated once support for smaller version bubbles is implemented.
-    if (IsReadyToRunCompilation() && (!IsLargeVersionBubbleEnabled() || !pMethod->GetModule()->IsInCurrentVersionBubble()))
+    if (IsReadyToRunCompilation() && (!IsLargeVersionBubbleEnabled() || !pMethod->GetModule()->IsInCurrentVersionBubble() || (pMethod->IsSharedByGenericInstantiations() && pMethod->IsInterface())))
     {
         if (pMethod->IsNDirect())
         {
@@ -1199,15 +1201,14 @@ BOOL ZapSig::EncodeMethod(
     }
 
 #ifdef FEATURE_READYTORUN_COMPILER
+    if (IsReadyToRunCompilation() && (pConstrainedResolvedToken != NULL))
+    {
+        methodFlags |= ENCODE_METHOD_SIG_Constrained;
+    }
 
     // FUTURE: This condition should likely be changed or reevaluated once support for smaller version bubbles is implemented.
     if (IsReadyToRunCompilation() && (!IsLargeVersionBubbleEnabled() || !pMethod->GetModule()->IsInCurrentVersionBubble()))
     {
-        if (pConstrainedResolvedToken != NULL)
-        {
-            methodFlags |= ENCODE_METHOD_SIG_Constrained;
-        }
-
         Module * pReferencingModule = pMethod->IsNDirect() ?
             pMethod->GetModule() :
             (Module *)pResolvedToken->tokenScope;