summaryrefslogtreecommitdiff
path: root/src/vm/jithelpers.cpp
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/vm/jithelpers.cpp
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/vm/jithelpers.cpp')
-rw-r--r--src/vm/jithelpers.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp
index 0576ca7336..d30b4d3300 100644
--- a/src/vm/jithelpers.cpp
+++ b/src/vm/jithelpers.cpp
@@ -5591,15 +5591,50 @@ HCIMPL0(VOID, JIT_PollGC)
}
HCIMPLEND
+
+/*************************************************************/
+// This helper is similar to JIT_RareDisableHelper, but has more operations
+// tailored to the post-pinvoke operations.
+extern "C" FCDECL0(VOID, JIT_PInvokeEndRarePath);
+
+HCIMPL0(void, JIT_PInvokeEndRarePath)
+{
+ BEGIN_PRESERVE_LAST_ERROR;
+
+ FCALL_CONTRACT;
+
+ Thread *thread = GetThread();
+
+ // We need to disable the implicit FORBID GC region that exists inside an FCALL
+ // in order to call RareDisablePreemptiveGC().
+ FC_CAN_TRIGGER_GC();
+ thread->RareDisablePreemptiveGC();
+ FC_CAN_TRIGGER_GC_END();
+
+ FC_GC_POLL_NOT_NEEDED();
+
+ HELPER_METHOD_FRAME_BEGIN_NOPOLL(); // Set up a frame
+ thread->HandleThreadAbort();
+ HELPER_METHOD_FRAME_END();
+
+ InlinedCallFrame* frame = (InlinedCallFrame*)thread->m_pFrame;
+
+ thread->m_pFrame->Pop(thread);
+
+ END_PRESERVE_LAST_ERROR;
+}
+HCIMPLEND
+
/*************************************************************/
// For an inlined N/Direct call (and possibly for other places that need this service)
// we have noticed that the returning thread should trap for one reason or another.
// ECall sets up the frame.
+extern "C" FCDECL0(VOID, JIT_RareDisableHelper);
+
#if defined(_TARGET_ARM_) || defined(_TARGET_AMD64_)
// The JIT expects this helper to preserve the return value on AMD64 and ARM. We should eventually
// switch other platforms to the same convention since it produces smaller code.
-extern "C" FCDECL0(VOID, JIT_RareDisableHelper);
extern "C" FCDECL0(VOID, JIT_RareDisableHelperWorker);
HCIMPL0(void, JIT_RareDisableHelperWorker)
@@ -5783,6 +5818,9 @@ Thread * __stdcall JIT_InitPInvokeFrame(InlinedCallFrame *pFrame, PTR_VOID StubS
#endif // _WIN64
+EXTERN_C void JIT_PInvokeBegin(InlinedCallFrame* pFrame);
+EXTERN_C void JIT_PInvokeEnd(InlinedCallFrame* pFrame);
+
//========================================================================
//
// JIT HELPERS IMPLEMENTED AS FCALLS