// inlining in CoreRT. Skip the ambient conditions checks and profitability checks.
if (!IsTargetAbi(CORINFO_CORERT_ABI) || (info.compFlags & CORINFO_FLG_PINVOKE) == 0)
{
- if (!impCanPInvokeInline())
+ if (opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && opts.ShouldUsePInvokeHelpers())
{
- return;
+ // Raw PInvoke call in PInvoke IL stub generated must be inlined to avoid infinite
+ // recursive calls to the stub.
}
-
- // Size-speed tradeoff: don't use inline pinvoke at rarely
- // executed call sites. The non-inline version is more
- // compact.
- if (block->isRunRarely())
+ else
{
- return;
+ if (!impCanPInvokeInline())
+ {
+ return;
+ }
+
+ // Size-speed tradeoff: don't use inline pinvoke at rarely
+ // executed call sites. The non-inline version is more
+ // compact.
+ if (block->isRunRarely())
+ {
+ return;
+ }
}
}
result |= CorInfoFlag.CORINFO_FLG_SHAREDINST;
if (method.IsPInvoke)
- {
result |= CorInfoFlag.CORINFO_FLG_PINVOKE;
- if (method.IsRawPInvoke())
- {
- result |= CorInfoFlag.CORINFO_FLG_FORCEINLINE;
- }
- }
-
#if READYTORUN
if (method.RequireSecObject)
{
Debug.Assert(method is EcmaMethod);
+ // If the PInvoke is declared on an external module, we can only compile it if
+ // that module is part of the version bubble.
+ if (!_versionBubbleModuleSet.Contains(((EcmaMethod)method).Module))
+ return false;
+
if (((EcmaMethod)method).Module.Equals(method.Context.SystemModule))
return true;