summaryrefslogtreecommitdiff
path: root/src/zap
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2019-04-01 12:07:47 -0700
committerGitHub <noreply@github.com>2019-04-01 12:07:47 -0700
commitbc9248cad132fa01dd2b641b6b22849bc7a05457 (patch)
tree5d1ee71059353a66004fc7a4d2501a7452db849f /src/zap
parentff43a803a814eaaa5eba02cafa4a91def3e4c7be (diff)
downloadcoreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.tar.gz
coreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.tar.bz2
coreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.zip
Enable R2R compilation/inlining of PInvoke stubs where no marshalling is required (#22560)
* These changes enable the inlining of some PInvokes that do not require any marshalling. With inlined pinvokes, R2R performance should become slightly better, since we'll avoid jitting some of the pinvoke IL stubs that we jit today for S.P.CoreLib. Performance gains not yet measured. * Added JIT_PInvokeBegin/End helpers for all architectures. Linux stubs not yet implemented * Add INLINE_GETTHREAD for arm/arm64 * Set CORJIT_FLAG_USE_PINVOKE_HELPERS jit flag for ReadyToRun compilations * Updating R2RDump tool to handle pinvokes
Diffstat (limited to 'src/zap')
-rw-r--r--src/zap/zapinfo.cpp25
-rw-r--r--src/zap/zapreadytorun.cpp2
2 files changed, 20 insertions, 7 deletions
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp
index 560400bd44..1e498463c6 100644
--- a/src/zap/zapinfo.cpp
+++ b/src/zap/zapinfo.cpp
@@ -205,8 +205,14 @@ CORJIT_FLAGS ZapInfo::ComputeJitFlags(CORINFO_METHOD_HANDLE handle)
#ifdef FEATURE_READYTORUN_COMPILER
if (IsReadyToRunCompilation())
+ {
jitFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_READYTORUN);
+#ifndef PLATFORM_UNIX
+ // PInvoke Helpers are not yet implemented on non-Windows platforms
+ jitFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_USE_PINVOKE_HELPERS);
#endif
+ }
+#endif // FEATURE_READYTORUN_COMPILER
return jitFlags;
}
@@ -1988,12 +1994,15 @@ void * ZapInfo::getAddressOfPInvokeFixup(CORINFO_METHOD_HANDLE method,void **ppI
m_pImage->m_pPreloader->AddMethodToTransitiveClosureOfInstantiations(method);
- CORINFO_MODULE_HANDLE moduleHandle = m_pEECompileInfo->GetLoaderModuleForEmbeddableMethod(method);
- if (moduleHandle == m_pImage->m_hModule
- && m_pImage->m_pPreloader->CanEmbedMethodHandle(method, m_currentMethodHandle))
+ if (!IsReadyToRunCompilation())
{
- *ppIndirection = NULL;
- return PVOID(m_pImage->GetWrappers()->GetAddrOfPInvokeFixup(method));
+ CORINFO_MODULE_HANDLE moduleHandle = m_pEECompileInfo->GetLoaderModuleForEmbeddableMethod(method);
+ if (moduleHandle == m_pImage->m_hModule
+ && m_pImage->m_pPreloader->CanEmbedMethodHandle(method, m_currentMethodHandle))
+ {
+ *ppIndirection = NULL;
+ return PVOID(m_pImage->GetWrappers()->GetAddrOfPInvokeFixup(method));
+ }
}
//
@@ -3849,9 +3858,11 @@ CorInfoUnmanagedCallConv ZapInfo::getUnmanagedCallConv(CORINFO_METHOD_HANDLE met
BOOL ZapInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method,
CORINFO_SIG_INFO* sig)
{
- // READYTORUN: FUTURE: P/Invoke
+#ifdef PLATFORM_UNIX
+ // TODO: Support for pinvoke helpers on non-Windows platforms
if (IsReadyToRunCompilation())
- return TRUE;
+ return TRUE;
+#endif
return m_pEEJitInfo->pInvokeMarshalingRequired(method, sig);
}
diff --git a/src/zap/zapreadytorun.cpp b/src/zap/zapreadytorun.cpp
index f0260a59aa..8d83ff7400 100644
--- a/src/zap/zapreadytorun.cpp
+++ b/src/zap/zapreadytorun.cpp
@@ -549,6 +549,8 @@ static_assert_no_msg((int)READYTORUN_FIXUP_DelegateCtor == (int)ENC
static_assert_no_msg((int)READYTORUN_FIXUP_DeclaringTypeHandle == (int)ENCODE_DECLARINGTYPE_HANDLE);
+static_assert_no_msg((int)READYTORUN_FIXUP_IndirectPInvokeTarget == (int)ENCODE_INDIRECT_PINVOKE_TARGET);
+
//
// READYTORUN_EXCEPTION
//