From bc9248cad132fa01dd2b641b6b22849bc7a05457 Mon Sep 17 00:00:00 2001 From: Fadi Hanna Date: Mon, 1 Apr 2019 12:07:47 -0700 Subject: 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 --- src/tools/r2rdump/R2RConstants.cs | 6 ++++++ src/tools/r2rdump/R2RSignature.cs | 13 +++++++++++++ 2 files changed, 19 insertions(+) (limited to 'src/tools') diff --git a/src/tools/r2rdump/R2RConstants.cs b/src/tools/r2rdump/R2RConstants.cs index 7e1c5e388f..7f2b2e3035 100644 --- a/src/tools/r2rdump/R2RConstants.cs +++ b/src/tools/r2rdump/R2RConstants.cs @@ -120,6 +120,8 @@ namespace R2RDump READYTORUN_FIXUP_DelegateCtor = 0x2C, /* optimized delegate ctor */ READYTORUN_FIXUP_DeclaringTypeHandle = 0x2D, + + READYTORUN_FIXUP_IndirectPInvokeTarget = 0x2E, /* Target of an inlined pinvoke */ } // @@ -171,6 +173,10 @@ namespace R2RDump READYTORUN_HELPER_MemSet = 0x40, READYTORUN_HELPER_MemCpy = 0x41, + // PInvoke helpers + READYTORUN_HELPER_PInvokeBegin = 0x42, + READYTORUN_HELPER_PInvokeEnd = 0x43, + // Get string handle lazily READYTORUN_HELPER_GetString = 0x50, diff --git a/src/tools/r2rdump/R2RSignature.cs b/src/tools/r2rdump/R2RSignature.cs index 60e4c0fd0a..9bf44122b0 100644 --- a/src/tools/r2rdump/R2RSignature.cs +++ b/src/tools/r2rdump/R2RSignature.cs @@ -679,6 +679,10 @@ namespace R2RDump builder.Append(" (DECLARING_TYPE_HANDLE)"); break; + case ReadyToRunFixupKind.READYTORUN_FIXUP_IndirectPInvokeTarget: + ParseMethod(builder); + builder.Append(" (INDIRECT_PINVOKE_TARGET)"); + break; default: builder.Append(string.Format("Unknown fixup type: {0:X2}", fixupType)); @@ -1126,6 +1130,15 @@ namespace R2RDump builder.Append("MEM_CPY"); break; + // PInvoke helpers + case ReadyToRunHelper.READYTORUN_HELPER_PInvokeBegin: + builder.Append("PINVOKE_BEGIN"); + break; + + case ReadyToRunHelper.READYTORUN_HELPER_PInvokeEnd: + builder.Append("PINVOKE_END"); + break; + // Get string handle lazily case ReadyToRunHelper.READYTORUN_HELPER_GetString: builder.Append("GET_STRING"); -- cgit v1.2.3