From 3d194a6099b43a04e2104879498ce1131ff228cd Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 14 Jul 2025 23:57:48 -0700 Subject: [PATCH 1/4] Fix invalid handle passed to RuntimeTypeHandle.GetRuntimeTypeFromHandle for synchronized methods - use method class handle --- src/coreclr/jit/flowgraph.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index 4db0f7b1ccbce1..70cfe579923c2f 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -1290,11 +1290,7 @@ GenTree* Compiler::fgGetCritSectOfStaticMethod() } else { - void *critSect = nullptr, **pCrit = nullptr; - critSect = info.compCompHnd->getMethodSync(info.compMethodHnd, (void**)&pCrit); - noway_assert((!critSect) != (!pCrit)); - - tree = gtNewIconEmbHndNode(critSect, pCrit, GTF_ICON_GLOBAL_PTR, info.compMethodHnd); + tree = gtNewIconEmbClsHndNode(info.compClassHnd); // Given the class handle, get the pointer to the Monitor. tree = gtNewHelperCallNode(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, TYP_REF, tree); From 7f800855d1f7c63f917498bcb22eb481e9d50f40 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 15 Jul 2025 00:10:41 -0700 Subject: [PATCH 2/4] Add test --- .../JitBlue/Runtime_117566/Runtime_117566.cs | 36 +++++++++++++++++++ .../Runtime_117566/Runtime_117566.csproj | 8 +++++ 2 files changed, 44 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.cs b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.cs new file mode 100644 index 00000000000000..7ca27eb30a35eb --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +// Failure calling a synchronized method in an assembly loaded in a collectible AssemblyLoadContext: +// +// Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. +// ---> System.NullReferenceException: Object reference not set to an instance of an object. +// at System.RuntimeTypeHandle.GetRuntimeTypeFromHandle(IntPtr handle) +// at Runtime_117566.Synchronized() +// at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(System.Object, IntPtr*) +// at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags) +// at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) +// at System.Reflection.MethodBase.Invoke(System.Object, System.Object[]) +// at Runtime_117566.TestEntryPoint() + +using System.Reflection; +using System.Runtime.Loader; +using System.Runtime.CompilerServices; +using Xunit; + +public class Runtime_117566 +{ + [Fact] + public static void TestEntryPoint() + { + var context = new AssemblyLoadContext("CollectibleALC", isCollectible: true); + Assembly assembly = context.LoadFromAssemblyPath(Assembly.GetExecutingAssembly().Location); + + var method = assembly.GetType(nameof(Runtime_117566)).GetMethod(nameof(Synchronized), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); + method?.Invoke(null, []); + } + + [MethodImpl(MethodImplOptions.Synchronized)] + internal static void Synchronized() + { } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj new file mode 100644 index 00000000000000..de6d5e08882e86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj @@ -0,0 +1,8 @@ + + + True + + + + + From f7a4f0bf8c1a3952ea90f14dfda243a0adb21a5b Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 15 Jul 2025 10:26:26 -0700 Subject: [PATCH 3/4] Remove getMethodSync from JIT interface --- src/coreclr/inc/corinfo.h | 6 - src/coreclr/inc/icorjitinfoimpl_generated.h | 4 - src/coreclr/inc/jiteeversionguid.h | 10 +- src/coreclr/jit/ICorJitInfo_names_generated.h | 1 - .../jit/ICorJitInfo_wrapper_generated.hpp | 10 -- .../JitInterface/CorInfoImpl_generated.cs | 110 ++++++++---------- .../ThunkGenerator/ThunkInput.txt | 1 - .../JitInterface/CorInfoImpl.ReadyToRun.cs | 5 - .../JitInterface/CorInfoImpl.RyuJit.cs | 20 ---- .../aot/jitinterface/jitinterface_generated.h | 11 -- .../tools/superpmi/superpmi-shared/lwmlist.h | 1 - .../superpmi-shared/methodcontext.cpp | 33 +----- .../superpmi/superpmi-shared/methodcontext.h | 12 +- .../superpmi-shim-collector/icorjitinfo.cpp | 9 -- .../icorjitinfo_generated.cpp | 8 -- .../icorjitinfo_generated.cpp | 7 -- .../tools/superpmi/superpmi/icorjitinfo.cpp | 7 -- src/coreclr/vm/jitinterface.cpp | 46 +------- src/coreclr/vm/jitinterface.h | 1 - 19 files changed, 59 insertions(+), 243 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 6182619dbbf77e..edcb4860dab3ca 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -3129,12 +3129,6 @@ class ICorDynamicInfo : public ICorStaticInfo CORINFO_CONST_LOOKUP * pResult ) = 0; - // get the synchronization handle that is passed to monXstatic function - virtual void* getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection = NULL - ) = 0; - // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*). // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used. virtual CorInfoHelpFunc getLazyStringLiteralHelper( diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index ee74e9c984fa98..472ada1cdd64d6 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -550,10 +550,6 @@ void getFunctionFixedEntryPoint( bool isUnsafeFunctionPointer, CORINFO_CONST_LOOKUP* pResult) override; -void* getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection) override; - CorInfoHelpFunc getLazyStringLiteralHelper( CORINFO_MODULE_HANDLE handle) override; diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 43c4c32332df8d..7043a7fa2f55ac 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -37,11 +37,11 @@ #include -constexpr GUID JITEEVersionIdentifier = { /* 5c7eb9f1-a9cb-4a35-aea6-ae93d1f54c56 */ - 0x5c7eb9f1, - 0xa9cb, - 0x4a35, - {0xae, 0xa6, 0xae, 0x93, 0xd1, 0xf5, 0x4c, 0x56} +constexpr GUID JITEEVersionIdentifier = { /* d24a67e0-9e57-4c9e-ad31-5785df2526f2 */ + 0xd24a67e0, + 0x9e57, + 0x4c9e, + {0xad, 0x31, 0x57, 0x85, 0xdf, 0x25, 0x26, 0xf2} }; #endif // JIT_EE_VERSIONING_GUID_H diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h index e8e089f0b1dd59..349725350198a8 100644 --- a/src/coreclr/jit/ICorJitInfo_names_generated.h +++ b/src/coreclr/jit/ICorJitInfo_names_generated.h @@ -136,7 +136,6 @@ DEF_CLR_API(getAddrOfCaptureThreadGlobal) DEF_CLR_API(getHelperFtn) DEF_CLR_API(getFunctionEntryPoint) DEF_CLR_API(getFunctionFixedEntryPoint) -DEF_CLR_API(getMethodSync) DEF_CLR_API(getLazyStringLiteralHelper) DEF_CLR_API(embedModuleHandle) DEF_CLR_API(embedClassHandle) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index c2a8418e30256d..7ee76ced3f8a32 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -1299,16 +1299,6 @@ void WrapICorJitInfo::getFunctionFixedEntryPoint( API_LEAVE(getFunctionFixedEntryPoint); } -void* WrapICorJitInfo::getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection) -{ - API_ENTER(getMethodSync); - void* temp = wrapHnd->getMethodSync(ftn, ppIndirection); - API_LEAVE(getMethodSync); - return temp; -} - CorInfoHelpFunc WrapICorJitInfo::getLazyStringLiteralHelper( CORINFO_MODULE_HANDLE handle) { diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index 6be49af5d42404..dd427561f98e90 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -1958,21 +1958,6 @@ private static void _getFunctionFixedEntryPoint(IntPtr thisHandle, IntPtr* ppExc } } - [UnmanagedCallersOnly] - private static void* _getMethodSync(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* ftn, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getMethodSync(ftn, ref *ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - [UnmanagedCallersOnly] private static CorInfoHelpFunc _getLazyStringLiteralHelper(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* handle) { @@ -2651,7 +2636,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 179); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 178); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_notifyMethodInfoUsage; @@ -2785,53 +2770,52 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[129] = (delegate* unmanaged)&_getHelperFtn; callbacks[130] = (delegate* unmanaged)&_getFunctionEntryPoint; callbacks[131] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[132] = (delegate* unmanaged)&_getMethodSync; - callbacks[133] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[134] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[135] = (delegate* unmanaged)&_embedClassHandle; - callbacks[136] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[137] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[138] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[139] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[140] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[141] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[142] = (delegate* unmanaged)&_GetCookieForInterpreterCalliSig; - callbacks[143] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[144] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[145] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[146] = (delegate* unmanaged)&_getCallInfo; - callbacks[147] = (delegate* unmanaged)&_getStaticFieldContent; - callbacks[148] = (delegate* unmanaged)&_getObjectContent; - callbacks[149] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[150] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[151] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[152] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[153] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[154] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[155] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[156] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[157] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[158] = (delegate* unmanaged)&_getAsyncResumptionStub; - callbacks[159] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[160] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[161] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[162] = (delegate* unmanaged)&_allocMem; - callbacks[163] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[164] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[165] = (delegate* unmanaged)&_allocGCInfo; - callbacks[166] = (delegate* unmanaged)&_setEHcount; - callbacks[167] = (delegate* unmanaged)&_setEHinfo; - callbacks[168] = (delegate* unmanaged)&_logMsg; - callbacks[169] = (delegate* unmanaged)&_doAssert; - callbacks[170] = (delegate* unmanaged)&_reportFatalError; - callbacks[171] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[172] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[173] = (delegate* unmanaged)&_recordCallSite; - callbacks[174] = (delegate* unmanaged)&_recordRelocation; - callbacks[175] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[176] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[177] = (delegate* unmanaged)&_getJitFlags; - callbacks[178] = (delegate* unmanaged)&_getSpecialCopyHelper; + callbacks[132] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[133] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[134] = (delegate* unmanaged)&_embedClassHandle; + callbacks[135] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[136] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[137] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[138] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[139] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[140] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[141] = (delegate* unmanaged)&_GetCookieForInterpreterCalliSig; + callbacks[142] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[143] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[144] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[145] = (delegate* unmanaged)&_getCallInfo; + callbacks[146] = (delegate* unmanaged)&_getStaticFieldContent; + callbacks[147] = (delegate* unmanaged)&_getObjectContent; + callbacks[148] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[149] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[150] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[151] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[152] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[153] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[157] = (delegate* unmanaged)&_getAsyncResumptionStub; + callbacks[158] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[159] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[160] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[161] = (delegate* unmanaged)&_allocMem; + callbacks[162] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[163] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[164] = (delegate* unmanaged)&_allocGCInfo; + callbacks[165] = (delegate* unmanaged)&_setEHcount; + callbacks[166] = (delegate* unmanaged)&_setEHinfo; + callbacks[167] = (delegate* unmanaged)&_logMsg; + callbacks[168] = (delegate* unmanaged)&_doAssert; + callbacks[169] = (delegate* unmanaged)&_reportFatalError; + callbacks[170] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[171] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[172] = (delegate* unmanaged)&_recordCallSite; + callbacks[173] = (delegate* unmanaged)&_recordRelocation; + callbacks[174] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[175] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[176] = (delegate* unmanaged)&_getJitFlags; + callbacks[177] = (delegate* unmanaged)&_getSpecialCopyHelper; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 7b5f8a7d79f292..18f4498a848797 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -298,7 +298,6 @@ FUNCTIONS void getHelperFtn (CorInfoHelpFunc ftnNum, CORINFO_CONST_LOOKUP* pNativeEntrypoint, CORINFO_METHOD_HANDLE *pMethod); void getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftn, REF_CORINFO_CONST_LOOKUP pResult, CORINFO_ACCESS_FLAGS accessFlags); void getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE ftn, bool isUnsafeFunctionPointer, REF_CORINFO_CONST_LOOKUP pResult); - void* getMethodSync(CORINFO_METHOD_HANDLE ftn, void **ppIndirection); CorInfoHelpFunc getLazyStringLiteralHelper(CORINFO_MODULE_HANDLE handle); CORINFO_MODULE_HANDLE embedModuleHandle(CORINFO_MODULE_HANDLE handle, void **ppIndirection); CORINFO_CLASS_HANDLE embedClassHandle(CORINFO_CLASS_HANDLE handle, 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 3e3c1762f1823e..afa3677e648c68 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -2954,11 +2954,6 @@ private void getMethodVTableOffset(CORINFO_METHOD_STRUCT_* method, ref uint offs private void expandRawHandleIntrinsic(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, ref CORINFO_GENERICHANDLE_RESULT pResult) { throw new NotImplementedException("expandRawHandleIntrinsic"); } - private void* getMethodSync(CORINFO_METHOD_STRUCT_* ftn, ref void* ppIndirection) - { - throw new RequiresRuntimeJitException($"{MethodBeingCompiled} -> {nameof(getMethodSync)}"); - } - private byte[] _bbCounts; partial void findKnownBBCountBlock(ref BlockType blockType, void* location, ref int offset) 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 65362e23982abe..bb0d15efae0cc3 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -1874,26 +1874,6 @@ private uint getMethodAttribs(CORINFO_METHOD_STRUCT_* ftn) return getMethodAttribsInternal(HandleToObject(ftn)); } - private void* getMethodSync(CORINFO_METHOD_STRUCT_* ftn, ref void* ppIndirection) - { - MethodDesc method = HandleToObject(ftn); - TypeDesc type = method.OwningType; - ISymbolNode methodSync = _compilation.NecessaryTypeSymbolIfPossible(type); - - void* result = (void*)ObjectToHandle(methodSync); - - if (methodSync.RepresentsIndirectionCell) - { - ppIndirection = result; - return null; - } - else - { - ppIndirection = null; - return result; - } - } - private unsafe HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_STRUCT_* ftnHnd, PgoInstrumentationSchema* pSchema, uint countSchemaItems, byte** pInstrumentationData) { throw new NotImplementedException("allocPgoInstrumentationBySchema"); diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index f72f9cdeef2ac4..6376292d538738 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -143,7 +143,6 @@ struct JitInterfaceCallbacks void (* getHelperFtn)(void * thisHandle, CorInfoExceptionClass** ppException, CorInfoHelpFunc ftnNum, CORINFO_CONST_LOOKUP* pNativeEntrypoint, 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); CorInfoHelpFunc (* getLazyStringLiteralHelper)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE handle); CORINFO_MODULE_HANDLE (* embedModuleHandle)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE handle, void** ppIndirection); CORINFO_CLASS_HANDLE (* embedClassHandle)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE handle, void** ppIndirection); @@ -1480,16 +1479,6 @@ class JitInterfaceWrapper : public ICorJitInfo if (pException != nullptr) throw pException; } - virtual void* getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection) -{ - CorInfoExceptionClass* pException = nullptr; - void* temp = _callbacks->getMethodSync(_thisHandle, &pException, ftn, ppIndirection); - if (pException != nullptr) throw pException; - return temp; -} - virtual CorInfoHelpFunc getLazyStringLiteralHelper( CORINFO_MODULE_HANDLE handle) { diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index b65429f3153bd4..595f376ff735fe 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -115,7 +115,6 @@ LWM(HaveSameMethodDefinition, DLDL, DWORD) LWM(GetTypeDefinition, DWORDLONG, DWORDLONG) LWM(GetMethodNameFromMetadata, Agnostic_CORINFO_METHODNAME_TOKENin, Agnostic_CORINFO_METHODNAME_TOKENout) LWM(GetMethodSig, DLDL, Agnostic_CORINFO_SIG_INFO) -LWM(GetMethodSync, DWORDLONG, DLDL) LWM(GetMethodVTableOffset, DWORDLONG, DDD) LWM(GetNewArrHelper, DWORDLONG, DWORD) LWM(GetNewHelper, DWORDLONG, DDD) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index bfdab057de446b..152e1299e89465 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -2396,7 +2396,7 @@ void MethodContext::recGetHelperFtn(CorInfoHelpFunc ftnNum, CORINFO_CONST_LOOKUP } void MethodContext::dmpGetHelperFtn(DWORD key, Agnostic_GetHelperFtn value) { - printf("GetHelperFtn key ftn-%u nativeEntrypoint {%s}, helperMethod-%016" PRIX64 "", key, + printf("GetHelperFtn key ftn-%u nativeEntrypoint {%s}, helperMethod-%016" PRIX64 "", key, SpmiDumpHelper::DumpAgnostic_CORINFO_CONST_LOOKUP(value.helperLookup).c_str(), value.helperMethod); } @@ -5504,37 +5504,6 @@ void MethodContext::repFindCallSiteSig(CORINFO_MODULE_HANDLE module, *sig = SpmiRecordsHelper::Restore_CORINFO_SIG_INFO(value, FindCallSiteSig, SigInstHandleMap, cr->getOrCreateMemoryTracker()); } -void MethodContext::recGetMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection, void* result) -{ - if (GetMethodSync == nullptr) - GetMethodSync = new LightWeightMap(); - DLDL value; - if (ppIndirection != nullptr) - value.A = CastPointer(*ppIndirection); - else - value.A = 0; - value.B = CastPointer(result); - - DWORDLONG key = CastHandle(ftn); - GetMethodSync->Add(key, value); - DEBUG_REC(dmpGetMethodSync(key, value)); -} -void MethodContext::dmpGetMethodSync(DWORDLONG key, DLDL value) -{ - printf("GetMethodSync key %016" PRIX64 ", value pp-%016" PRIX64 " res-%016" PRIX64 "", key, value.A, value.B); -} -void* MethodContext::repGetMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection) -{ - DWORDLONG key = CastHandle(ftn); - DLDL value = LookupByKeyOrMiss(GetMethodSync, key, ": key %016" PRIX64 "", key); - - DEBUG_REP(dmpGetMethodSync(key, value)); - - if (ppIndirection != nullptr) - *ppIndirection = (void*)value.A; - return (void*)value.B; -} - void MethodContext::recGetVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection, CORINFO_VARARGS_HANDLE result) { if (GetVarArgsHandle == nullptr) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index 06c1c1e33bd842..d7ce4ed4069f69 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -460,13 +460,13 @@ class MethodContext void dmpGetUnboxedEntry(DWORDLONG key, DLD value); CORINFO_METHOD_HANDLE repGetUnboxedEntry(CORINFO_METHOD_HANDLE ftn, bool* requiresInstMethodTableArg); - void recGetInstantiatedEntry(CORINFO_METHOD_HANDLE ftn, + void recGetInstantiatedEntry(CORINFO_METHOD_HANDLE ftn, CORINFO_METHOD_HANDLE methodHandle, CORINFO_CLASS_HANDLE classHandle, CORINFO_METHOD_HANDLE result); void dmpGetInstantiatedEntry(DWORDLONG key, const Agnostic_GetInstantiatedEntryResult& value); - CORINFO_METHOD_HANDLE repGetInstantiatedEntry(CORINFO_METHOD_HANDLE ftn, - CORINFO_METHOD_HANDLE* methodHandle, + CORINFO_METHOD_HANDLE repGetInstantiatedEntry(CORINFO_METHOD_HANDLE ftn, + CORINFO_METHOD_HANDLE* methodHandle, CORINFO_CLASS_HANDLE* classHandle); void recGetDefaultComparerClass(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result); @@ -713,10 +713,6 @@ class MethodContext CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* sig); - void recGetMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection, void* result); - void dmpGetMethodSync(DWORDLONG key, DLDL value); - void* repGetMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection); - void recGetVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection, CORINFO_VARARGS_HANDLE result); void dmpGetVarArgsHandle(const GetVarArgsHandleValue& key, DLDL value); CORINFO_VARARGS_HANDLE repGetVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection); @@ -1068,7 +1064,7 @@ enum mcPackets Packet_GetMethodHash = 73, Packet_GetMethodInfo = 74, Packet_GetMethodSig = 76, - Packet_GetMethodSync = 77, + // Packet_GetMethodSync = 77, Packet_GetMethodVTableOffset = 78, Packet_GetNewArrHelper = 79, Packet_GetNewHelper = 80, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index eab692b4d37cab..bc2fc0131515f9 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1504,15 +1504,6 @@ void interceptor_ICJI::getFunctionFixedEntryPoint( mc->recGetFunctionFixedEntryPoint(ftn, pResult); } -// get the synchronization handle that is passed to monXstatic function -void* interceptor_ICJI::getMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection) -{ - mc->cr->AddCall("getMethodSync"); - void* temp = original_ICorJitInfo->getMethodSync(ftn, ppIndirection); - mc->recGetMethodSync(ftn, ppIndirection, temp); - return temp; -} - // These entry points must be called if a handle is being embedded in // the code to be passed to a JIT helper function. (as opposed to just // being passed back into the ICorInfo interface.) 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 ffcf2dc749695c..615f8c9dca1265 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -1069,14 +1069,6 @@ void interceptor_ICJI::getFunctionFixedEntryPoint( original_ICorJitInfo->getFunctionFixedEntryPoint(ftn, isUnsafeFunctionPointer, pResult); } -void* interceptor_ICJI::getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection) -{ - mcs->AddCall("getMethodSync"); - return original_ICorJitInfo->getMethodSync(ftn, ppIndirection); -} - CorInfoHelpFunc interceptor_ICJI::getLazyStringLiteralHelper( CORINFO_MODULE_HANDLE handle) { 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 718959681da80a..c4caa76a89518c 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -937,13 +937,6 @@ void interceptor_ICJI::getFunctionFixedEntryPoint( original_ICorJitInfo->getFunctionFixedEntryPoint(ftn, isUnsafeFunctionPointer, pResult); } -void* interceptor_ICJI::getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void** ppIndirection) -{ - return original_ICorJitInfo->getMethodSync(ftn, ppIndirection); -} - CorInfoHelpFunc interceptor_ICJI::getLazyStringLiteralHelper( CORINFO_MODULE_HANDLE handle) { diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index fafda8ea9fda18..c40cd89f854fe3 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -1299,13 +1299,6 @@ void MyICJI::getFunctionFixedEntryPoint( jitInstance->mc->repGetFunctionFixedEntryPoint(ftn, isUnsafeFunctionPointer, pResult); } -// get the synchronization handle that is passed to monXstatic function -void* MyICJI::getMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection) -{ - jitInstance->mc->cr->AddCall("getMethodSync"); - return jitInstance->mc->repGetMethodSync(ftn, ppIndirection); -} - // These entry points must be called if a handle is being embedded in // the code to be passed to a JIT helper function. (as opposed to just // being passed back into the ICorInfo interface.) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 1a9556a77228e7..06645f6701ad44 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -8664,7 +8664,7 @@ bool CEEInfo::resolveVirtualMethodHelper(CORINFO_DEVIRTUALIZATION_INFO * info) else if (pObjMT->IsSharedByGenericInstantiations() || pBaseMT->IsSharedByGenericInstantiations()) { MethodTable* pCanonBaseMT = pBaseMT->GetCanonicalMethodTable(); - + // Check to see if the derived class implements multiple variants of a matching interface. // If so, we cannot predict exactly which implementation is in use here. MethodTable::InterfaceMapIterator it = pObjMT->IterateInterfaceMap(); @@ -8687,7 +8687,7 @@ bool CEEInfo::resolveVirtualMethodHelper(CORINFO_DEVIRTUALIZATION_INFO * info) } } } - + if (canonicallyMatchingInterfacesFound == 0) { // The object doesn't implement the interface... @@ -12389,41 +12389,6 @@ CORINFO_CLASS_HANDLE CEECodeGenInfo::getStaticFieldCurrentClass(CORINFO_FIELD_HA return result; } -/*********************************************************************/ -static void *GetClassSync(MethodTable *pMT) -{ - STANDARD_VM_CONTRACT; - - GCX_COOP(); - - OBJECTREF ref = pMT->GetManagedClassObject(); - return (void*)ref->GetSyncBlock()->GetMonitor(); -} - -/*********************************************************************/ -void* CEECodeGenInfo::getMethodSync(CORINFO_METHOD_HANDLE ftnHnd, - void **ppIndirection) -{ - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } CONTRACTL_END; - - void * result = NULL; - - if (ppIndirection != NULL) - *ppIndirection = NULL; - - JIT_TO_EE_TRANSITION(); - - result = GetClassSync((GetMethod(ftnHnd))->GetMethodTable()); - - EE_TO_JIT_TRANSITION(); - - return result; -} - CORINFO_METHOD_INFO* CEECodeGenInfo::getMethodInfoInternal() { LIMITED_METHOD_CONTRACT; @@ -14889,13 +14854,6 @@ CORINFO_CLASS_HANDLE CEEInfo::getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE fi UNREACHABLE(); // only called on derived class. } -void* CEEInfo::getMethodSync(CORINFO_METHOD_HANDLE ftnHnd, - void **ppIndirection) -{ - LIMITED_METHOD_CONTRACT; - UNREACHABLE(); // only called on derived class. -} - HRESULT CEEInfo::allocPgoInstrumentationBySchema( CORINFO_METHOD_HANDLE ftnHnd, /* IN */ PgoInstrumentationSchema* pSchema, /* IN/OUT */ diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index 7116f37690d1dd..9ff07f1312fa7c 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -579,7 +579,6 @@ class CEECodeGenInfo : public CEEInfo InfoAccessType constructStringLiteral(CORINFO_MODULE_HANDLE scopeHnd, mdToken metaTok, void **ppValue) override; InfoAccessType emptyStringLiteral(void ** ppValue) override; CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative) override; - void* getMethodSync(CORINFO_METHOD_HANDLE ftnHnd, void **ppIndirection) override; CORINFO_METHOD_INFO* getMethodInfoInternal(); CORJIT_FLAGS* getJitFlagsInternal(); From 47fb7c0a119a0d07d908269f8b1f83f2e70db69f Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 15 Jul 2025 12:10:41 -0700 Subject: [PATCH 4/4] Update src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj Co-authored-by: Jan Kotas --- .../JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj index de6d5e08882e86..1c287f51f440e2 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj +++ b/src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj @@ -1,6 +1,8 @@ True + + true