@@ -7668,6 +7668,37 @@ static void getMethodInfoHelper(
7668
7668
&methInfo->locals );
7669
7669
} // getMethodInfoHelper
7670
7670
7671
+
7672
+ void CEEInfo::getTransientMethodInfo (MethodDesc* pMD, CORINFO_METHOD_INFO* methInfo)
7673
+ {
7674
+ MethodInfoHelperContext cxt{ pMD };
7675
+
7676
+ // We will either find or create transient method details.
7677
+ _ASSERTE (!cxt.HasTransientMethodDetails ());
7678
+
7679
+ // IL methods with no RVA indicate there is no implementation defined in metadata.
7680
+ // Check if we previously generated details/implementation for this method.
7681
+ TransientMethodDetails* detailsMaybe = NULL ;
7682
+ if (FindTransientMethodDetails (pMD, &detailsMaybe))
7683
+ cxt.UpdateWith (*detailsMaybe);
7684
+
7685
+ getMethodInfoHelper (cxt, methInfo);
7686
+
7687
+ // If we have transient method details we need to handle
7688
+ // the lifetime of the details.
7689
+ if (cxt.HasTransientMethodDetails ())
7690
+ {
7691
+ // If we didn't find transient details, but we have them
7692
+ // after getting method info, store them for cleanup.
7693
+ if (detailsMaybe == NULL )
7694
+ AddTransientMethodDetails (cxt.CreateTransientMethodDetails ());
7695
+
7696
+ // Reset the context because ownership has either been
7697
+ // transferred or was found in this instance.
7698
+ cxt.UpdateWith ({});
7699
+ }
7700
+ }
7701
+
7671
7702
// ---------------------------------------------------------------------------------------
7672
7703
//
7673
7704
bool
@@ -7704,31 +7735,7 @@ CEEInfo::getMethodInfo(
7704
7735
}
7705
7736
else if (ftn->IsIL () && ftn->GetRVA () == 0 )
7706
7737
{
7707
- // We will either find or create transient method details.
7708
- _ASSERTE (!cxt.HasTransientMethodDetails ());
7709
-
7710
- // IL methods with no RVA indicate there is no implementation defined in metadata.
7711
- // Check if we previously generated details/implementation for this method.
7712
- TransientMethodDetails* detailsMaybe = NULL ;
7713
- if (FindTransientMethodDetails (ftn, &detailsMaybe))
7714
- cxt.UpdateWith (*detailsMaybe);
7715
-
7716
- getMethodInfoHelper (cxt, methInfo);
7717
-
7718
- // If we have transient method details we need to handle
7719
- // the lifetime of the details.
7720
- if (cxt.HasTransientMethodDetails ())
7721
- {
7722
- // If we didn't find transient details, but we have them
7723
- // after getting method info, store them for cleanup.
7724
- if (detailsMaybe == NULL )
7725
- AddTransientMethodDetails (cxt.CreateTransientMethodDetails ());
7726
-
7727
- // Reset the context because ownership has either been
7728
- // transferred or was found in this instance.
7729
- cxt.UpdateWith ({});
7730
- }
7731
-
7738
+ getTransientMethodInfo (ftn, methInfo);
7732
7739
result = true ;
7733
7740
}
7734
7741
@@ -7890,6 +7897,40 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
7890
7897
}
7891
7898
}
7892
7899
7900
+ // If the root level caller and callee modules do not have the same runtime
7901
+ // wrapped exception behavior, and the callee has EH, we cannot inline.
7902
+ _ASSERTE (!pCallee->IsDynamicMethod ());
7903
+ {
7904
+ Module* pCalleeModule = pCallee->GetModule ();
7905
+ Module* pRootModule = pOrigCaller->GetModule ();
7906
+
7907
+ if (pRootModule->IsRuntimeWrapExceptions () != pCalleeModule->IsRuntimeWrapExceptions ())
7908
+ {
7909
+ if (pCallee->HasILHeader ())
7910
+ {
7911
+ COR_ILMETHOD_DECODER header (pCallee->GetILHeader (), pCallee->GetMDImport (), NULL );
7912
+ if (header.EHCount () > 0 )
7913
+ {
7914
+ result = INLINE_FAIL;
7915
+ szFailReason = " Inlinee and root method have different wrapped exception behavior" ;
7916
+ goto exit;
7917
+ }
7918
+ }
7919
+ else if (pCallee->IsIL () && pCallee->GetRVA () == 0 )
7920
+ {
7921
+ CORINFO_METHOD_INFO methodInfo;
7922
+ getTransientMethodInfo (pCallee, &methodInfo);
7923
+
7924
+ if (methodInfo.EHcount > 0 )
7925
+ {
7926
+ result = INLINE_FAIL;
7927
+ szFailReason = " Inlinee and root method have different wrapped exception behavior" ;
7928
+ goto exit;
7929
+ }
7930
+ }
7931
+ }
7932
+ }
7933
+
7893
7934
#ifdef PROFILING_SUPPORTED
7894
7935
if (pOrigCallerModule->IsInliningDisabledByProfiler ())
7895
7936
{
0 commit comments