From b199388912be25ac860ebfb0ad13bc74cf62b25d Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 7 Jun 2020 13:21:45 +0300 Subject: [PATCH 1/4] Add getUniqueImplementingClass call to jitinterface --- .../superpmi-shared/icorjitinfoimpl.h | 2 + .../superpmi/superpmi-shared/lwmlist.h | 1 + .../superpmi-shared/methodcontext.cpp | 17 + .../superpmi/superpmi-shared/methodcontext.h | 7 +- .../superpmi-shim-collector/icorjitinfo.cpp | 8 + .../superpmi-shim-counter/icorjitinfo.cpp | 6 + .../superpmi-shim-simple/icorjitinfo.cpp | 5 + .../ToolBox/superpmi/superpmi/icorjitinfo.cpp | 7 + src/coreclr/src/inc/corinfo.h | 14 +- src/coreclr/src/jit/ICorJitInfo_API_names.h | 1 + .../src/jit/ICorJitInfo_API_wrapper.hpp | 10 + src/coreclr/src/jit/importer.cpp | 2 +- .../tools/Common/JitInterface/CorInfoBase.cs | 333 +++++++++--------- .../tools/Common/JitInterface/CorInfoImpl.cs | 5 + .../ThunkGenerator/ThunkInput.txt | 1 + .../crossgen2/jitinterface/jitinterface.h | 10 + .../crossgen2/jitinterface/jitwrapper.cpp | 10 +- src/coreclr/src/vm/jitinterface.cpp | 19 + src/coreclr/src/vm/jitinterface.h | 4 + src/coreclr/src/zap/zapinfo.cpp | 6 + src/coreclr/src/zap/zapinfo.h | 3 + 21 files changed, 302 insertions(+), 169 deletions(-) diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 03c722caed8962..03b1d140d8f886 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -130,6 +130,8 @@ CORINFO_METHOD_HANDLE getUnboxedEntry( // Returns null if the type can't be determined exactly. CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE elemType); +CORINFO_CLASS_HANDLE getUniqueImplementingClass(CORINFO_CLASS_HANDLE baseType); + // Given resolved token that corresponds to an intrinsic classified as // a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated // with the token. If this is not possible at compile-time (because the current method's diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h index 1922e7d0f5dfad..e930c3dc89882d 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -74,6 +74,7 @@ LWM(GetHeapClassSize, DWORDLONG, DWORD) LWM(CanAllocateOnStack, DWORDLONG, DWORD) LWM(GetCookieForPInvokeCalliSig, GetCookieForPInvokeCalliSigValue, DLDL) LWM(GetDefaultEqualityComparerClass, DWORDLONG, DWORDLONG) +LWM(GetUniqueImplementingClass, DWORDLONG, DWORDLONG) LWM(GetDelegateCtor, Agnostic_GetDelegateCtorIn, Agnostic_GetDelegateCtorOut) LWM(GetEEInfo, DWORD, Agnostic_CORINFO_EE_INFO) LWM(GetEHinfo, DLD, Agnostic_CORINFO_EH_CLAUSE) diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index 77603de0a850c6..3c26fc6d4166ee 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -3158,6 +3158,23 @@ CORINFO_CLASS_HANDLE MethodContext::repGetDefaultEqualityComparerClass(CORINFO_C return result; } +void MethodContext::recGetUniqueImplementingClass(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result) +{ + if (GetUniqueImplementingClass == nullptr) + GetUniqueImplementingClass = new LightWeightMap(); + + GetUniqueImplementingClass->Add((DWORDLONG)cls, (DWORDLONG)result); +} +void MethodContext::dmpGetUniqueImplementingClass(DWORDLONG key, DWORDLONG value) +{ + printf("GetUniqueImplementingClass key cls-%016llX, value cls-%016llX", key, value); +} +CORINFO_CLASS_HANDLE MethodContext::repGetUniqueImplementingClass(CORINFO_CLASS_HANDLE cls) +{ + CORINFO_CLASS_HANDLE result = (CORINFO_CLASS_HANDLE)GetUniqueImplementingClass->Get((DWORDLONG)cls); + return result; +} + void MethodContext::recGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CLASS_HANDLE result) { if (GetTokenTypeAsHandle == nullptr) diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index 1f34c4569e3358..d25e322aec8ac0 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -922,6 +922,10 @@ class MethodContext void dmpGetDefaultEqualityComparerClass(DWORDLONG key, DWORDLONG value); CORINFO_CLASS_HANDLE repGetDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE cls); + void recGetUniqueImplementingClass(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result); + void dmpGetUniqueImplementingClass(DWORDLONG key, DWORDLONG value); + CORINFO_CLASS_HANDLE repGetUniqueImplementingClass(CORINFO_CLASS_HANDLE cls); + void recGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_CLASS_HANDLE result); void dmpGetTokenTypeAsHandle(const GetTokenTypeAsHandleValue& key, DWORDLONG value); CORINFO_CLASS_HANDLE repGetTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken); @@ -1337,7 +1341,7 @@ class MethodContext }; // ********************* Please keep this up-to-date to ease adding more *************** -// Highest packet number: 178 +// Highest packet number: 179 // ************************************************************************************* enum mcPackets { @@ -1413,6 +1417,7 @@ enum mcPackets Packet_GetStringConfigValue = 152, // Added 2/12/2015 Packet_GetCookieForPInvokeCalliSig = 48, Packet_GetDefaultEqualityComparerClass = 162, // Added 9/24/2017 + Packet_GetUniqueImplementingClass = 162, // Added 6/7/2020 Packet_GetDelegateCtor = 49, Packet_GetEEInfo = 50, Packet_GetEHinfo = 51, diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 2da8785f96bc23..52fdcb8e10b3e1 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -265,6 +265,14 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_C return result; } +CORINFO_CLASS_HANDLE interceptor_ICJI::getUniqueImplementingClass(CORINFO_CLASS_HANDLE cls) +{ + mc->cr->AddCall("getUniqueImplementingClass"); + CORINFO_CLASS_HANDLE result = original_ICorJitInfo->getUniqueImplementingClass(cls); + mc->recGetUniqueImplementingClass(cls, result); + return result; +} + void interceptor_ICJI::expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) { diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index febd952a655fab..bf25948efa3fe1 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -177,6 +177,12 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_C return original_ICorJitInfo->getDefaultEqualityComparerClass(cls); } +CORINFO_CLASS_HANDLE interceptor_ICJI::getUniqueImplementingClass(CORINFO_CLASS_HANDLE cls) +{ + mcs->AddCall("getUniqueImplementingClass"); + return original_ICorJitInfo->getUniqueImplementingClass(cls); +} + void interceptor_ICJI::expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) { diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 26141d06068f46..8c0540cd101463 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -162,6 +162,11 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getDefaultEqualityComparerClass(CORINFO_C return original_ICorJitInfo->getDefaultEqualityComparerClass(cls); } +CORINFO_CLASS_HANDLE interceptor_ICJI::getUniqueImplementingClass(CORINFO_CLASS_HANDLE cls) +{ + return original_ICorJitInfo->getUniqueImplementingClass(cls); +} + void interceptor_ICJI::expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) { diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 24bc4415e586e0..eac5e745f030b0 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -202,6 +202,13 @@ CORINFO_CLASS_HANDLE MyICJI::getDefaultEqualityComparerClass(CORINFO_CLASS_HANDL return result; } +CORINFO_CLASS_HANDLE MyICJI::getUniqueImplementingClass(CORINFO_CLASS_HANDLE cls) +{ + jitInstance->mc->cr->AddCall("getUniqueImplementingClass"); + CORINFO_CLASS_HANDLE result = jitInstance->mc->repGetUniqueImplementingClass(cls); + return result; +} + void MyICJI::expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERICHANDLE_RESULT* pResult) { jitInstance->mc->cr->AddCall("expandRawHandleIntrinsic"); diff --git a/src/coreclr/src/inc/corinfo.h b/src/coreclr/src/inc/corinfo.h index 159b8ad92a6401..4a8eff2438a442 100644 --- a/src/coreclr/src/inc/corinfo.h +++ b/src/coreclr/src/inc/corinfo.h @@ -217,11 +217,11 @@ TODO: Talk about initializing strutures before use #endif #endif -SELECTANY const GUID JITEEVersionIdentifier = { /* 8b2226a2-ac30-4f5c-ae5c-926c792ecdb9 */ - 0x8b2226a2, - 0xac30, - 0x4f5c, - { 0xae, 0x5c, 0x92, 0x6c, 0x79, 0x2e, 0xcd, 0xb9 } +SELECTANY const GUID JITEEVersionIdentifier = { /* 34d57104-4280-472f-a13e-842ab177777d */ + 0x34d57104, + 0x4280, + 0x472f, + { 0xa1, 0x3e, 0x84, 0x2a, 0xb1, 0x77, 0x77, 0x7d } }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2102,6 +2102,10 @@ class ICorStaticInfo CORINFO_CLASS_HANDLE elemType ) = 0; + virtual CORINFO_CLASS_HANDLE getUniqueImplementingClass( + CORINFO_CLASS_HANDLE baseType + ) = 0; + // Given resolved token that corresponds to an intrinsic classified as // a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated // with the token. If this is not possible at compile-time (because the current method's diff --git a/src/coreclr/src/jit/ICorJitInfo_API_names.h b/src/coreclr/src/jit/ICorJitInfo_API_names.h index b2f623ac96fb19..9400233c36c55b 100644 --- a/src/coreclr/src/jit/ICorJitInfo_API_names.h +++ b/src/coreclr/src/jit/ICorJitInfo_API_names.h @@ -17,6 +17,7 @@ DEF_CLR_API(getMethodVTableOffset) DEF_CLR_API(resolveVirtualMethod) DEF_CLR_API(getUnboxedEntry) DEF_CLR_API(getDefaultEqualityComparerClass) +DEF_CLR_API(getUniqueImplementingClass) DEF_CLR_API(expandRawHandleIntrinsic) DEF_CLR_API(getIntrinsicID) DEF_CLR_API(isIntrinsicType) diff --git a/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp index 44e4a3ea1055f1..8f65af8b963e65 100644 --- a/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/src/jit/ICorJitInfo_API_wrapper.hpp @@ -163,6 +163,16 @@ CORINFO_CLASS_HANDLE WrapICorJitInfo::getDefaultEqualityComparerClass( return temp; } +CORINFO_CLASS_HANDLE WrapICorJitInfo::getUniqueImplementingClass( + CORINFO_CLASS_HANDLE baseType + ) +{ + API_ENTER(getUniqueImplementingClass); + CORINFO_CLASS_HANDLE temp = wrapHnd->getUniqueImplementingClass(baseType); + API_LEAVE(getUniqueImplementingClass); + return temp; +} + void WrapICorJitInfo::expandRawHandleIntrinsic( CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 079a111b25b981..3eb8122bcb6f71 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -20352,7 +20352,7 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, CORINFO_CLASS_HANDLE uniqueImplementingClass = NO_CLASS_HANDLE; - // info.compCompHnd->getUniqueImplementingClass(objClass); + uniqueImplementingClass = info.compCompHnd->getUniqueImplementingClass(objClass); if (uniqueImplementingClass == NO_CLASS_HANDLE) { diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs index 6b2869f23967e1..ff5604c28eb142 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoBase.cs @@ -42,6 +42,8 @@ unsafe partial class CorInfoImpl [UnmanagedFunctionPointerAttribute(default(CallingConvention))] delegate CORINFO_CLASS_STRUCT_* __getDefaultEqualityComparerClass(IntPtr _this, IntPtr* ppException, CORINFO_CLASS_STRUCT_* elemType); [UnmanagedFunctionPointerAttribute(default(CallingConvention))] + delegate CORINFO_CLASS_STRUCT_* __getUniqueImplementingClass(IntPtr _this, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType); + [UnmanagedFunctionPointerAttribute(default(CallingConvention))] delegate void __expandRawHandleIntrinsic(IntPtr _this, IntPtr* ppException, ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref CORINFO_GENERICHANDLE_RESULT pResult); [UnmanagedFunctionPointerAttribute(default(CallingConvention))] delegate CorInfoIntrinsics __getIntrinsicID(IntPtr _this, IntPtr* ppException, CORINFO_METHOD_STRUCT_* method, byte* pMustExpand); @@ -556,6 +558,20 @@ static void _getMethodVTableOffset(IntPtr thisHandle, IntPtr* ppException, CORIN } } + static CORINFO_CLASS_STRUCT_* _getUniqueImplementingClass(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* baseType) + { + var _this = GetThis(thisHandle); + try + { + return _this.getUniqueImplementingClass(baseType); + } + catch (Exception ex) + { + *ppException = _this.AllocException(ex); + return default(CORINFO_CLASS_STRUCT_*); + } + } + static void _expandRawHandleIntrinsic(IntPtr thisHandle, IntPtr* ppException, ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref CORINFO_GENERICHANDLE_RESULT pResult) { var _this = GetThis(thisHandle); @@ -2689,8 +2705,8 @@ static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, ref CORJIT_FLAG static IntPtr GetUnmanagedCallbacks(out Object keepAlive) { - IntPtr * callbacks = (IntPtr *)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 170); - Object[] delegates = new Object[170]; + IntPtr * callbacks = (IntPtr *)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 171); + Object[] delegates = new Object[171]; var d0 = new __getMethodAttribs(_getMethodAttribs); callbacks[0] = Marshal.GetFunctionPointerForDelegate(d0); @@ -2737,471 +2753,474 @@ static IntPtr GetUnmanagedCallbacks(out Object keepAlive) var d14 = new __getDefaultEqualityComparerClass(_getDefaultEqualityComparerClass); callbacks[14] = Marshal.GetFunctionPointerForDelegate(d14); delegates[14] = d14; - var d15 = new __expandRawHandleIntrinsic(_expandRawHandleIntrinsic); + var d15 = new __getUniqueImplementingClass(_getUniqueImplementingClass); callbacks[15] = Marshal.GetFunctionPointerForDelegate(d15); delegates[15] = d15; - var d16 = new __getIntrinsicID(_getIntrinsicID); + var d16 = new __expandRawHandleIntrinsic(_expandRawHandleIntrinsic); callbacks[16] = Marshal.GetFunctionPointerForDelegate(d16); delegates[16] = d16; - var d17 = new __isIntrinsicType(_isIntrinsicType); + var d17 = new __getIntrinsicID(_getIntrinsicID); callbacks[17] = Marshal.GetFunctionPointerForDelegate(d17); delegates[17] = d17; - var d18 = new __getUnmanagedCallConv(_getUnmanagedCallConv); + var d18 = new __isIntrinsicType(_isIntrinsicType); callbacks[18] = Marshal.GetFunctionPointerForDelegate(d18); delegates[18] = d18; - var d19 = new __pInvokeMarshalingRequired(_pInvokeMarshalingRequired); + var d19 = new __getUnmanagedCallConv(_getUnmanagedCallConv); callbacks[19] = Marshal.GetFunctionPointerForDelegate(d19); delegates[19] = d19; - var d20 = new __satisfiesMethodConstraints(_satisfiesMethodConstraints); + var d20 = new __pInvokeMarshalingRequired(_pInvokeMarshalingRequired); callbacks[20] = Marshal.GetFunctionPointerForDelegate(d20); delegates[20] = d20; - var d21 = new __isCompatibleDelegate(_isCompatibleDelegate); + var d21 = new __satisfiesMethodConstraints(_satisfiesMethodConstraints); callbacks[21] = Marshal.GetFunctionPointerForDelegate(d21); delegates[21] = d21; - var d22 = new __methodMustBeLoadedBeforeCodeIsRun(_methodMustBeLoadedBeforeCodeIsRun); + var d22 = new __isCompatibleDelegate(_isCompatibleDelegate); callbacks[22] = Marshal.GetFunctionPointerForDelegate(d22); delegates[22] = d22; - var d23 = new __mapMethodDeclToMethodImpl(_mapMethodDeclToMethodImpl); + var d23 = new __methodMustBeLoadedBeforeCodeIsRun(_methodMustBeLoadedBeforeCodeIsRun); callbacks[23] = Marshal.GetFunctionPointerForDelegate(d23); delegates[23] = d23; - var d24 = new __getGSCookie(_getGSCookie); + var d24 = new __mapMethodDeclToMethodImpl(_mapMethodDeclToMethodImpl); callbacks[24] = Marshal.GetFunctionPointerForDelegate(d24); delegates[24] = d24; - var d25 = new __setPatchpointInfo(_setPatchpointInfo); + var d25 = new __getGSCookie(_getGSCookie); callbacks[25] = Marshal.GetFunctionPointerForDelegate(d25); delegates[25] = d25; - var d26 = new __getOSRInfo(_getOSRInfo); + var d26 = new __setPatchpointInfo(_setPatchpointInfo); callbacks[26] = Marshal.GetFunctionPointerForDelegate(d26); delegates[26] = d26; - var d27 = new __resolveToken(_resolveToken); + var d27 = new __getOSRInfo(_getOSRInfo); callbacks[27] = Marshal.GetFunctionPointerForDelegate(d27); delegates[27] = d27; - var d28 = new __tryResolveToken(_tryResolveToken); + var d28 = new __resolveToken(_resolveToken); callbacks[28] = Marshal.GetFunctionPointerForDelegate(d28); delegates[28] = d28; - var d29 = new __findSig(_findSig); + var d29 = new __tryResolveToken(_tryResolveToken); callbacks[29] = Marshal.GetFunctionPointerForDelegate(d29); delegates[29] = d29; - var d30 = new __findCallSiteSig(_findCallSiteSig); + var d30 = new __findSig(_findSig); callbacks[30] = Marshal.GetFunctionPointerForDelegate(d30); delegates[30] = d30; - var d31 = new __getTokenTypeAsHandle(_getTokenTypeAsHandle); + var d31 = new __findCallSiteSig(_findCallSiteSig); callbacks[31] = Marshal.GetFunctionPointerForDelegate(d31); delegates[31] = d31; - var d32 = new __isValidToken(_isValidToken); + var d32 = new __getTokenTypeAsHandle(_getTokenTypeAsHandle); callbacks[32] = Marshal.GetFunctionPointerForDelegate(d32); delegates[32] = d32; - var d33 = new __isValidStringRef(_isValidStringRef); + var d33 = new __isValidToken(_isValidToken); callbacks[33] = Marshal.GetFunctionPointerForDelegate(d33); delegates[33] = d33; - var d34 = new __getStringLiteral(_getStringLiteral); + var d34 = new __isValidStringRef(_isValidStringRef); callbacks[34] = Marshal.GetFunctionPointerForDelegate(d34); delegates[34] = d34; - var d35 = new __asCorInfoType(_asCorInfoType); + var d35 = new __getStringLiteral(_getStringLiteral); callbacks[35] = Marshal.GetFunctionPointerForDelegate(d35); delegates[35] = d35; - var d36 = new __getClassName(_getClassName); + var d36 = new __asCorInfoType(_asCorInfoType); callbacks[36] = Marshal.GetFunctionPointerForDelegate(d36); delegates[36] = d36; - var d37 = new __getClassNameFromMetadata(_getClassNameFromMetadata); + var d37 = new __getClassName(_getClassName); callbacks[37] = Marshal.GetFunctionPointerForDelegate(d37); delegates[37] = d37; - var d38 = new __getTypeInstantiationArgument(_getTypeInstantiationArgument); + var d38 = new __getClassNameFromMetadata(_getClassNameFromMetadata); callbacks[38] = Marshal.GetFunctionPointerForDelegate(d38); delegates[38] = d38; - var d39 = new __appendClassName(_appendClassName); + var d39 = new __getTypeInstantiationArgument(_getTypeInstantiationArgument); callbacks[39] = Marshal.GetFunctionPointerForDelegate(d39); delegates[39] = d39; - var d40 = new __isValueClass(_isValueClass); + var d40 = new __appendClassName(_appendClassName); callbacks[40] = Marshal.GetFunctionPointerForDelegate(d40); delegates[40] = d40; - var d41 = new __canInlineTypeCheck(_canInlineTypeCheck); + var d41 = new __isValueClass(_isValueClass); callbacks[41] = Marshal.GetFunctionPointerForDelegate(d41); delegates[41] = d41; - var d42 = new __getClassAttribs(_getClassAttribs); + var d42 = new __canInlineTypeCheck(_canInlineTypeCheck); callbacks[42] = Marshal.GetFunctionPointerForDelegate(d42); delegates[42] = d42; - var d43 = new __isStructRequiringStackAllocRetBuf(_isStructRequiringStackAllocRetBuf); + var d43 = new __getClassAttribs(_getClassAttribs); callbacks[43] = Marshal.GetFunctionPointerForDelegate(d43); delegates[43] = d43; - var d44 = new __getClassModule(_getClassModule); + var d44 = new __isStructRequiringStackAllocRetBuf(_isStructRequiringStackAllocRetBuf); callbacks[44] = Marshal.GetFunctionPointerForDelegate(d44); delegates[44] = d44; - var d45 = new __getModuleAssembly(_getModuleAssembly); + var d45 = new __getClassModule(_getClassModule); callbacks[45] = Marshal.GetFunctionPointerForDelegate(d45); delegates[45] = d45; - var d46 = new __getAssemblyName(_getAssemblyName); + var d46 = new __getModuleAssembly(_getModuleAssembly); callbacks[46] = Marshal.GetFunctionPointerForDelegate(d46); delegates[46] = d46; - var d47 = new __LongLifetimeMalloc(_LongLifetimeMalloc); + var d47 = new __getAssemblyName(_getAssemblyName); callbacks[47] = Marshal.GetFunctionPointerForDelegate(d47); delegates[47] = d47; - var d48 = new __LongLifetimeFree(_LongLifetimeFree); + var d48 = new __LongLifetimeMalloc(_LongLifetimeMalloc); callbacks[48] = Marshal.GetFunctionPointerForDelegate(d48); delegates[48] = d48; - var d49 = new __getClassModuleIdForStatics(_getClassModuleIdForStatics); + var d49 = new __LongLifetimeFree(_LongLifetimeFree); callbacks[49] = Marshal.GetFunctionPointerForDelegate(d49); delegates[49] = d49; - var d50 = new __getClassSize(_getClassSize); + var d50 = new __getClassModuleIdForStatics(_getClassModuleIdForStatics); callbacks[50] = Marshal.GetFunctionPointerForDelegate(d50); delegates[50] = d50; - var d51 = new __getHeapClassSize(_getHeapClassSize); + var d51 = new __getClassSize(_getClassSize); callbacks[51] = Marshal.GetFunctionPointerForDelegate(d51); delegates[51] = d51; - var d52 = new __canAllocateOnStack(_canAllocateOnStack); + var d52 = new __getHeapClassSize(_getHeapClassSize); callbacks[52] = Marshal.GetFunctionPointerForDelegate(d52); delegates[52] = d52; - var d53 = new __getClassAlignmentRequirement(_getClassAlignmentRequirement); + var d53 = new __canAllocateOnStack(_canAllocateOnStack); callbacks[53] = Marshal.GetFunctionPointerForDelegate(d53); delegates[53] = d53; - var d54 = new __getClassGClayout(_getClassGClayout); + var d54 = new __getClassAlignmentRequirement(_getClassAlignmentRequirement); callbacks[54] = Marshal.GetFunctionPointerForDelegate(d54); delegates[54] = d54; - var d55 = new __getClassNumInstanceFields(_getClassNumInstanceFields); + var d55 = new __getClassGClayout(_getClassGClayout); callbacks[55] = Marshal.GetFunctionPointerForDelegate(d55); delegates[55] = d55; - var d56 = new __getFieldInClass(_getFieldInClass); + var d56 = new __getClassNumInstanceFields(_getClassNumInstanceFields); callbacks[56] = Marshal.GetFunctionPointerForDelegate(d56); delegates[56] = d56; - var d57 = new __checkMethodModifier(_checkMethodModifier); + var d57 = new __getFieldInClass(_getFieldInClass); callbacks[57] = Marshal.GetFunctionPointerForDelegate(d57); delegates[57] = d57; - var d58 = new __getNewHelper(_getNewHelper); + var d58 = new __checkMethodModifier(_checkMethodModifier); callbacks[58] = Marshal.GetFunctionPointerForDelegate(d58); delegates[58] = d58; - var d59 = new __getNewArrHelper(_getNewArrHelper); + var d59 = new __getNewHelper(_getNewHelper); callbacks[59] = Marshal.GetFunctionPointerForDelegate(d59); delegates[59] = d59; - var d60 = new __getCastingHelper(_getCastingHelper); + var d60 = new __getNewArrHelper(_getNewArrHelper); callbacks[60] = Marshal.GetFunctionPointerForDelegate(d60); delegates[60] = d60; - var d61 = new __getSharedCCtorHelper(_getSharedCCtorHelper); + var d61 = new __getCastingHelper(_getCastingHelper); callbacks[61] = Marshal.GetFunctionPointerForDelegate(d61); delegates[61] = d61; - var d62 = new __getTypeForBox(_getTypeForBox); + var d62 = new __getSharedCCtorHelper(_getSharedCCtorHelper); callbacks[62] = Marshal.GetFunctionPointerForDelegate(d62); delegates[62] = d62; - var d63 = new __getBoxHelper(_getBoxHelper); + var d63 = new __getTypeForBox(_getTypeForBox); callbacks[63] = Marshal.GetFunctionPointerForDelegate(d63); delegates[63] = d63; - var d64 = new __getUnBoxHelper(_getUnBoxHelper); + var d64 = new __getBoxHelper(_getBoxHelper); callbacks[64] = Marshal.GetFunctionPointerForDelegate(d64); delegates[64] = d64; - var d65 = new __getReadyToRunHelper(_getReadyToRunHelper); + var d65 = new __getUnBoxHelper(_getUnBoxHelper); callbacks[65] = Marshal.GetFunctionPointerForDelegate(d65); delegates[65] = d65; - var d66 = new __getReadyToRunDelegateCtorHelper(_getReadyToRunDelegateCtorHelper); + var d66 = new __getReadyToRunHelper(_getReadyToRunHelper); callbacks[66] = Marshal.GetFunctionPointerForDelegate(d66); delegates[66] = d66; - var d67 = new __getHelperName(_getHelperName); + var d67 = new __getReadyToRunDelegateCtorHelper(_getReadyToRunDelegateCtorHelper); callbacks[67] = Marshal.GetFunctionPointerForDelegate(d67); delegates[67] = d67; - var d68 = new __initClass(_initClass); + var d68 = new __getHelperName(_getHelperName); callbacks[68] = Marshal.GetFunctionPointerForDelegate(d68); delegates[68] = d68; - var d69 = new __classMustBeLoadedBeforeCodeIsRun(_classMustBeLoadedBeforeCodeIsRun); + var d69 = new __initClass(_initClass); callbacks[69] = Marshal.GetFunctionPointerForDelegate(d69); delegates[69] = d69; - var d70 = new __getBuiltinClass(_getBuiltinClass); + var d70 = new __classMustBeLoadedBeforeCodeIsRun(_classMustBeLoadedBeforeCodeIsRun); callbacks[70] = Marshal.GetFunctionPointerForDelegate(d70); delegates[70] = d70; - var d71 = new __getTypeForPrimitiveValueClass(_getTypeForPrimitiveValueClass); + var d71 = new __getBuiltinClass(_getBuiltinClass); callbacks[71] = Marshal.GetFunctionPointerForDelegate(d71); delegates[71] = d71; - var d72 = new __getTypeForPrimitiveNumericClass(_getTypeForPrimitiveNumericClass); + var d72 = new __getTypeForPrimitiveValueClass(_getTypeForPrimitiveValueClass); callbacks[72] = Marshal.GetFunctionPointerForDelegate(d72); delegates[72] = d72; - var d73 = new __canCast(_canCast); + var d73 = new __getTypeForPrimitiveNumericClass(_getTypeForPrimitiveNumericClass); callbacks[73] = Marshal.GetFunctionPointerForDelegate(d73); delegates[73] = d73; - var d74 = new __areTypesEquivalent(_areTypesEquivalent); + var d74 = new __canCast(_canCast); callbacks[74] = Marshal.GetFunctionPointerForDelegate(d74); delegates[74] = d74; - var d75 = new __compareTypesForCast(_compareTypesForCast); + var d75 = new __areTypesEquivalent(_areTypesEquivalent); callbacks[75] = Marshal.GetFunctionPointerForDelegate(d75); delegates[75] = d75; - var d76 = new __compareTypesForEquality(_compareTypesForEquality); + var d76 = new __compareTypesForCast(_compareTypesForCast); callbacks[76] = Marshal.GetFunctionPointerForDelegate(d76); delegates[76] = d76; - var d77 = new __mergeClasses(_mergeClasses); + var d77 = new __compareTypesForEquality(_compareTypesForEquality); callbacks[77] = Marshal.GetFunctionPointerForDelegate(d77); delegates[77] = d77; - var d78 = new __isMoreSpecificType(_isMoreSpecificType); + var d78 = new __mergeClasses(_mergeClasses); callbacks[78] = Marshal.GetFunctionPointerForDelegate(d78); delegates[78] = d78; - var d79 = new __getParentType(_getParentType); + var d79 = new __isMoreSpecificType(_isMoreSpecificType); callbacks[79] = Marshal.GetFunctionPointerForDelegate(d79); delegates[79] = d79; - var d80 = new __getChildType(_getChildType); + var d80 = new __getParentType(_getParentType); callbacks[80] = Marshal.GetFunctionPointerForDelegate(d80); delegates[80] = d80; - var d81 = new __satisfiesClassConstraints(_satisfiesClassConstraints); + var d81 = new __getChildType(_getChildType); callbacks[81] = Marshal.GetFunctionPointerForDelegate(d81); delegates[81] = d81; - var d82 = new __isSDArray(_isSDArray); + var d82 = new __satisfiesClassConstraints(_satisfiesClassConstraints); callbacks[82] = Marshal.GetFunctionPointerForDelegate(d82); delegates[82] = d82; - var d83 = new __getArrayRank(_getArrayRank); + var d83 = new __isSDArray(_isSDArray); callbacks[83] = Marshal.GetFunctionPointerForDelegate(d83); delegates[83] = d83; - var d84 = new __getArrayInitializationData(_getArrayInitializationData); + var d84 = new __getArrayRank(_getArrayRank); callbacks[84] = Marshal.GetFunctionPointerForDelegate(d84); delegates[84] = d84; - var d85 = new __canAccessClass(_canAccessClass); + var d85 = new __getArrayInitializationData(_getArrayInitializationData); callbacks[85] = Marshal.GetFunctionPointerForDelegate(d85); delegates[85] = d85; - var d86 = new __getFieldName(_getFieldName); + var d86 = new __canAccessClass(_canAccessClass); callbacks[86] = Marshal.GetFunctionPointerForDelegate(d86); delegates[86] = d86; - var d87 = new __getFieldClass(_getFieldClass); + var d87 = new __getFieldName(_getFieldName); callbacks[87] = Marshal.GetFunctionPointerForDelegate(d87); delegates[87] = d87; - var d88 = new __getFieldType(_getFieldType); + var d88 = new __getFieldClass(_getFieldClass); callbacks[88] = Marshal.GetFunctionPointerForDelegate(d88); delegates[88] = d88; - var d89 = new __getFieldOffset(_getFieldOffset); + var d89 = new __getFieldType(_getFieldType); callbacks[89] = Marshal.GetFunctionPointerForDelegate(d89); delegates[89] = d89; - var d90 = new __getFieldInfo(_getFieldInfo); + var d90 = new __getFieldOffset(_getFieldOffset); callbacks[90] = Marshal.GetFunctionPointerForDelegate(d90); delegates[90] = d90; - var d91 = new __isFieldStatic(_isFieldStatic); + var d91 = new __getFieldInfo(_getFieldInfo); callbacks[91] = Marshal.GetFunctionPointerForDelegate(d91); delegates[91] = d91; - var d92 = new __getBoundaries(_getBoundaries); + var d92 = new __isFieldStatic(_isFieldStatic); callbacks[92] = Marshal.GetFunctionPointerForDelegate(d92); delegates[92] = d92; - var d93 = new __setBoundaries(_setBoundaries); + var d93 = new __getBoundaries(_getBoundaries); callbacks[93] = Marshal.GetFunctionPointerForDelegate(d93); delegates[93] = d93; - var d94 = new __getVars(_getVars); + var d94 = new __setBoundaries(_setBoundaries); callbacks[94] = Marshal.GetFunctionPointerForDelegate(d94); delegates[94] = d94; - var d95 = new __setVars(_setVars); + var d95 = new __getVars(_getVars); callbacks[95] = Marshal.GetFunctionPointerForDelegate(d95); delegates[95] = d95; - var d96 = new __allocateArray(_allocateArray); + var d96 = new __setVars(_setVars); callbacks[96] = Marshal.GetFunctionPointerForDelegate(d96); delegates[96] = d96; - var d97 = new __freeArray(_freeArray); + var d97 = new __allocateArray(_allocateArray); callbacks[97] = Marshal.GetFunctionPointerForDelegate(d97); delegates[97] = d97; - var d98 = new __getArgNext(_getArgNext); + var d98 = new __freeArray(_freeArray); callbacks[98] = Marshal.GetFunctionPointerForDelegate(d98); delegates[98] = d98; - var d99 = new __getArgType(_getArgType); + var d99 = new __getArgNext(_getArgNext); callbacks[99] = Marshal.GetFunctionPointerForDelegate(d99); delegates[99] = d99; - var d100 = new __getArgClass(_getArgClass); + var d100 = new __getArgType(_getArgType); callbacks[100] = Marshal.GetFunctionPointerForDelegate(d100); delegates[100] = d100; - var d101 = new __getHFAType(_getHFAType); + var d101 = new __getArgClass(_getArgClass); callbacks[101] = Marshal.GetFunctionPointerForDelegate(d101); delegates[101] = d101; - var d102 = new __GetErrorHRESULT(_GetErrorHRESULT); + var d102 = new __getHFAType(_getHFAType); callbacks[102] = Marshal.GetFunctionPointerForDelegate(d102); delegates[102] = d102; - var d103 = new __GetErrorMessage(_GetErrorMessage); + var d103 = new __GetErrorHRESULT(_GetErrorHRESULT); callbacks[103] = Marshal.GetFunctionPointerForDelegate(d103); delegates[103] = d103; - var d104 = new __FilterException(_FilterException); + var d104 = new __GetErrorMessage(_GetErrorMessage); callbacks[104] = Marshal.GetFunctionPointerForDelegate(d104); delegates[104] = d104; - var d105 = new __HandleException(_HandleException); + var d105 = new __FilterException(_FilterException); callbacks[105] = Marshal.GetFunctionPointerForDelegate(d105); delegates[105] = d105; - var d106 = new __ThrowExceptionForJitResult(_ThrowExceptionForJitResult); + var d106 = new __HandleException(_HandleException); callbacks[106] = Marshal.GetFunctionPointerForDelegate(d106); delegates[106] = d106; - var d107 = new __ThrowExceptionForHelper(_ThrowExceptionForHelper); + var d107 = new __ThrowExceptionForJitResult(_ThrowExceptionForJitResult); callbacks[107] = Marshal.GetFunctionPointerForDelegate(d107); delegates[107] = d107; - var d108 = new __runWithErrorTrap(_runWithErrorTrap); + var d108 = new __ThrowExceptionForHelper(_ThrowExceptionForHelper); callbacks[108] = Marshal.GetFunctionPointerForDelegate(d108); delegates[108] = d108; - var d109 = new __getEEInfo(_getEEInfo); + var d109 = new __runWithErrorTrap(_runWithErrorTrap); callbacks[109] = Marshal.GetFunctionPointerForDelegate(d109); delegates[109] = d109; - var d110 = new __getJitTimeLogFilename(_getJitTimeLogFilename); + var d110 = new __getEEInfo(_getEEInfo); callbacks[110] = Marshal.GetFunctionPointerForDelegate(d110); delegates[110] = d110; - var d111 = new __getMethodDefFromMethod(_getMethodDefFromMethod); + var d111 = new __getJitTimeLogFilename(_getJitTimeLogFilename); callbacks[111] = Marshal.GetFunctionPointerForDelegate(d111); delegates[111] = d111; - var d112 = new __getMethodName(_getMethodName); + var d112 = new __getMethodDefFromMethod(_getMethodDefFromMethod); callbacks[112] = Marshal.GetFunctionPointerForDelegate(d112); delegates[112] = d112; - var d113 = new __getMethodNameFromMetadata(_getMethodNameFromMetadata); + var d113 = new __getMethodName(_getMethodName); callbacks[113] = Marshal.GetFunctionPointerForDelegate(d113); delegates[113] = d113; - var d114 = new __getMethodHash(_getMethodHash); + var d114 = new __getMethodNameFromMetadata(_getMethodNameFromMetadata); callbacks[114] = Marshal.GetFunctionPointerForDelegate(d114); delegates[114] = d114; - var d115 = new __findNameOfToken(_findNameOfToken); + var d115 = new __getMethodHash(_getMethodHash); callbacks[115] = Marshal.GetFunctionPointerForDelegate(d115); delegates[115] = d115; - var d116 = new __getSystemVAmd64PassStructInRegisterDescriptor(_getSystemVAmd64PassStructInRegisterDescriptor); + var d116 = new __findNameOfToken(_findNameOfToken); callbacks[116] = Marshal.GetFunctionPointerForDelegate(d116); delegates[116] = d116; - var d117 = new __getThreadTLSIndex(_getThreadTLSIndex); + var d117 = new __getSystemVAmd64PassStructInRegisterDescriptor(_getSystemVAmd64PassStructInRegisterDescriptor); callbacks[117] = Marshal.GetFunctionPointerForDelegate(d117); delegates[117] = d117; - var d118 = new __getInlinedCallFrameVptr(_getInlinedCallFrameVptr); + var d118 = new __getThreadTLSIndex(_getThreadTLSIndex); callbacks[118] = Marshal.GetFunctionPointerForDelegate(d118); delegates[118] = d118; - var d119 = new __getAddrOfCaptureThreadGlobal(_getAddrOfCaptureThreadGlobal); + var d119 = new __getInlinedCallFrameVptr(_getInlinedCallFrameVptr); callbacks[119] = Marshal.GetFunctionPointerForDelegate(d119); delegates[119] = d119; - var d120 = new __getHelperFtn(_getHelperFtn); + var d120 = new __getAddrOfCaptureThreadGlobal(_getAddrOfCaptureThreadGlobal); callbacks[120] = Marshal.GetFunctionPointerForDelegate(d120); delegates[120] = d120; - var d121 = new __getFunctionEntryPoint(_getFunctionEntryPoint); + var d121 = new __getHelperFtn(_getHelperFtn); callbacks[121] = Marshal.GetFunctionPointerForDelegate(d121); delegates[121] = d121; - var d122 = new __getFunctionFixedEntryPoint(_getFunctionFixedEntryPoint); + var d122 = new __getFunctionEntryPoint(_getFunctionEntryPoint); callbacks[122] = Marshal.GetFunctionPointerForDelegate(d122); delegates[122] = d122; - var d123 = new __getMethodSync(_getMethodSync); + var d123 = new __getFunctionFixedEntryPoint(_getFunctionFixedEntryPoint); callbacks[123] = Marshal.GetFunctionPointerForDelegate(d123); delegates[123] = d123; - var d124 = new __getLazyStringLiteralHelper(_getLazyStringLiteralHelper); + var d124 = new __getMethodSync(_getMethodSync); callbacks[124] = Marshal.GetFunctionPointerForDelegate(d124); delegates[124] = d124; - var d125 = new __embedModuleHandle(_embedModuleHandle); + var d125 = new __getLazyStringLiteralHelper(_getLazyStringLiteralHelper); callbacks[125] = Marshal.GetFunctionPointerForDelegate(d125); delegates[125] = d125; - var d126 = new __embedClassHandle(_embedClassHandle); + var d126 = new __embedModuleHandle(_embedModuleHandle); callbacks[126] = Marshal.GetFunctionPointerForDelegate(d126); delegates[126] = d126; - var d127 = new __embedMethodHandle(_embedMethodHandle); + var d127 = new __embedClassHandle(_embedClassHandle); callbacks[127] = Marshal.GetFunctionPointerForDelegate(d127); delegates[127] = d127; - var d128 = new __embedFieldHandle(_embedFieldHandle); + var d128 = new __embedMethodHandle(_embedMethodHandle); callbacks[128] = Marshal.GetFunctionPointerForDelegate(d128); delegates[128] = d128; - var d129 = new __embedGenericHandle(_embedGenericHandle); + var d129 = new __embedFieldHandle(_embedFieldHandle); callbacks[129] = Marshal.GetFunctionPointerForDelegate(d129); delegates[129] = d129; - var d130 = new __getLocationOfThisType(_getLocationOfThisType); + var d130 = new __embedGenericHandle(_embedGenericHandle); callbacks[130] = Marshal.GetFunctionPointerForDelegate(d130); delegates[130] = d130; - var d131 = new __getAddressOfPInvokeTarget(_getAddressOfPInvokeTarget); + var d131 = new __getLocationOfThisType(_getLocationOfThisType); callbacks[131] = Marshal.GetFunctionPointerForDelegate(d131); delegates[131] = d131; - var d132 = new __GetCookieForPInvokeCalliSig(_GetCookieForPInvokeCalliSig); + var d132 = new __getAddressOfPInvokeTarget(_getAddressOfPInvokeTarget); callbacks[132] = Marshal.GetFunctionPointerForDelegate(d132); delegates[132] = d132; - var d133 = new __canGetCookieForPInvokeCalliSig(_canGetCookieForPInvokeCalliSig); + var d133 = new __GetCookieForPInvokeCalliSig(_GetCookieForPInvokeCalliSig); callbacks[133] = Marshal.GetFunctionPointerForDelegate(d133); delegates[133] = d133; - var d134 = new __getJustMyCodeHandle(_getJustMyCodeHandle); + var d134 = new __canGetCookieForPInvokeCalliSig(_canGetCookieForPInvokeCalliSig); callbacks[134] = Marshal.GetFunctionPointerForDelegate(d134); delegates[134] = d134; - var d135 = new __GetProfilingHandle(_GetProfilingHandle); + var d135 = new __getJustMyCodeHandle(_getJustMyCodeHandle); callbacks[135] = Marshal.GetFunctionPointerForDelegate(d135); delegates[135] = d135; - var d136 = new __getCallInfo(_getCallInfo); + var d136 = new __GetProfilingHandle(_GetProfilingHandle); callbacks[136] = Marshal.GetFunctionPointerForDelegate(d136); delegates[136] = d136; - var d137 = new __canAccessFamily(_canAccessFamily); + var d137 = new __getCallInfo(_getCallInfo); callbacks[137] = Marshal.GetFunctionPointerForDelegate(d137); delegates[137] = d137; - var d138 = new __isRIDClassDomainID(_isRIDClassDomainID); + var d138 = new __canAccessFamily(_canAccessFamily); callbacks[138] = Marshal.GetFunctionPointerForDelegate(d138); delegates[138] = d138; - var d139 = new __getClassDomainID(_getClassDomainID); + var d139 = new __isRIDClassDomainID(_isRIDClassDomainID); callbacks[139] = Marshal.GetFunctionPointerForDelegate(d139); delegates[139] = d139; - var d140 = new __getFieldAddress(_getFieldAddress); + var d140 = new __getClassDomainID(_getClassDomainID); callbacks[140] = Marshal.GetFunctionPointerForDelegate(d140); delegates[140] = d140; - var d141 = new __getStaticFieldCurrentClass(_getStaticFieldCurrentClass); + var d141 = new __getFieldAddress(_getFieldAddress); callbacks[141] = Marshal.GetFunctionPointerForDelegate(d141); delegates[141] = d141; - var d142 = new __getVarArgsHandle(_getVarArgsHandle); + var d142 = new __getStaticFieldCurrentClass(_getStaticFieldCurrentClass); callbacks[142] = Marshal.GetFunctionPointerForDelegate(d142); delegates[142] = d142; - var d143 = new __canGetVarArgsHandle(_canGetVarArgsHandle); + var d143 = new __getVarArgsHandle(_getVarArgsHandle); callbacks[143] = Marshal.GetFunctionPointerForDelegate(d143); delegates[143] = d143; - var d144 = new __constructStringLiteral(_constructStringLiteral); + var d144 = new __canGetVarArgsHandle(_canGetVarArgsHandle); callbacks[144] = Marshal.GetFunctionPointerForDelegate(d144); delegates[144] = d144; - var d145 = new __emptyStringLiteral(_emptyStringLiteral); + var d145 = new __constructStringLiteral(_constructStringLiteral); callbacks[145] = Marshal.GetFunctionPointerForDelegate(d145); delegates[145] = d145; - var d146 = new __getFieldThreadLocalStoreID(_getFieldThreadLocalStoreID); + var d146 = new __emptyStringLiteral(_emptyStringLiteral); callbacks[146] = Marshal.GetFunctionPointerForDelegate(d146); delegates[146] = d146; - var d147 = new __setOverride(_setOverride); + var d147 = new __getFieldThreadLocalStoreID(_getFieldThreadLocalStoreID); callbacks[147] = Marshal.GetFunctionPointerForDelegate(d147); delegates[147] = d147; - var d148 = new __addActiveDependency(_addActiveDependency); + var d148 = new __setOverride(_setOverride); callbacks[148] = Marshal.GetFunctionPointerForDelegate(d148); delegates[148] = d148; - var d149 = new __GetDelegateCtor(_GetDelegateCtor); + var d149 = new __addActiveDependency(_addActiveDependency); callbacks[149] = Marshal.GetFunctionPointerForDelegate(d149); delegates[149] = d149; - var d150 = new __MethodCompileComplete(_MethodCompileComplete); + var d150 = new __GetDelegateCtor(_GetDelegateCtor); callbacks[150] = Marshal.GetFunctionPointerForDelegate(d150); delegates[150] = d150; - var d151 = new __getTailCallHelpers(_getTailCallHelpers); + var d151 = new __MethodCompileComplete(_MethodCompileComplete); callbacks[151] = Marshal.GetFunctionPointerForDelegate(d151); delegates[151] = d151; - var d152 = new __convertPInvokeCalliToCall(_convertPInvokeCalliToCall); + var d152 = new __getTailCallHelpers(_getTailCallHelpers); callbacks[152] = Marshal.GetFunctionPointerForDelegate(d152); delegates[152] = d152; - var d153 = new __notifyInstructionSetUsage(_notifyInstructionSetUsage); + var d153 = new __convertPInvokeCalliToCall(_convertPInvokeCalliToCall); callbacks[153] = Marshal.GetFunctionPointerForDelegate(d153); delegates[153] = d153; - var d154 = new __allocMem(_allocMem); + var d154 = new __notifyInstructionSetUsage(_notifyInstructionSetUsage); callbacks[154] = Marshal.GetFunctionPointerForDelegate(d154); delegates[154] = d154; - var d155 = new __reserveUnwindInfo(_reserveUnwindInfo); + var d155 = new __allocMem(_allocMem); callbacks[155] = Marshal.GetFunctionPointerForDelegate(d155); delegates[155] = d155; - var d156 = new __allocUnwindInfo(_allocUnwindInfo); + var d156 = new __reserveUnwindInfo(_reserveUnwindInfo); callbacks[156] = Marshal.GetFunctionPointerForDelegate(d156); delegates[156] = d156; - var d157 = new __allocGCInfo(_allocGCInfo); + var d157 = new __allocUnwindInfo(_allocUnwindInfo); callbacks[157] = Marshal.GetFunctionPointerForDelegate(d157); delegates[157] = d157; - var d158 = new __setEHcount(_setEHcount); + var d158 = new __allocGCInfo(_allocGCInfo); callbacks[158] = Marshal.GetFunctionPointerForDelegate(d158); delegates[158] = d158; - var d159 = new __setEHinfo(_setEHinfo); + var d159 = new __setEHcount(_setEHcount); callbacks[159] = Marshal.GetFunctionPointerForDelegate(d159); delegates[159] = d159; - var d160 = new __logMsg(_logMsg); + var d160 = new __setEHinfo(_setEHinfo); callbacks[160] = Marshal.GetFunctionPointerForDelegate(d160); delegates[160] = d160; - var d161 = new __doAssert(_doAssert); + var d161 = new __logMsg(_logMsg); callbacks[161] = Marshal.GetFunctionPointerForDelegate(d161); delegates[161] = d161; - var d162 = new __reportFatalError(_reportFatalError); + var d162 = new __doAssert(_doAssert); callbacks[162] = Marshal.GetFunctionPointerForDelegate(d162); delegates[162] = d162; - var d163 = new __allocMethodBlockCounts(_allocMethodBlockCounts); + var d163 = new __reportFatalError(_reportFatalError); callbacks[163] = Marshal.GetFunctionPointerForDelegate(d163); delegates[163] = d163; - var d164 = new __getMethodBlockCounts(_getMethodBlockCounts); + var d164 = new __allocMethodBlockCounts(_allocMethodBlockCounts); callbacks[164] = Marshal.GetFunctionPointerForDelegate(d164); delegates[164] = d164; - var d165 = new __recordCallSite(_recordCallSite); + var d165 = new __getMethodBlockCounts(_getMethodBlockCounts); callbacks[165] = Marshal.GetFunctionPointerForDelegate(d165); delegates[165] = d165; - var d166 = new __recordRelocation(_recordRelocation); + var d166 = new __recordCallSite(_recordCallSite); callbacks[166] = Marshal.GetFunctionPointerForDelegate(d166); delegates[166] = d166; - var d167 = new __getRelocTypeHint(_getRelocTypeHint); + var d167 = new __recordRelocation(_recordRelocation); callbacks[167] = Marshal.GetFunctionPointerForDelegate(d167); delegates[167] = d167; - var d168 = new __getExpectedTargetArchitecture(_getExpectedTargetArchitecture); + var d168 = new __getRelocTypeHint(_getRelocTypeHint); callbacks[168] = Marshal.GetFunctionPointerForDelegate(d168); delegates[168] = d168; - var d169 = new __getJitFlags(_getJitFlags); + var d169 = new __getExpectedTargetArchitecture(_getExpectedTargetArchitecture); callbacks[169] = Marshal.GetFunctionPointerForDelegate(d169); delegates[169] = d169; + var d170 = new __getJitFlags(_getJitFlags); + callbacks[170] = Marshal.GetFunctionPointerForDelegate(d170); + delegates[170] = d170; keepAlive = delegates; return (IntPtr)callbacks; diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index fef6e6e5eb5ed7..b710e9dcf2223c 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -910,6 +910,11 @@ private void getEHinfo(CORINFO_METHOD_STRUCT_* ftn, uint EHnumber, ref CORINFO_E return comparer != null ? ObjectToHandle(comparer) : null; } + private CORINFO_CLASS_STRUCT_* getUniqueImplementingClass(CORINFO_CLASS_STRUCT_* baseType) + { + return null; + } + private bool isIntrinsicType(CORINFO_CLASS_STRUCT_* classHnd) { TypeDesc type = HandleToObject(classHnd); diff --git a/src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index fd5b9f464452c0..11ff70b719eb46 100644 --- a/src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -177,6 +177,7 @@ FUNCTIONS CORINFO_METHOD_HANDLE resolveVirtualMethod( CORINFO_METHOD_HANDLE virtualMethod, CORINFO_CLASS_HANDLE implementingClass, CORINFO_CONTEXT_HANDLE ownerType); CORINFO_METHOD_HANDLE getUnboxedEntry(CORINFO_METHOD_HANDLE ftn, BoolStar requiresInstMethodTableArg); CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass(CORINFO_CLASS_HANDLE elemType); + CORINFO_CLASS_HANDLE getUniqueImplementingClass(CORINFO_CLASS_HANDLE baseType); void expandRawHandleIntrinsic(CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult); CorInfoIntrinsics getIntrinsicID( CORINFO_METHOD_HANDLE method , BoolStar pMustExpand); bool isIntrinsicType( CORINFO_CLASS_HANDLE classHnd ); diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h b/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h index 88144e0bb8455f..806247e2ebf146 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h +++ b/src/coreclr/src/tools/crossgen2/jitinterface/jitinterface.h @@ -25,6 +25,7 @@ struct JitInterfaceCallbacks void* (* resolveVirtualMethod)(void * thisHandle, CorInfoException** ppException, void* virtualMethod, void* implementingClass, void* ownerType); void* (* getUnboxedEntry)(void * thisHandle, CorInfoException** ppException, void* ftn, bool* requiresInstMethodTableArg); void* (* getDefaultEqualityComparerClass)(void * thisHandle, CorInfoException** ppException, void* elemType); + void* (* getUniqueImplementingClass)(void * thisHandle, CorInfoException** ppException, void* baseType); void (* expandRawHandleIntrinsic)(void * thisHandle, CorInfoException** ppException, void* pResolvedToken, void* pResult); int (* getIntrinsicID)(void * thisHandle, CorInfoException** ppException, void* method, bool* pMustExpand); bool (* isIntrinsicType)(void * thisHandle, CorInfoException** ppException, void* classHnd); @@ -323,6 +324,15 @@ class JitInterfaceWrapper return _ret; } + virtual void* getUniqueImplementingClass(void* baseType) + { + CorInfoException* pException = nullptr; + void* _ret = _callbacks->getUniqueImplementingClass(_thisHandle, &pException, baseType); + if (pException != nullptr) + throw pException; + return _ret; + } + virtual void expandRawHandleIntrinsic(void* pResolvedToken, void* pResult) { CorInfoException* pException = nullptr; diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp b/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp index 63fa69eda34f43..61338ebf45dbb9 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp +++ b/src/coreclr/src/tools/crossgen2/jitinterface/jitwrapper.cpp @@ -27,11 +27,11 @@ class CORJIT_FLAGS uint64_t corJitFlags; }; -static const GUID JITEEVersionIdentifier = { /* 8b2226a2-ac30-4f5c-ae5c-926c792ecdb9 */ - 0x8b2226a2, - 0xac30, - 0x4f5c, - { 0xae, 0x5c, 0x92, 0x6c, 0x79, 0x2e, 0xcd, 0xb9 } +static const GUID JITEEVersionIdentifier = { /* 34d57104-4280-472f-a13e-842ab177777d */ + 0x34d57104, + 0x4280, + 0x472f, + { 0xa1, 0x3e, 0x84, 0x2a, 0xb1, 0x77, 0x77, 0x7d } }; class Jit diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index 196782100c0f3c..ee630b9282f0be 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -9153,6 +9153,25 @@ CORINFO_CLASS_HANDLE CEEInfo::getDefaultEqualityComparerClassHelper(CORINFO_CLAS return CORINFO_CLASS_HANDLE(resultTh.GetMethodTable()); } +CORINFO_CLASS_HANDLE CEEInfo::getUniqueImplementingClass(CORINFO_CLASS_HANDLE baseType) +{ + CONTRACTL { + THROWS; + GC_TRIGGERS; + MODE_PREEMPTIVE; + } CONTRACTL_END; + + CORINFO_CLASS_HANDLE result = NULL; + + JIT_TO_EE_TRANSITION(); + + result = NULL; // EGOR: implement here + + EE_TO_JIT_TRANSITION(); + + return result; +} + /*********************************************************************/ void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd, CORINFO_CONST_LOOKUP * pResult, diff --git a/src/coreclr/src/vm/jitinterface.h b/src/coreclr/src/vm/jitinterface.h index 0e52a1eccc5721..99dc0d9194a7d8 100644 --- a/src/coreclr/src/vm/jitinterface.h +++ b/src/coreclr/src/vm/jitinterface.h @@ -771,6 +771,10 @@ class CEEInfo : public ICorJitInfo CORINFO_CLASS_HANDLE elemType ); + CORINFO_CLASS_HANDLE getUniqueImplementingClass( + CORINFO_CLASS_HANDLE baseType + ); + void expandRawHandleIntrinsic( CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult); diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index 1f4f83c0e48e8a..9f09253f62a652 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -3973,6 +3973,12 @@ CORINFO_CLASS_HANDLE ZapInfo::getDefaultEqualityComparerClass( return m_pEEJitInfo->getDefaultEqualityComparerClass(elemType); } +CORINFO_CLASS_HANDLE ZapInfo::getUniqueImplementingClass( + CORINFO_CLASS_HANDLE baseType) +{ + return m_pEEJitInfo->getUniqueImplementingClass(baseType); +} + void ZapInfo::expandRawHandleIntrinsic( CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult) diff --git a/src/coreclr/src/zap/zapinfo.h b/src/coreclr/src/zap/zapinfo.h index 6079f3291c6ea3..2ffb46e2984a51 100644 --- a/src/coreclr/src/zap/zapinfo.h +++ b/src/coreclr/src/zap/zapinfo.h @@ -682,6 +682,9 @@ class ZapInfo CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass( CORINFO_CLASS_HANDLE elemType); + CORINFO_CLASS_HANDLE getUniqueImplementingClass( + CORINFO_CLASS_HANDLE baseType); + void expandRawHandleIntrinsic( CORINFO_RESOLVED_TOKEN * pResolvedToken, CORINFO_GENERICHANDLE_RESULT * pResult); From 2c6b351d462e2e4f0deec9a5eb4e8af39300fd9f Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 7 Jun 2020 16:39:41 +0300 Subject: [PATCH 2/4] Implement getUniqueImplementingClass --- .../superpmi/superpmi-shared/methodcontext.h | 2 +- src/coreclr/src/jit/importer.cpp | 13 +++-- src/coreclr/src/vm/jitinterface.cpp | 53 +++++++++++++++++-- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index d25e322aec8ac0..fe30117ffd9fec 100644 --- a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -1417,7 +1417,7 @@ enum mcPackets Packet_GetStringConfigValue = 152, // Added 2/12/2015 Packet_GetCookieForPInvokeCalliSig = 48, Packet_GetDefaultEqualityComparerClass = 162, // Added 9/24/2017 - Packet_GetUniqueImplementingClass = 162, // Added 6/7/2020 + Packet_GetUniqueImplementingClass = 179, // Added 6/7/2020 Packet_GetDelegateCtor = 49, Packet_GetEEInfo = 50, Packet_GetEHinfo = 51, diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 3eb8122bcb6f71..29cea4b7e8ab86 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -20350,9 +20350,16 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, return; } + bool guessUniqueInterface = false; + + INDEBUG(guessUniqueInterface = (JitConfig.JitGuardedDevirtualizationGuessUniqueInterface() > 0);); + CORINFO_CLASS_HANDLE uniqueImplementingClass = NO_CLASS_HANDLE; - uniqueImplementingClass = info.compCompHnd->getUniqueImplementingClass(objClass); + if (guessUniqueInterface && !opts.IsReadyToRun() && opts.OptimizationEnabled()) + { + uniqueImplementingClass = info.compCompHnd->getUniqueImplementingClass(objClass); + } if (uniqueImplementingClass == NO_CLASS_HANDLE) { @@ -20363,10 +20370,6 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, JITDUMP("Only known implementor of interface %p (%s) is %p (%s)!\n", dspPtr(objClass), objClassName, uniqueImplementingClass, eeGetClassName(uniqueImplementingClass)); - bool guessUniqueInterface = true; - - INDEBUG(guessUniqueInterface = (JitConfig.JitGuardedDevirtualizationGuessUniqueInterface() > 0);); - if (!guessUniqueInterface) { JITDUMP("Guarded devirt for unique interface implementor is not enabled, sorry\n"); diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index ee630b9282f0be..e9cd7935c87356 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -9161,15 +9161,60 @@ CORINFO_CLASS_HANDLE CEEInfo::getUniqueImplementingClass(CORINFO_CLASS_HANDLE ba MODE_PREEMPTIVE; } CONTRACTL_END; - CORINFO_CLASS_HANDLE result = NULL; + int implementators = 0; + CORINFO_CLASS_HANDLE result = NULL; + +#if !defined(CROSSGEN_COMPILE) + TypeHandle baseHnd = (TypeHandle)baseType; + IMDInternalImport* pInternalImport = NULL; + Module* pModule = baseHnd.GetModule(); + MethodTable* pMT = NULL; + mdTypeDef tdCur = mdTypeDefNil; JIT_TO_EE_TRANSITION(); - result = NULL; // EGOR: implement here + // Look for implementations in the current Module + // TODO: scan all modules? Get hints from ILLink/R2R? + pInternalImport = pModule->GetMDImport(); + HENUMTypeDefInternalHolder hEnum(pInternalImport); + hEnum.EnumTypeDefInit(); - EE_TO_JIT_TRANSITION(); + while (pInternalImport->EnumNext(&hEnum, &tdCur)) + { + TypeHandle curClass; + EX_TRY + { + curClass = ClassLoader::LoadTypeDefOrRefThrowing(pModule, tdCur, + ClassLoader::ReturnNullIfNotFound, + ClassLoader::PermitUninstDefOrRef); + } + EX_CATCH + { + continue; + } + EX_END_CATCH(SwallowAllExceptions) - return result; + if (!curClass.IsNull()) + { + pMT = curClass.GetMethodTable(); + MethodTable* baseMT = baseHnd.GetMethodTable(); + if (pMT->ImplementsInterface(baseMT)) + { + result = static_cast(curClass.AsPtr()); + implementators++; + } + + if (implementators > 1) + { + // implentation is not unqiue - give up + break; + } + } + } + + EE_TO_JIT_TRANSITION(); +#endif + return implementators == 1 ? result : NULL; } /*********************************************************************/ From e88ec6b7b8725f08787194b970ea863174cf6d43 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Tue, 9 Jun 2020 22:29:56 +0300 Subject: [PATCH 3/4] Implement getUniqueImplementingClass --- src/coreclr/src/inc/corhdr.h | 3 ++ src/coreclr/src/jit/jitconfigvalues.h | 2 +- src/coreclr/src/vm/jitinterface.cpp | 63 ++++++++++----------------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/coreclr/src/inc/corhdr.h b/src/coreclr/src/inc/corhdr.h index abef978313a9e4..66464c8f66beb8 100644 --- a/src/coreclr/src/inc/corhdr.h +++ b/src/coreclr/src/inc/corhdr.h @@ -1862,6 +1862,9 @@ typedef enum LoadHintEnum #define DEFAULTDEPENDENCY_TYPE_W W("System.Runtime.CompilerServices.DefaultDependencyAttribute") #define DEFAULTDEPENDENCY_TYPE "System.Runtime.CompilerServices.DefaultDependencyAttribute" +#define UNIQUEIMPL_TYPE_W W("System.Runtime.CompilerServices.UniqueImplAttribute") +#define UNIQUEIMPL_TYPE "System.Runtime.CompilerServices.UniqueImplAttribute" + #define DEPENDENCY_TYPE_W W("System.Runtime.CompilerServices.DependencyAttribute") #define DEPENDENCY_TYPE "System.Runtime.CompilerServices.DependencyAttribute" diff --git a/src/coreclr/src/jit/jitconfigvalues.h b/src/coreclr/src/jit/jitconfigvalues.h index d531362543ebe0..6c261ce9102fce 100644 --- a/src/coreclr/src/jit/jitconfigvalues.h +++ b/src/coreclr/src/jit/jitconfigvalues.h @@ -397,7 +397,7 @@ CONFIG_INTEGER(JitEnableGuardedDevirtualization, W("JitEnableGuardedDevirtualiza #if defined(DEBUG) // Various policies for GuardedDevirtualization -CONFIG_INTEGER(JitGuardedDevirtualizationGuessUniqueInterface, W("JitGuardedDevirtualizationGuessUniqueInterface"), 1) +CONFIG_INTEGER(JitGuardedDevirtualizationGuessUniqueInterface, W("JitGuardedDevirtualizationGuessUniqueInterface"), 0) CONFIG_INTEGER(JitGuardedDevirtualizationGuessBestClass, W("JitGuardedDevirtualizationGuessBestClass"), 1) #endif // DEBUG diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index e9cd7935c87356..b3fb222e79b412 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -26,6 +26,7 @@ #include "dbginterface.h" #include "dllimport.h" #include "gcheaputilities.h" +#include "caparser.h" #include "comdelegate.h" #include "corprof.h" #include "eeprofinterfaces.h" @@ -9161,60 +9162,42 @@ CORINFO_CLASS_HANDLE CEEInfo::getUniqueImplementingClass(CORINFO_CLASS_HANDLE ba MODE_PREEMPTIVE; } CONTRACTL_END; - int implementators = 0; - CORINFO_CLASS_HANDLE result = NULL; + CORINFO_CLASS_HANDLE result = NULL; #if !defined(CROSSGEN_COMPILE) - TypeHandle baseHnd = (TypeHandle)baseType; - IMDInternalImport* pInternalImport = NULL; - Module* pModule = baseHnd.GetModule(); - MethodTable* pMT = NULL; - mdTypeDef tdCur = mdTypeDefNil; + TypeHandle baseHnd = (TypeHandle)baseType; + Module* pModule = baseHnd.GetModule(); + const BYTE* pbAttr = NULL; // Custom attribute data as a BYTE*. + ULONG cbAttr = NULL; // Size of custom attribute data. - JIT_TO_EE_TRANSITION(); + _ASSERTE(baseHnd.IsInterface()); - // Look for implementations in the current Module - // TODO: scan all modules? Get hints from ILLink/R2R? - pInternalImport = pModule->GetMDImport(); - HENUMTypeDefInternalHolder hEnum(pInternalImport); - hEnum.EnumTypeDefInit(); + JIT_TO_EE_TRANSITION(); - while (pInternalImport->EnumNext(&hEnum, &tdCur)) + if (!FAILED(pModule->GetMDImport()->GetCustomAttributeByName( + baseHnd.GetCl(), UNIQUEIMPL_TYPE, (const void**)&pbAttr, &cbAttr)) && pbAttr) { - TypeHandle curClass; - EX_TRY - { - curClass = ClassLoader::LoadTypeDefOrRefThrowing(pModule, tdCur, - ClassLoader::ReturnNullIfNotFound, - ClassLoader::PermitUninstDefOrRef); - } - EX_CATCH + CustomAttributeParser cap(pbAttr, cbAttr); + if (!FAILED(cap.ValidateProlog())) { - continue; - } - EX_END_CATCH(SwallowAllExceptions) - - if (!curClass.IsNull()) - { - pMT = curClass.GetMethodTable(); - MethodTable* baseMT = baseHnd.GetMethodTable(); - if (pMT->ImplementsInterface(baseMT)) - { - result = static_cast(curClass.AsPtr()); - implementators++; - } - - if (implementators > 1) + LPCUTF8 szString; + ULONG cbString; + if (!FAILED(cap.GetNonNullString(&szString, &cbString))) { - // implentation is not unqiue - give up - break; + StackSString ss(SString::Utf8, szString, cbString); + TypeHandle implHandle = TypeName::GetTypeUsingCASearchRules( + ss.GetUnicode(), pModule->GetAssembly()); + if (!implHandle.IsNull()) + { + result = static_cast(implHandle.AsPtr()); + } } } } EE_TO_JIT_TRANSITION(); #endif - return implementators == 1 ? result : NULL; + return result; } /*********************************************************************/ From a38b93db42a34ddf51e6cd4e3cd110675a0bfa0b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Wed, 10 Jun 2020 15:46:54 +0300 Subject: [PATCH 4/4] Address feedback --- src/coreclr/src/vm/jitinterface.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index b3fb222e79b412..df6e36023f1b1e 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -9184,9 +9184,20 @@ CORINFO_CLASS_HANDLE CEEInfo::getUniqueImplementingClass(CORINFO_CLASS_HANDLE ba ULONG cbString; if (!FAILED(cap.GetNonNullString(&szString, &cbString))) { - StackSString ss(SString::Utf8, szString, cbString); + // The attribute has the following layout: + // + // public Type Type { get; } + // public bool AlwaysUnique { get; } + // + // The second field is not used yet. It should tell the JIT that the App + // is not going to load/emit additional implementation for given interface + // + // signed char alwaysUnique; + // cap.GetI1(&alwaysUnique); + + StackSString stackStr(SString::Utf8, szString, cbString); TypeHandle implHandle = TypeName::GetTypeUsingCASearchRules( - ss.GetUnicode(), pModule->GetAssembly()); + stackStr.GetUnicode(), pModule->GetAssembly()); if (!implHandle.IsNull()) { result = static_cast(implHandle.AsPtr());