diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index aabc86d3cd65a4..bd578460b3920d 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -3063,7 +3063,8 @@ class ICorDynamicInfo : public ICorStaticInfo // return the native entry point to an EE helper (see CorInfoHelpFunc) virtual void* getHelperFtn ( CorInfoHelpFunc ftnNum, - void **ppIndirection = NULL + void **ppIndirection = NULL, + CORINFO_METHOD_HANDLE* pMethod = NULL ) = 0; // return a callable address of the function (native code). This function diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 08b1004d4642d3..570d6580777e5a 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -537,7 +537,8 @@ int32_t* getAddrOfCaptureThreadGlobal( void* getHelperFtn( CorInfoHelpFunc ftnNum, - void** ppIndirection) override; + void** ppIndirection, + CORINFO_METHOD_HANDLE* pMethod) override; void getFunctionEntryPoint( CORINFO_METHOD_HANDLE ftn, diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 82fbaf1c0d108b..4402789109f51e 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* 64146448-11b1-4f94-b1f2-edce91fbcb33 */ - 0x64146448, - 0x11b1, - 0x4f94, - {0xb1, 0xf2, 0xed, 0xce, 0x91, 0xfb, 0xcb, 0x33} +constexpr GUID JITEEVersionIdentifier = { /* 9bd31e12-c91e-4574-bfed-c1a03b68c2e0 */ + 0x9bd31e12, + 0xc91e, + 0x4574, + {0xbf, 0xed, 0xc1, 0xa0, 0x3b, 0x68, 0xc2, 0xe0} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index 9c7e6c1099826d..0a949ff65dc112 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -1272,10 +1272,11 @@ int32_t* WrapICorJitInfo::getAddrOfCaptureThreadGlobal( void* WrapICorJitInfo::getHelperFtn( CorInfoHelpFunc ftnNum, - void** ppIndirection) + void** ppIndirection, + CORINFO_METHOD_HANDLE* pMethod) { API_ENTER(getHelperFtn); - void* temp = wrapHnd->getHelperFtn(ftnNum, ppIndirection); + void* temp = wrapHnd->getHelperFtn(ftnNum, ppIndirection, pMethod); API_LEAVE(getHelperFtn); return temp; } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 865cda25ffab17..126f0bdf1cfc1f 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -3531,25 +3531,29 @@ private void getFpStructLowering(CORINFO_CLASS_STRUCT_* structHnd, ref CORINFO_F private uint getThreadTLSIndex(ref void* ppIndirection) { throw new NotImplementedException("getThreadTLSIndex"); } - private Dictionary _helperCache = new Dictionary(); - private void* getHelperFtn(CorInfoHelpFunc ftnNum, ref void* ppIndirection) + private readonly Dictionary _helperCache = new(); + private void* getHelperFtn(CorInfoHelpFunc ftnNum, ref void* ppIndirection, CORINFO_METHOD_STRUCT_** pMethod) { - ISymbolNode entryPoint; - if (!_helperCache.TryGetValue(ftnNum, out entryPoint)) + if (!_helperCache.TryGetValue(ftnNum, out (ISymbolNode Symbol, MethodDesc Method) entryPointMethodDesc)) { - entryPoint = GetHelperFtnUncached(ftnNum); - _helperCache.Add(ftnNum, entryPoint); + ISymbolNode node = GetHelperFtnUncached(ftnNum, out MethodDesc methodDesc); + entryPointMethodDesc = (node, methodDesc); + _helperCache.Add(ftnNum, entryPointMethodDesc); } - if (entryPoint.RepresentsIndirectionCell) + + if (pMethod != null && entryPointMethodDesc.Method != null) { - ppIndirection = (void*)ObjectToHandle(entryPoint); - return null; + *pMethod = ObjectToHandle(entryPointMethodDesc.Method); } - else + + if (entryPointMethodDesc.Symbol.RepresentsIndirectionCell) { - ppIndirection = null; - return (void*)ObjectToHandle(entryPoint); + ppIndirection = (void*)ObjectToHandle(entryPointMethodDesc.Symbol); + return null; } + + ppIndirection = null; + return (void*)ObjectToHandle(entryPointMethodDesc.Symbol); } public static ReadyToRunHelperId GetReadyToRunHelperFromStaticBaseHelper(CorInfoHelpFunc helper) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 91df884c58272c..a67b47d1a5947c 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -1918,12 +1918,12 @@ private static uint _getThreadTLSIndex(IntPtr thisHandle, IntPtr* ppException, v } [UnmanagedCallersOnly] - private static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection) + private static void* _getHelperFtn(IntPtr thisHandle, IntPtr* ppException, CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_STRUCT_** pMethod) { var _this = GetThis(thisHandle); try { - return _this.getHelperFtn(ftnNum, ref *ppIndirection); + return _this.getHelperFtn(ftnNum, ref *ppIndirection, pMethod); } catch (Exception ex) { @@ -2754,7 +2754,7 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[126] = (delegate* unmanaged)&_getFpStructLowering; callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex; callbacks[128] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[129] = (delegate* unmanaged)&_getHelperFtn; + callbacks[129] = (delegate* unmanaged)&_getHelperFtn; callbacks[130] = (delegate* unmanaged)&_getFunctionEntryPoint; callbacks[131] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; callbacks[132] = (delegate* unmanaged)&_getMethodSync; diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 3aaa80673334f4..44c71361f8e39f 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -293,7 +293,7 @@ FUNCTIONS void getFpStructLowering(CORINFO_CLASS_HANDLE structHnd, CORINFO_FPSTRUCT_LOWERING* pLowering); uint32_t getThreadTLSIndex(void **ppIndirection); int32_t * getAddrOfCaptureThreadGlobal(void **ppIndirection); - void* getHelperFtn (CorInfoHelpFunc ftnNum, void **ppIndirection); + void* getHelperFtn (CorInfoHelpFunc ftnNum, void **ppIndirection, CORINFO_METHOD_HANDLE* pMethod); void getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftn, CORINFO_CONST_LOOKUP * pResult, CORINFO_ACCESS_FLAGS accessFlags); void getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE ftn, bool isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP * pResult); void* getMethodSync(CORINFO_METHOD_HANDLE ftn, void **ppIndirection); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 500863a90d9347..70f85a401136b1 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -963,8 +963,9 @@ private void getReadyToRunDelegateCtorHelper(ref CORINFO_RESOLVED_TOKEN pTargetM pLookup.constLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.DelegateCtor(delegateTypeDesc, targetMethod)); } - private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) + private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum, out MethodDesc methodDesc) { + methodDesc = null; ReadyToRunHelper id; switch (ftnNum) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index 34c5a1a3b16cc0..30fc50aba67d2d 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -455,8 +455,9 @@ private void getReadyToRunDelegateCtorHelper(ref CORINFO_RESOLVED_TOKEN pTargetM } } - private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) + private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum, out MethodDesc methodDesc) { + methodDesc = null; ReadyToRunHelper id; switch (ftnNum) @@ -786,7 +787,6 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) } string mangledName; - MethodDesc methodDesc; JitHelper.GetEntryPoint(_compilation.TypeSystemContext, id, out mangledName, out methodDesc); Debug.Assert(mangledName != null || methodDesc != null); diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index a1a6122037d27a..77c38b3a3798f0 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -140,7 +140,7 @@ struct JitInterfaceCallbacks void (* getFpStructLowering)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE structHnd, CORINFO_FPSTRUCT_LOWERING* pLowering); uint32_t (* getThreadTLSIndex)(void * thisHandle, CorInfoExceptionClass** ppException, void** ppIndirection); int32_t* (* getAddrOfCaptureThreadGlobal)(void * thisHandle, CorInfoExceptionClass** ppException, void** ppIndirection); - void* (* getHelperFtn)(void * thisHandle, CorInfoExceptionClass** ppException, CorInfoHelpFunc ftnNum, void** ppIndirection); + void* (* getHelperFtn)(void * thisHandle, CorInfoExceptionClass** ppException, CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod); void (* getFunctionEntryPoint)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, CORINFO_CONST_LOOKUP* pResult, CORINFO_ACCESS_FLAGS accessFlags); void (* getFunctionFixedEntryPoint)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, bool isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult); void* (* getMethodSync)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, void** ppIndirection); @@ -1451,10 +1451,11 @@ class JitInterfaceWrapper : public ICorJitInfo virtual void* getHelperFtn( CorInfoHelpFunc ftnNum, - void** ppIndirection) + void** ppIndirection, + CORINFO_METHOD_HANDLE* pMethod) { CorInfoExceptionClass* pException = nullptr; - void* temp = _callbacks->getHelperFtn(_thisHandle, &pException, ftnNum, ppIndirection); + void* temp = _callbacks->getHelperFtn(_thisHandle, &pException, ftnNum, ppIndirection, pMethod); if (pException != nullptr) throw pException; return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index 771951a68baea8..38632842810a5f 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -133,6 +133,13 @@ struct Agnostic_CORINFO_RESOLVED_TOKENout DWORD cbMethodSpec; }; +struct Agnostic_GetHelperFtn +{ + DWORDLONG pMethod; + DWORDLONG ppIndirect; + DWORDLONG result; +}; + struct Agnostic_GetArgType_Key { // Partial CORINFO_SIG_INFO data diff --git a/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp b/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp index de8925555cb94e..49163ea52e0a91 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp @@ -1003,8 +1003,8 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b { for (unsigned int idx = 0; idx < rc->mc->GetHelperFtn->GetCount(); idx++) { - DLDL value = rc->mc->GetHelperFtn->GetItem(idx); - if (value.B == tmp.target) + Agnostic_GetHelperFtn value = rc->mc->GetHelperFtn->GetItem(idx); + if (value.result == tmp.target) { LogDebug(" REL32 target is result of getHelperFtn(): setting delta=%d (0x%X)", (int)tmp.target, (int)tmp.target); diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index b9be6659ed773f..0e770a966931df 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -93,7 +93,7 @@ LWM(GetFieldType, DLDL, DLD) LWM(GetFunctionEntryPoint, DLD, DLD) LWM(GetFunctionFixedEntryPoint, DWORDLONG, Agnostic_CORINFO_CONST_LOOKUP) LWM(GetGSCookie, DWORD, DLDL) -LWM(GetHelperFtn, DWORD, DLDL) +LWM(GetHelperFtn, DWORD, Agnostic_GetHelperFtn) LWM(GetHFAType, DWORDLONG, DWORD) LWM(GetIntConfigValue, Agnostic_ConfigIntInfo, DWORD) LWM(GetJitFlags, DWORD, DD) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 191e18718bc56f..a28f292e126242 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -2349,32 +2349,38 @@ void MethodContext::repGetReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN* p *pLookup = SpmiRecordsHelper::RestoreCORINFO_LOOKUP(value); } -void MethodContext::recGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, void* result) +void MethodContext::recGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod, void* result) { if (GetHelperFtn == nullptr) - GetHelperFtn = new LightWeightMap(); + GetHelperFtn = new LightWeightMap(); DWORD key = (DWORD)ftnNum; - DLDL value; - value.A = CastPointer(*ppIndirection); - value.B = CastPointer(result); + Agnostic_GetHelperFtn value = {}; // Zero value including any struct padding + value.ppIndirect = CastPointer(*ppIndirection); + value.result = CastPointer(result); + value.pMethod = pMethod != nullptr ? CastHandle(*pMethod) : 0; GetHelperFtn->Add(key, value); DEBUG_REC(dmpGetHelperFtn(key, value)); } -void MethodContext::dmpGetHelperFtn(DWORD key, DLDL value) +void MethodContext::dmpGetHelperFtn(DWORD key, Agnostic_GetHelperFtn value) { - printf("GetHelperFtn key ftn-%u, value ppi-%016" PRIX64 " res-%016" PRIX64 "", key, value.A, value.B); + printf("GetHelperFtn key ftn-%u, value ppi-%016" PRIX64 " mth-%016" PRIX64 "res-%016" PRIX64 "", key, value.ppIndirect, value.pMethod, value.result); } -void* MethodContext::repGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection) +void* MethodContext::repGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod) { DWORD key = (DWORD)ftnNum; - DLDL value = LookupByKeyOrMiss(GetHelperFtn, key, ": key %u", key); + Agnostic_GetHelperFtn value = LookupByKeyOrMiss(GetHelperFtn, key, ": key %u", key); DEBUG_REP(dmpGetHelperFtn(key, value)); - *ppIndirection = (void*)value.A; - return (void*)value.B; + if (pMethod != nullptr) + { + *pMethod = (CORINFO_METHOD_HANDLE)value.pMethod; + } + + *ppIndirection = (void*)value.ppIndirect; + return (void*)value.result; } // @@ -2400,11 +2406,11 @@ bool MethodContext::fndGetHelperFtn(void* functionAddress, CorInfoHelpFunc* pRes for (unsigned int i = 0; i < GetHelperFtn->GetCount(); i++) { DWORD key = GetHelperFtn->GetKey(i); - DLDL val = GetHelperFtn->GetItem(i); + Agnostic_GetHelperFtn val = GetHelperFtn->GetItem(i); // TODO-Cleanup: this only compares the function addresses, and doesn't account for // ppIndirection, which will break if the helper is a dynamic helper function. - if (val.B == CastPointer(functionAddress)) + if (val.result == CastPointer(functionAddress)) { *pResult = (CorInfoHelpFunc)key; return true; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index b6997b94e6c251..4e86a548b5bea8 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -332,9 +332,9 @@ class MethodContext CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* pLookup); - void recGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, void* result); - void dmpGetHelperFtn(DWORD key, DLDL value); - void* repGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection); + void recGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod, void* result); + void dmpGetHelperFtn(DWORD key, Agnostic_GetHelperFtn value); + void* repGetHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod); bool fndGetHelperFtn(void* functionAddress, CorInfoHelpFunc* pResult); void recGetJustMyCodeHandle(CORINFO_METHOD_HANDLE method, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index fdf27620abb211..89acb7a53c057d 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1456,11 +1456,11 @@ int32_t* interceptor_ICJI::getAddrOfCaptureThreadGlobal(void** ppIndirection) } // return the native entry point to an EE helper (see CorInfoHelpFunc) -void* interceptor_ICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection) +void* interceptor_ICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod) { mc->cr->AddCall("getHelperFtn"); - void* temp = original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection); - mc->recGetHelperFtn(ftnNum, ppIndirection, temp); + void* temp = original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection, pMethod); + mc->recGetHelperFtn(ftnNum, ppIndirection, pMethod, temp); return temp; } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index d14acec9674bb5..beb607d4ab93c2 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -1044,10 +1044,11 @@ int32_t* interceptor_ICJI::getAddrOfCaptureThreadGlobal( void* interceptor_ICJI::getHelperFtn( CorInfoHelpFunc ftnNum, - void** ppIndirection) + void** ppIndirection, + CORINFO_METHOD_HANDLE* pMethod) { mcs->AddCall("getHelperFtn"); - return original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection); + return original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection, pMethod); } void interceptor_ICJI::getFunctionEntryPoint( diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index ee04f7d948bb01..b223258e9f430d 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -915,9 +915,10 @@ int32_t* interceptor_ICJI::getAddrOfCaptureThreadGlobal( void* interceptor_ICJI::getHelperFtn( CorInfoHelpFunc ftnNum, - void** ppIndirection) + void** ppIndirection, + CORINFO_METHOD_HANDLE* pMethod) { - return original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection); + return original_ICorJitInfo->getHelperFtn(ftnNum, ppIndirection, pMethod); } void interceptor_ICJI::getFunctionEntryPoint( diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index d190ffe727303e..bf236f6b76d905 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -1271,10 +1271,10 @@ int32_t* MyICJI::getAddrOfCaptureThreadGlobal(void** ppIndirection) } // return the native entry point to an EE helper (see CorInfoHelpFunc) -void* MyICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection) +void* MyICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection, CORINFO_METHOD_HANDLE* pMethod) { jitInstance->mc->cr->AddCall("getHelperFtn"); - return jitInstance->mc->repGetHelperFtn(ftnNum, ppIndirection); + return jitInstance->mc->repGetHelperFtn(ftnNum, ppIndirection, pMethod); } // return a callable address of the function (native code). This function diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index ff5cf24a4ac01a..90a5846c5aef0d 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10689,8 +10689,9 @@ bool CEEInfo::logMsg(unsigned level, const char* fmt, va_list args) /*********************************************************************/ -void* CEEJitInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ - void ** ppIndirection) /* OUT */ +void* CEEJitInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ + void ** ppIndirection, /* OUT */ + CORINFO_METHOD_HANDLE* pMethod) /* OUT */ { CONTRACTL { THROWS; @@ -10748,6 +10749,11 @@ void* CEEJitInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ if (finalTierAddr != NULL) { result = finalTierAddr; + if (pMethod != nullptr && HasILBasedDynamicJitHelper((DynamicCorInfoHelpFunc)dynamicFtnNum)) + { + (void)LoadDynamicJitHelper((DynamicCorInfoHelpFunc)dynamicFtnNum, (MethodDesc**)pMethod); + _ASSERT(*pMethod != NULL); + } goto exit; } @@ -10757,6 +10763,11 @@ void* CEEJitInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ (void)LoadDynamicJitHelper((DynamicCorInfoHelpFunc)dynamicFtnNum, &helperMD); _ASSERT(helperMD != NULL); + if (pMethod != NULL) + { + *pMethod = (CORINFO_METHOD_HANDLE)helperMD; + } + // Check if the target MethodDesc is already jitted to its final Tier // so we no longer need to use indirections and can emit a direct call instead. // @@ -14519,8 +14530,9 @@ PatchpointInfo* CEEInfo::getOSRInfo(unsigned* ilOffset) UNREACHABLE(); // only called on derived class. } -void* CEEInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ - void ** ppIndirection) /* OUT */ +void* CEEInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ + void ** ppIndirection, /* OUT */ + CORINFO_METHOD_HANDLE* pMethod) /* OUT */ { LIMITED_METHOD_CONTRACT; UNREACHABLE(); // only called on derived class. diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index 6038fbfbbcc499..9fb00cc566352c 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -868,8 +868,9 @@ class CEEJitInfo : public CEEInfo void reportMetadata(const char* key, const void* value, size_t length) override final; - void* getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ - void ** ppIndirection) override final; /* OUT */ + void* getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ + void ** ppIndirection, /* OUT */ + CORINFO_METHOD_HANDLE* pMethod) override final; /* OUT */ static PCODE getHelperFtnStatic(CorInfoHelpFunc ftnNum); // Override of CEEInfo::GetProfilingHandle. The first time this is called for a