@@ -8714,12 +8714,16 @@ void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd,
8714
8714
}
8715
8715
8716
8716
/* ********************************************************************/
8717
- static CORINFO_METHOD_HANDLE resolveVirtualMethodHelper (MethodDesc* callerMethod,
8718
- CORINFO_METHOD_HANDLE baseMethod,
8719
- CORINFO_CLASS_HANDLE derivedClass,
8720
- CORINFO_CONTEXT_HANDLE ownerType)
8717
+ CORINFO_METHOD_HANDLE CEEInfo::resolveVirtualMethodHelper (CORINFO_METHOD_HANDLE baseMethod,
8718
+ CORINFO_CLASS_HANDLE derivedClass,
8719
+ CORINFO_CONTEXT_HANDLE ownerType)
8721
8720
{
8722
- STANDARD_VM_CONTRACT;
8721
+ CONTRACTL {
8722
+ SO_TOLERANT;
8723
+ THROWS;
8724
+ GC_TRIGGERS;
8725
+ MODE_PREEMPTIVE;
8726
+ } CONTRACTL_END;
8723
8727
8724
8728
MethodDesc* pBaseMD = GetMethod (baseMethod);
8725
8729
MethodTable* pBaseMT = pBaseMD->GetMethodTable ();
@@ -8747,6 +8751,15 @@ static CORINFO_METHOD_HANDLE resolveVirtualMethodHelper(MethodDesc* callerMethod
8747
8751
8748
8752
if (pBaseMT->IsInterface ())
8749
8753
{
8754
+
8755
+ #ifdef FEATURE_COMINTEROP
8756
+ // Don't try and devirtualize com interface calls.
8757
+ if (pDerivedMT->IsComObjectType ())
8758
+ {
8759
+ return nullptr ;
8760
+ }
8761
+ #endif // FEATURE_COMINTEROP
8762
+
8750
8763
// Interface call devirtualization.
8751
8764
//
8752
8765
// We must ensure that pDerivedMT actually implements the
@@ -8760,7 +8773,17 @@ static CORINFO_METHOD_HANDLE resolveVirtualMethodHelper(MethodDesc* callerMethod
8760
8773
// safely devirtualize.
8761
8774
if (ownerType != nullptr )
8762
8775
{
8763
- pDevirtMD = pDerivedMT->GetMethodDescForInterfaceMethod (GetTypeFromContext (ownerType), pBaseMD);
8776
+ TypeHandle OwnerClsHnd = GetTypeFromContext (ownerType);
8777
+ MethodTable* pOwnerMT = OwnerClsHnd.GetMethodTable ();
8778
+
8779
+ // If the derived class is a shared class, make sure the
8780
+ // owner class is too.
8781
+ if (pDerivedMT->IsSharedByGenericInstantiations ())
8782
+ {
8783
+ pOwnerMT = pOwnerMT->GetCanonicalMethodTable ();
8784
+ }
8785
+
8786
+ pDevirtMD = pDerivedMT->GetMethodDescForInterfaceMethod (TypeHandle (pOwnerMT), pBaseMD);
8764
8787
}
8765
8788
else if (!pBaseMD->HasClassOrMethodInstantiation ())
8766
8789
{
@@ -8810,6 +8833,7 @@ static CORINFO_METHOD_HANDLE resolveVirtualMethodHelper(MethodDesc* callerMethod
8810
8833
// bubble information and if so, disallow it.
8811
8834
if (IsReadyToRunCompilation ())
8812
8835
{
8836
+ MethodDesc* callerMethod = m_pMethodBeingCompiled;
8813
8837
Assembly* pCallerAssembly = callerMethod->GetModule ()->GetAssembly ();
8814
8838
bool allowDevirt =
8815
8839
IsInSameVersionBubble (pCallerAssembly , pDevirtMD->GetModule ()->GetAssembly ())
@@ -8829,13 +8853,18 @@ CORINFO_METHOD_HANDLE CEEInfo::resolveVirtualMethod(CORINFO_METHOD_HANDLE method
8829
8853
CORINFO_CLASS_HANDLE derivedClass,
8830
8854
CORINFO_CONTEXT_HANDLE ownerType)
8831
8855
{
8832
- STANDARD_VM_CONTRACT;
8856
+ CONTRACTL {
8857
+ SO_TOLERANT;
8858
+ THROWS;
8859
+ GC_TRIGGERS;
8860
+ MODE_PREEMPTIVE;
8861
+ } CONTRACTL_END;
8833
8862
8834
8863
CORINFO_METHOD_HANDLE result = nullptr ;
8835
8864
8836
8865
JIT_TO_EE_TRANSITION ();
8837
8866
8838
- result = resolveVirtualMethodHelper (m_pMethodBeingCompiled, methodHnd, derivedClass, ownerType);
8867
+ result = resolveVirtualMethodHelper (methodHnd, derivedClass, ownerType);
8839
8868
8840
8869
EE_TO_JIT_TRANSITION ();
8841
8870
0 commit comments