From 6c0cd9e701265dc7a20667323669b72b711b18a8 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 16 Oct 2025 18:48:52 +0200 Subject: [PATCH 1/8] Fix feature code versioning support across various components --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 86 ++++++++++++------------ src/coreclr/debug/daccess/dacdbiimpl.h | 8 ++- src/coreclr/debug/daccess/request.cpp | 18 +++++ src/coreclr/debug/di/module.cpp | 3 +- src/coreclr/debug/di/rsfunction.cpp | 14 +++- src/coreclr/debug/di/rspriv.h | 16 +++++ src/coreclr/debug/di/rsstackwalk.cpp | 4 ++ src/coreclr/debug/di/rsthread.cpp | 33 +++++++++ src/coreclr/debug/ee/debugger.cpp | 29 +++++++- src/coreclr/debug/ee/debugger.h | 2 + src/coreclr/debug/ee/functioninfo.cpp | 9 ++- src/coreclr/debug/inc/dacdbiinterface.h | 2 + src/coreclr/debug/inc/dbgipcevents.h | 2 + src/coreclr/inc/dacvars.h | 2 + src/coreclr/vm/eventtrace.cpp | 12 ++++ src/coreclr/vm/jitinterface.cpp | 2 + src/coreclr/vm/perfmap.cpp | 9 +-- 17 files changed, 192 insertions(+), 59 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 33272e4546d3a1..ef09f202cc5592 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -7153,6 +7153,7 @@ HRESULT DacDbiInterfaceImpl::GetReJitInfo(VMPTR_Module vmModule, mdMethodDef met return S_OK; } +#ifdef FEATURE_CODE_VERSIONING HRESULT DacDbiInterfaceImpl::GetActiveRejitILCodeVersionNode(VMPTR_Module vmModule, mdMethodDef methodTk, OUT VMPTR_ILCodeVersionNode* pVmILCodeVersionNode) { DD_ENTER_MAY_THROW; @@ -7183,34 +7184,6 @@ HRESULT DacDbiInterfaceImpl::GetActiveRejitILCodeVersionNode(VMPTR_Module vmModu return S_OK; } -HRESULT DacDbiInterfaceImpl::GetReJitInfo(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_ReJitInfo* pvmReJitInfo) -{ - DD_ENTER_MAY_THROW; - _ASSERTE(!"You shouldn't be calling this - use GetNativeCodeVersionNode instead"); - return S_OK; -} - -HRESULT DacDbiInterfaceImpl::AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled) -{ - DD_ENTER_MAY_THROW; -#ifdef FEATURE_REJIT - PTR_Module pModule = vmModule.GetDacPtr(); - if (pModule == NULL || pOptimizationsDisabled == NULL || TypeFromToken(methodTk) != mdtMethodDef) - { - return E_INVALIDARG; - } - { - CodeVersionManager * pCodeVersionManager = pModule->GetCodeVersionManager(); - ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodTk); - *pOptimizationsDisabled = activeILVersion.IsDeoptimized(); - } -#else - *pOptimizationsDisabled = FALSE; -#endif - - return S_OK; -} - HRESULT DacDbiInterfaceImpl::GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_NativeCodeVersionNode* pVmNativeCodeVersionNode) { DD_ENTER_MAY_THROW; @@ -7227,13 +7200,6 @@ HRESULT DacDbiInterfaceImpl::GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, return S_OK; } -HRESULT DacDbiInterfaceImpl::GetSharedReJitInfo(VMPTR_ReJitInfo vmReJitInfo, OUT VMPTR_SharedReJitInfo* pvmSharedReJitInfo) -{ - DD_ENTER_MAY_THROW; - _ASSERTE(!"You shouldn't be calling this - use GetLCodeVersionNode instead"); - return S_OK; -} - HRESULT DacDbiInterfaceImpl::GetILCodeVersionNode(VMPTR_NativeCodeVersionNode vmNativeCodeVersionNode, VMPTR_ILCodeVersionNode* pVmILCodeVersionNode) { DD_ENTER_MAY_THROW; @@ -7258,13 +7224,6 @@ HRESULT DacDbiInterfaceImpl::GetILCodeVersionNode(VMPTR_NativeCodeVersionNode vm return S_OK; } -HRESULT DacDbiInterfaceImpl::GetSharedReJitInfoData(VMPTR_SharedReJitInfo vmSharedReJitInfo, DacSharedReJitInfo* pData) -{ - DD_ENTER_MAY_THROW; - _ASSERTE(!"You shouldn't be calling this - use GetILCodeVersionNodeData instead"); - return S_OK; -} - HRESULT DacDbiInterfaceImpl::GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode vmILCodeVersionNode, DacSharedReJitInfo* pData) { DD_ENTER_MAY_THROW; @@ -7289,6 +7248,49 @@ HRESULT DacDbiInterfaceImpl::GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode vm #endif return S_OK; } +#endif // FEATURE_CODE_VERSIONING + +HRESULT DacDbiInterfaceImpl::GetReJitInfo(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_ReJitInfo* pvmReJitInfo) +{ + DD_ENTER_MAY_THROW; + _ASSERTE(!"You shouldn't be calling this - use GetNativeCodeVersionNode instead"); + return S_OK; +} + +HRESULT DacDbiInterfaceImpl::AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled) +{ + DD_ENTER_MAY_THROW; +#ifdef FEATURE_REJIT + PTR_Module pModule = vmModule.GetDacPtr(); + if (pModule == NULL || pOptimizationsDisabled == NULL || TypeFromToken(methodTk) != mdtMethodDef) + { + return E_INVALIDARG; + } + { + CodeVersionManager * pCodeVersionManager = pModule->GetCodeVersionManager(); + ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodTk); + *pOptimizationsDisabled = activeILVersion.IsDeoptimized(); + } +#else + *pOptimizationsDisabled = FALSE; +#endif + + return S_OK; +} + +HRESULT DacDbiInterfaceImpl::GetSharedReJitInfo(VMPTR_ReJitInfo vmReJitInfo, OUT VMPTR_SharedReJitInfo* pvmSharedReJitInfo) +{ + DD_ENTER_MAY_THROW; + _ASSERTE(!"You shouldn't be calling this - use GetLCodeVersionNode instead"); + return S_OK; +} + +HRESULT DacDbiInterfaceImpl::GetSharedReJitInfoData(VMPTR_SharedReJitInfo vmSharedReJitInfo, DacSharedReJitInfo* pData) +{ + DD_ENTER_MAY_THROW; + _ASSERTE(!"You shouldn't be calling this - use GetILCodeVersionNodeData instead"); + return S_OK; +} HRESULT DacDbiInterfaceImpl::GetDefinesBitField(ULONG32 *pDefines) { diff --git a/src/coreclr/debug/daccess/dacdbiimpl.h b/src/coreclr/debug/daccess/dacdbiimpl.h index c1ae09a3feaf0a..ed5c379b525331 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.h +++ b/src/coreclr/debug/daccess/dacdbiimpl.h @@ -151,14 +151,16 @@ class DacDbiInterfaceImpl : void GetGCHeapInformation(COR_HEAPINFO * pHeapInfo); HRESULT GetPEFileMDInternalRW(VMPTR_PEAssembly vmPEAssembly, OUT TADDR* pAddrMDInternalRW); HRESULT GetReJitInfo(VMPTR_Module vmModule, mdMethodDef methodTk, OUT VMPTR_ReJitInfo* pReJitInfo); +#ifdef FEATURE_CODE_VERSIONING HRESULT GetActiveRejitILCodeVersionNode(VMPTR_Module vmModule, mdMethodDef methodTk, OUT VMPTR_ILCodeVersionNode* pVmILCodeVersionNode); + HRESULT GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_NativeCodeVersionNode* pVmNativeCodeVersionNode); + HRESULT GetILCodeVersionNode(VMPTR_NativeCodeVersionNode vmNativeCodeVersionNode, VMPTR_ILCodeVersionNode* pVmILCodeVersionNode); + HRESULT GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode vmILCodeVersionNode, DacSharedReJitInfo* pData); +#endif // FEATURE_CODE_VERSIONING HRESULT GetReJitInfo(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_ReJitInfo* pReJitInfo); HRESULT AreOptimizationsDisabled(VMPTR_Module vmModule, mdMethodDef methodTk, OUT BOOL* pOptimizationsDisabled); - HRESULT GetNativeCodeVersionNode(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeStartAddress, OUT VMPTR_NativeCodeVersionNode* pVmNativeCodeVersionNode); HRESULT GetSharedReJitInfo(VMPTR_ReJitInfo vmReJitInfo, VMPTR_SharedReJitInfo* pSharedReJitInfo); - HRESULT GetILCodeVersionNode(VMPTR_NativeCodeVersionNode vmNativeCodeVersionNode, VMPTR_ILCodeVersionNode* pVmILCodeVersionNode); HRESULT GetSharedReJitInfoData(VMPTR_SharedReJitInfo sharedReJitInfo, DacSharedReJitInfo* pData); - HRESULT GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode vmILCodeVersionNode, DacSharedReJitInfo* pData); HRESULT GetDefinesBitField(ULONG32 *pDefines); HRESULT GetMDStructuresVersion(ULONG32* pMDStructuresVersion); HRESULT EnableGCNotificationEvents(BOOL fEnable); diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index b20be8fd8eca41..a5c1302393ae69 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -4650,6 +4650,7 @@ HRESULT ClrDataAccess::GetClrNotification(CLRDATA_ADDRESS arguments[], int count HRESULT ClrDataAccess::GetPendingReJITID(CLRDATA_ADDRESS methodDesc, int *pRejitId) { +#ifdef FEATURE_CODE_VERSIONING if (methodDesc == 0 || pRejitId == NULL) { return E_INVALIDARG; @@ -4679,9 +4680,14 @@ HRESULT ClrDataAccess::GetPendingReJITID(CLRDATA_ADDRESS methodDesc, int *pRejit SOSDacLeave(); return hr; +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING } HRESULT ClrDataAccess::GetReJITInformation(CLRDATA_ADDRESS methodDesc, int rejitId, struct DacpReJitData2 *pReJitData) +{ +#ifdef FEATURE_CODE_VERSIONING { if (methodDesc == 0 || rejitId < 0 || pReJitData == NULL) { @@ -4728,10 +4734,15 @@ HRESULT ClrDataAccess::GetReJITInformation(CLRDATA_ADDRESS methodDesc, int rejit return hr; } +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING +} HRESULT ClrDataAccess::GetProfilerModifiedILInformation(CLRDATA_ADDRESS methodDesc, struct DacpProfilerILData *pILData) { +#ifdef FEATURE_CODE_VERSIONING if (methodDesc == 0 || pILData == NULL) { return E_INVALIDARG; @@ -4763,10 +4774,14 @@ HRESULT ClrDataAccess::GetProfilerModifiedILInformation(CLRDATA_ADDRESS methodDe SOSDacLeave(); return hr; +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING } HRESULT ClrDataAccess::GetMethodsWithProfilerModifiedIL(CLRDATA_ADDRESS mod, CLRDATA_ADDRESS *methodDescs, int cMethodDescs, int *pcMethodDescs) { +#ifdef FEATURE_CODE_VERSIONING if (mod == 0 || methodDescs == NULL || cMethodDescs == 0 || pcMethodDescs == NULL) { return E_INVALIDARG; @@ -4814,6 +4829,9 @@ HRESULT ClrDataAccess::GetMethodsWithProfilerModifiedIL(CLRDATA_ADDRESS mod, CLR SOSDacLeave(); return hr; +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING } HRESULT ClrDataAccess::GetNumberGenerations(unsigned int *pGenerations) diff --git a/src/coreclr/debug/di/module.cpp b/src/coreclr/debug/di/module.cpp index cdbed5137fd99d..b9a832f41761e6 100644 --- a/src/coreclr/debug/di/module.cpp +++ b/src/coreclr/debug/di/module.cpp @@ -3258,7 +3258,7 @@ HRESULT CordbILCode::CreateNativeBreakpoint(ICorDebugFunctionBreakpoint **ppBrea } - +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode::CordbReJitILCode(CordbFunction *pFunction, SIZE_T encVersion, VMPTR_ILCodeVersionNode vmILCodeVersionNode) : CordbILCode(pFunction, TargetBuffer(), encVersion, mdSignatureNil, VmPtrToCookie(vmILCodeVersionNode)), m_cClauses(0), @@ -3544,6 +3544,7 @@ HRESULT CordbReJitILCode::GetInstrumentedILMap(ULONG32 cMap, ULONG32 *pcMap, COR } return S_OK; } +#endif // FEATURE_CODE_VERSIONING // FindNativeInfoInILVariableArray // Linear search through an array of NativeVarInfos, to find the variable of index dwIndex, valid diff --git a/src/coreclr/debug/di/rsfunction.cpp b/src/coreclr/debug/di/rsfunction.cpp index 0dc6cd2b8531df..84688137a7f369 100644 --- a/src/coreclr/debug/di/rsfunction.cpp +++ b/src/coreclr/debug/di/rsfunction.cpp @@ -42,8 +42,10 @@ CordbFunction::CordbFunction(CordbModule * m, m_fIsNativeImpl(kUnknownImpl), m_fCachedMethodValuesValid(FALSE), m_argCountCached(0), - m_fIsStaticCached(FALSE), - m_reJitILCodes(1) + m_fIsStaticCached(FALSE) +#ifdef FEATURE_CODE_VERSIONING + , m_reJitILCodes(1) +#endif // FEATURE_CODE_VERSIONING { m_methodSigParserCached = SigParser(NULL, 0); @@ -108,7 +110,9 @@ void CordbFunction::Neuter() m_pClass = NULL; m_nativeCode.Clear(); +#ifdef FEATURE_CODE_VERSIONING m_reJitILCodes.NeuterAndClear(GetProcess()->GetProcessLock()); +#endif // FEATURE_CODE_VERSIONING CordbBase::Neuter(); } @@ -559,6 +563,7 @@ HRESULT CordbFunction::GetVersionNumber(ULONG32 *pnVersion) //----------------------------------------------------------------------------- HRESULT CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedILCode) { +#ifdef FEATURE_CODE_VERSIONING HRESULT hr = S_OK; VALIDATE_POINTER_TO_OBJECT(ppReJitedILCode, ICorDebugILCode **); PUBLIC_API_BEGIN(this); @@ -576,6 +581,9 @@ HRESULT CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedIL } PUBLIC_API_END(hr); return hr; +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING } //----------------------------------------------------------------------------- @@ -1274,6 +1282,7 @@ VOID CordbFunction::NotifyCodeCreated(CordbNativeCode* nativeCode) // If the CordbReJitILCode doesn't exist, it creates it. // // +#ifdef FEATURE_CODE_VERSIONING HRESULT CordbFunction::LookupOrCreateReJitILCode(VMPTR_ILCodeVersionNode vmILCodeVersionNode, CordbReJitILCode** ppILCode) { INTERNAL_API_ENTRY(this); @@ -1298,3 +1307,4 @@ HRESULT CordbFunction::LookupOrCreateReJitILCode(VMPTR_ILCodeVersionNode vmILCod *ppILCode = pILCode; return S_OK; } +#endif // FEATURE_CODE_VERSIONING diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index 33d54ee398199a..e0e1052aebdea8 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -109,7 +109,9 @@ class Instantiation; class CordbType; class CordbNativeCode; class CordbILCode; +#ifdef FEATURE_CODE_VERSIONING class CordbReJitILCode; +#endif // FEATURE_CODE_VERSIONING class CordbEval; class CordbMDA; @@ -5496,9 +5498,11 @@ class CordbFunction : public CordbBase, // Get the existing IL code object HRESULT GetILCode(CordbILCode ** ppCode); +#ifdef FEATURE_CODE_VERSIONING // Finds or creates an ILCode for a given rejit request HRESULT LookupOrCreateReJitILCode(VMPTR_ILCodeVersionNode vmILCodeVersionNode, CordbReJitILCode** ppILCode); +#endif // FEATURE_CODE_VERSIONING #ifdef FEATURE_METADATA_UPDATER @@ -5613,9 +5617,11 @@ class CordbFunction : public CordbBase, // Only valid if m_fCachedMethodValuesValid is set. BOOL m_fIsStaticCached; +#ifdef FEATURE_CODE_VERSIONING // A collection, indexed by VMPTR_SharedReJitInfo, of IL code for rejit requests // The collection is filled lazily by LookupOrCreateReJitILCode CordbSafeHashTable m_reJitILCodes; +#endif // FEATURE_CODE_VERSIONING }; //----------------------------------------------------------------------------- @@ -5833,6 +5839,7 @@ class CordbILCode : public CordbCode }; // class CordbILCode +#ifdef FEATURE_CODE_VERSIONING /* ------------------------------------------------------------------------- * * CordbReJitILCode class * This class represents an IL code blob for a particular EnC version and @@ -5878,6 +5885,7 @@ class CordbReJitILCode : public CordbILCode, ULONG32 m_cILMap; NewArrayHolder m_pILMap; }; +#endif // FEATURE_CODE_VERSIONING /* ------------------------------------------------------------------------- * * CordbNativeCode class. These correspond to MethodDesc's on the left-side. @@ -7368,7 +7376,11 @@ class CordbJITILFrame : public CordbBase, public ICorDebugILFrame, public ICorDe GENERICS_TYPE_TOKEN exactGenericArgsToken, DWORD dwExactGenericArgsTokenIndex, bool fVarArgFnx, +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode * pReJitCode, +#else + void * pReJitCode, +#endif // FEATURE_CODE_VERSIONING bool fAdjustedIP); HRESULT Init(); virtual ~CordbJITILFrame(); @@ -7479,7 +7491,9 @@ class CordbJITILFrame : public CordbBase, public ICorDebugILFrame, public ICorDe static HRESULT BuildInstantiationForCallsite(CordbModule *pModule, NewArrayHolder &types, Instantiation &inst, Instantiation *currentInstantiation, mdToken targetClass, SigParser funcGenerics); CordbILCode* GetOriginalILCode(); +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode* GetReJitILCode(); +#endif // FEATURE_CODE_VERSIONING void AdjustIPAfterException(); private: @@ -7546,8 +7560,10 @@ class CordbJITILFrame : public CordbBase, public ICorDebugILFrame, public ICorDe // IL Variable index of the Generics Arg Token. DWORD m_dwFrameParamsTokenIndex; +#ifdef FEATURE_CODE_VERSIONING // if this frame is instrumented with rejit, this will point to the instrumented IL code RSSmartPtr m_pReJitCode; +#endif // FEATURE_CODE_VERSIONING BOOL m_adjustedIP; }; diff --git a/src/coreclr/debug/di/rsstackwalk.cpp b/src/coreclr/debug/di/rsstackwalk.cpp index 8fdcf2efc5d255..b94110ff786ff5 100644 --- a/src/coreclr/debug/di/rsstackwalk.cpp +++ b/src/coreclr/debug/di/rsstackwalk.cpp @@ -750,6 +750,7 @@ HRESULT CordbStackWalk::GetFrameWorker(ICorDebugFrame ** ppFrame) // I'm not sure if ignoring rejit for mini-dumps is the right call long term, but we aren't doing // anything special to collect the memory at dump time so we better be prepared to not fetch it here. // We'll attempt to treat it as not being instrumented, though I suspect the abstraction is leaky. +#ifdef FEATURE_CODE_VERSIONING RSSmartPtr pReJitCode; EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY { @@ -766,6 +767,9 @@ HRESULT CordbStackWalk::GetFrameWorker(ICorDebugFrame ** ppFrame) } } EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY +#else + void* pReJitCode = NULL; +#endif // FEATURE_CODE_VERSIONING diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 28703f55ed71d7..d40e5a87e3fbd6 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -4956,17 +4956,25 @@ HRESULT CordbValueEnum::Init() { // Get the locals signature. ULONG localsCount; +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode* pCode = jil->GetReJitILCode(); +#else + void* pCode = NULL; +#endif // FEATURE_CODE_VERSIONING if (pCode == NULL) { m_iMax = 0; } else { +#ifdef FEATURE_CODE_VERSIONING IfFailRet(pCode->GetLocalVarSig(NULL, &localsCount)); // Grab the number of locals for the size of the enumeration. m_iMax = localsCount; +#else + m_iMax = 0; +#endif // FEATURE_CODE_VERSIONING } break; } @@ -7514,7 +7522,11 @@ CordbJITILFrame::CordbJITILFrame(CordbNativeFrame * pNativeFrame, GENERICS_TYPE_TOKEN exactGenericArgsToken, DWORD dwExactGenericArgsTokenIndex, bool fVarArgFnx, +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode * pRejitCode, +#else + void * pRejitCode, +#endif // FEATURE_CODE_VERSIONING bool fAdjustedIP) : CordbBase(pNativeFrame->GetProcess(), 0, enumCordbJITILFrame), m_nativeFrame(pNativeFrame), @@ -7530,7 +7542,9 @@ CordbJITILFrame::CordbJITILFrame(CordbNativeFrame * pNativeFrame, m_genericArgsLoaded(false), m_frameParamsToken(exactGenericArgsToken), m_dwFrameParamsTokenIndex(dwExactGenericArgsTokenIndex), +#ifdef FEATURE_CODE_VERSIONING m_pReJitCode(pRejitCode), +#endif // FEATURE_CODE_VERSIONING m_adjustedIP(fAdjustedIP) { // We'll initialize the SigParser in CordbJITILFrame::Init(). @@ -7743,7 +7757,9 @@ void CordbJITILFrame::Neuter() m_rgbSigParserBuf = NULL; } +#ifdef FEATURE_CODE_VERSIONING m_pReJitCode.Clear(); +#endif // FEATURE_CODE_VERSIONING // If this class ever inherits from the CordbFrame we'll need a call // to CordbFrame::Neuter() here instead of to CordbBase::Neuter(); @@ -9049,8 +9065,13 @@ HRESULT CordbJITILFrame::GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICo if (flags != ILCODE_ORIGINAL_IL && flags != ILCODE_REJIT_IL) return E_INVALIDARG; +#ifdef FEATURE_CODE_VERSIONING if (flags == ILCODE_REJIT_IL && m_pReJitCode == NULL) return E_INVALIDARG; +#else + if (flags == ILCODE_REJIT_IL) + return E_INVALIDARG; +#endif // FEATURE_CODE_VERSIONING const ICorDebugInfo::NativeVarInfo *pNativeInfo; @@ -9081,7 +9102,11 @@ HRESULT CordbJITILFrame::GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICo // Get the type of this argument from the function CordbType *type; +#ifdef FEATURE_CODE_VERSIONING CordbILCode* pActiveCode = m_pReJitCode != NULL ? m_pReJitCode : m_ilCode; +#else + CordbILCode* pActiveCode = m_ilCode; +#endif // FEATURE_CODE_VERSIONING hr = pActiveCode->GetLocalVariableType(dwIndex, &(this->m_genericArgs), &type); IfFailThrow(hr); @@ -9092,6 +9117,7 @@ HRESULT CordbJITILFrame::GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICo // (GetLocalVariableType will return E_INVALIDARG if not) // b) the type of local in the original signature matches the type of local in the instrumented signature // (the code below will return CORDBG_E_IL_VAR_NOT_AVAILABLE) +#ifdef FEATURE_CODE_VERSIONING if (flags == ILCODE_ORIGINAL_IL && m_pReJitCode != NULL) { CordbType* pOriginalType; @@ -9102,6 +9128,7 @@ HRESULT CordbJITILFrame::GetLocalVariableEx(ILCodeKind flags, DWORD dwIndex, ICo IfFailThrow(CORDBG_E_IL_VAR_NOT_AVAILABLE); // bad profiler, it shouldn't have changed types } } +#endif // FEATURE_CODE_VERSIONING hr = GetNativeVariable(type, pNativeInfo, ppValue); @@ -9128,11 +9155,15 @@ HRESULT CordbJITILFrame::GetCodeEx(ILCodeKind flags, ICorDebugCode **ppCode) } else { +#ifdef FEATURE_CODE_VERSIONING *ppCode = m_pReJitCode; if (m_pReJitCode != NULL) { m_pReJitCode->ExternalAddRef(); } +#else + return E_NOTIMPL; +#endif // FEATURE_CODE_VERSIONING } return S_OK; } @@ -9142,10 +9173,12 @@ CordbILCode* CordbJITILFrame::GetOriginalILCode() return m_ilCode; } +#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode* CordbJITILFrame::GetReJitILCode() { return m_pReJitCode; } +#endif // FEATURE_CODE_VERSIONING void CordbJITILFrame::AdjustIPAfterException() { diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 65e94cc28390df..90e19778c54ea2 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -3486,6 +3486,7 @@ HRESULT Debugger::SetIP( bool fCanSetIPOnly, Thread *thread,Module *module, LOG((LF_CORDB, LL_INFO1000, "D::SIP: In SetIP ==> fCanSetIPOnly:0x%x <==!\n", fCanSetIPOnly)); +#ifdef FEATURE_CODE_VERSIONING CodeVersionManager *pCodeVersionManager = module->GetCodeVersionManager(); { CodeVersionManager::LockHolder codeVersioningLockHolder; @@ -3495,6 +3496,7 @@ HRESULT Debugger::SetIP( bool fCanSetIPOnly, Thread *thread,Module *module, return CORDBG_E_SET_IP_IMPOSSIBLE; } } +#endif // FEATURE_CODE_VERSIONING pCtx = GetManagedStoppedCtx(thread); @@ -10275,6 +10277,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) } case DB_IPCE_DISABLE_OPTS: +#ifdef FEATURE_CODE_VERSIONING { Module *pModule = pEvent->DisableOptData.pModule.GetRawPtr(); mdToken methodDef = pEvent->DisableOptData.funcMetadataToken; @@ -10297,6 +10300,19 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) m_pRCThread->SendIPCReply(); } +#else + { + DebuggerIPCEvent * pIPCResult = m_pRCThread->GetIPCEventReceiveBuffer(); + + InitIPCEvent(pIPCResult, + DB_IPCE_DISABLE_OPTS_RESULT, + g_pEEInterface->GetThread()); + + pIPCResult->hr = E_NOTIMPL; + + m_pRCThread->SendIPCReply(); + } +#endif // FEATURE_CODE_VERSIONING break; case DB_IPCE_FORCE_CATCH_HANDLER_FOUND: @@ -12100,7 +12116,7 @@ HRESULT Debugger::ReleaseRemoteBuffer(void *pBuffer, bool removeFromBlobList) return S_OK; } -#ifndef DACCESS_COMPILE +#if defined(FEATURE_CODE_VERSIONING) && !defined(DACCESS_COMPILE) HRESULT Debugger::DeoptimizeMethodHelper(Module* pModule, mdMethodDef methodDef) { CONTRACTL @@ -12218,7 +12234,12 @@ HRESULT Debugger::DeoptimizeMethod(Module* pModule, mdMethodDef methodDef) return hr; } -#endif //DACCESS_COMPILE +#else +HRESULT Debugger::DeoptimizeMethod(Module* pModule, mdMethodDef methodDef) +{ + return E_NOTIMPL; +} +#endif //FEATURE_CODE_VERSIONING && !DACCESS_COMPILE HRESULT Debugger::IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult) { @@ -12235,12 +12256,16 @@ HRESULT Debugger::IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BO return E_INVALIDARG; } +#ifdef FEATURE_CODE_VERSIONING { CodeVersionManager::LockHolder codeVersioningLockHolder; CodeVersionManager *pCodeVersionManager = pModule->GetCodeVersionManager(); ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodDef); *pResult = activeILVersion.IsDeoptimized(); } +#else + *pResult = FALSE; +#endif // FEATURE_CODE_VERSIONING return S_OK; } diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h index c3a14ee8133775..570338f00793b6 100644 --- a/src/coreclr/debug/ee/debugger.h +++ b/src/coreclr/debug/ee/debugger.h @@ -2302,10 +2302,12 @@ class Debugger : public DebugInterface } #ifndef DACCESS_COMPILE +#ifdef FEATURE_CODE_VERSIONING private: HRESULT DeoptimizeMethodHelper(Module* pModule, mdMethodDef methodDef); public: +#endif // FEATURE_CODE_VERSIONING HRESULT DeoptimizeMethod(Module* pModule, mdMethodDef methodDef); #endif //DACCESS_COMPILE HRESULT IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BOOL *pResult); diff --git a/src/coreclr/debug/ee/functioninfo.cpp b/src/coreclr/debug/ee/functioninfo.cpp index 191cc7c278b00b..d1c7de147d9add 100644 --- a/src/coreclr/debug/ee/functioninfo.cpp +++ b/src/coreclr/debug/ee/functioninfo.cpp @@ -1060,6 +1060,7 @@ void DebuggerJitInfo::SetBoundaries(ULONG32 cMap, ICorDebugInfo::OffsetMapping * InstrumentedILOffsetMapping mapping; +#ifdef FEATURE_CODE_VERSIONING ILCodeVersion ilVersion = m_nativeCodeVersion.GetILCodeVersion(); if (!ilVersion.IsDefaultVersion()) { @@ -1079,7 +1080,9 @@ void DebuggerJitInfo::SetBoundaries(ULONG32 cMap, ICorDebugInfo::OffsetMapping * mapping = *pReJitMap; } } - else if (m_methodInfo->HasInstrumentedILMap()) + else +#endif // FEATURE_CODE_VERSIONING + if (m_methodInfo->HasInstrumentedILMap()) { // If a ReJIT hasn't happened, check for a profiler provided map. mapping = m_methodInfo->GetRuntimeModule()->GetInstrumentedILOffsetMapping(m_methodInfo->m_token); @@ -1612,6 +1615,7 @@ DebuggerJitInfo *DebuggerMethodInfo::FindOrCreateInitAndAddJitInfo(MethodDesc* f // CreateInitAndAddJitInfo takes a lock and checks the list again, which makes this thread-safe. NativeCodeVersion nativeCodeVersion; +#ifdef FEATURE_CODE_VERSIONING if (fd->IsVersionable()) { CodeVersionManager *pCodeVersionManager = fd->GetCodeVersionManager(); @@ -1622,6 +1626,7 @@ DebuggerJitInfo *DebuggerMethodInfo::FindOrCreateInitAndAddJitInfo(MethodDesc* f } } else +#endif // FEATURE_CODE_VERSIONING { // Some day we'll get EnC to use code versioning properly, but until then we'll get the right behavior treating all EnC versions as the default native code version. nativeCodeVersion = NativeCodeVersion(fd); @@ -2104,7 +2109,7 @@ void DebuggerMethodInfo::CreateDJIsForMethodDesc(MethodDesc * pMethodDesc) #else // We just ask for the DJI to ensure that it's lazily created. // This should only fail in an oom scenario. - DebuggerJitInfo * djiTest = g_pDebugger->GetLatestJitInfoFromMethodDesc(pDesc); + DebuggerJitInfo * djiTest = g_pDebugger->GetLatestJitInfoFromMethodDesc(pMethodDesc); if (djiTest == NULL) { // We're oom. Give up. diff --git a/src/coreclr/debug/inc/dacdbiinterface.h b/src/coreclr/debug/inc/dacdbiinterface.h index 66b33aab1fa51d..790010fd2fad9c 100644 --- a/src/coreclr/debug/inc/dacdbiinterface.h +++ b/src/coreclr/debug/inc/dacdbiinterface.h @@ -2602,6 +2602,7 @@ class IDacDbiInterface virtual HRESULT GetMDStructuresVersion(ULONG32* pMDStructuresVersion) = 0; +#ifdef FEATURE_CODE_VERSIONING // Retrieves the active rejit ILCodeVersionNode for a given module/methodDef, if it exists. // Active is defined as after GetReJitParameters returns from the profiler dll and // no call to Revert has completed yet. @@ -2666,6 +2667,7 @@ class IDacDbiInterface // virtual HRESULT GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode ilCodeVersionNode, DacSharedReJitInfo* pData) = 0; +#endif // FEATURE_CODE_VERSIONING // Enable or disable the GC notification events. The GC notification events are turned off by default // They will be delivered through ICorDebugManagedCallback4 diff --git a/src/coreclr/debug/inc/dbgipcevents.h b/src/coreclr/debug/inc/dbgipcevents.h index 7b6be4543cadba..8382e505a128bc 100644 --- a/src/coreclr/debug/inc/dbgipcevents.h +++ b/src/coreclr/debug/inc/dbgipcevents.h @@ -820,8 +820,10 @@ DEFINE_VMPTR(class SimpleRWLock, PTR_SimpleRWLock, VMPTR_SimpleRWLock); DEFINE_VMPTR(class SimpleRWLock, PTR_SimpleRWLock, VMPTR_RWLock); DEFINE_VMPTR(struct ReJitInfo, PTR_ReJitInfo, VMPTR_ReJitInfo); DEFINE_VMPTR(struct SharedReJitInfo, PTR_SharedReJitInfo, VMPTR_SharedReJitInfo); +#ifdef FEATURE_CODE_VERSIONING DEFINE_VMPTR(class NativeCodeVersionNode, PTR_NativeCodeVersionNode, VMPTR_NativeCodeVersionNode); DEFINE_VMPTR(class ILCodeVersionNode, PTR_ILCodeVersionNode, VMPTR_ILCodeVersionNode); +#endif // FEATURE_CODE_VERSIONING typedef CORDB_ADDRESS GENERICS_TYPE_TOKEN; diff --git a/src/coreclr/inc/dacvars.h b/src/coreclr/inc/dacvars.h index 151335e6daa60b..8845620d8b1be5 100644 --- a/src/coreclr/inc/dacvars.h +++ b/src/coreclr/inc/dacvars.h @@ -128,7 +128,9 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pStackFrameIteratorClass, ::g_pStackF DEFINE_DACVAR(PTR_SString, SString__s_Empty, SString::s_Empty) DEFINE_DACVAR(INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero) +#ifdef FEATURE_CODE_VERSIONING DEFINE_DACVAR(BOOL, CodeVersionManager__s_HasNonDefaultILVersions, CodeVersionManager::s_HasNonDefaultILVersions) +#endif // FEATURE_CODE_VERSIONING DEFINE_DACVAR(PTR_JITNotification, dac__g_pNotificationTable, ::g_pNotificationTable) DEFINE_DACVAR(ULONG32, dac__g_dacNotificationFlags, ::g_dacNotificationFlags) diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index de5e23c22cabf3..f316b9bbbb8253 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -3544,16 +3544,28 @@ VOID ETW::MethodLog::MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrC TRACE_LEVEL_INFORMATION, CLR_JITTEDMETHODILTONATIVEMAP_KEYWORD)) { +#ifdef FEATURE_CODE_VERSIONING ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), pConfig->GetCodeVersion().GetILCodeVersionId()); +#else + ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, + ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, + pNativeCodeStartAddress, + pConfig->GetCodeVersion().GetVersionId(), + 0); +#endif // FEATURE_CODE_VERSIONING } if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context, JittedMethodRichDebugInfo)) { +#ifdef FEATURE_CODE_VERSIONING ETW::MethodLog::SendMethodRichDebugInfo(pMethodDesc, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), pConfig->GetCodeVersion().GetILCodeVersionId(), NULL); +#else + ETW::MethodLog::SendMethodRichDebugInfo(pMethodDesc, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), 0, NULL); +#endif // FEATURE_CODE_VERSIONING } } EX_CATCH { } EX_END_CATCH diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 77317625dbadd1..152e92844509de 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10836,6 +10836,7 @@ void CEECodeGenInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN if (!GetAppDomain()->GetTieredCompilationManager()->IsTieringDelayActive() && g_pConfig->JitEnableOptionalRelocs()) { +#ifdef FEATURE_CODE_VERSIONING CodeVersionManager* manager = helperMD->GetCodeVersionManager(); NativeCodeVersion activeCodeVersion; @@ -10859,6 +10860,7 @@ void CEECodeGenInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN goto exit; } } +#endif // FEATURE_CODE_VERSIONING } if (IndirectionAllowedForJitHelper(ftnNum)) diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index df46fe9c1ce965..c5d6174beace96 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -146,6 +146,7 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) } } +#ifdef FEATURE_CODE_VERSIONING { CodeVersionManager::LockHolder codeVersioningLockHolder; @@ -160,18 +161,11 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) PCODE codeStart = PINSTRToPCODE(heapIterator.GetMethodCode()); NativeCodeVersion nativeCodeVersion; -#ifdef FEATURE_CODE_VERSIONING nativeCodeVersion = pMethod->GetCodeVersionManager()->GetNativeCodeVersion(pMethod, codeStart);; if (nativeCodeVersion.IsNull() && codeStart != pMethod->GetNativeCode()) { continue; } -#else // FEATURE_CODE_VERSIONING - if (codeStart != pMethod->GetNativeCode()) - { - continue; - } -#endif // FEATURE_CODE_VERSIONING EECodeInfo codeInfo(codeStart); IJitManager::MethodRegionInfo methodRegionInfo; @@ -183,6 +177,7 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) PerfMap::LogJITCompiledMethod(pMethod, codeStart, methodRegionInfo.hotSize, &config); } } +#endif // FEATURE_CODE_VERSIONING } } From 709eafa606051452a7d652324ca3ff633cd2c591 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 16 Oct 2025 09:59:19 -0700 Subject: [PATCH 2/8] Update src/coreclr/debug/daccess/dacdbiimpl.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index ef09f202cc5592..eaf8a88a272217 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -7281,7 +7281,7 @@ HRESULT DacDbiInterfaceImpl::AreOptimizationsDisabled(VMPTR_Module vmModule, mdM HRESULT DacDbiInterfaceImpl::GetSharedReJitInfo(VMPTR_ReJitInfo vmReJitInfo, OUT VMPTR_SharedReJitInfo* pvmSharedReJitInfo) { DD_ENTER_MAY_THROW; - _ASSERTE(!"You shouldn't be calling this - use GetLCodeVersionNode instead"); + _ASSERTE(!"You shouldn't be calling this - use GetILCodeVersionNode instead"); return S_OK; } From fed5808986a1a27a285c42d8f8bf361a706d34ad Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 16 Oct 2025 10:00:28 -0700 Subject: [PATCH 3/8] Update src/coreclr/vm/perfmap.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/coreclr/vm/perfmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index c5d6174beace96..4265debf103a3e 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -161,7 +161,7 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) PCODE codeStart = PINSTRToPCODE(heapIterator.GetMethodCode()); NativeCodeVersion nativeCodeVersion; - nativeCodeVersion = pMethod->GetCodeVersionManager()->GetNativeCodeVersion(pMethod, codeStart);; + nativeCodeVersion = pMethod->GetCodeVersionManager()->GetNativeCodeVersion(pMethod, codeStart); if (nativeCodeVersion.IsNull() && codeStart != pMethod->GetNativeCode()) { continue; From a7865dced3e8f84954fa2f9b41a7d191e4e546b2 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 17 Oct 2025 09:53:41 +0200 Subject: [PATCH 4/8] Update src/coreclr/debug/di/rsthread.cpp Co-authored-by: Aaron Robinson --- src/coreclr/debug/di/rsthread.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index d40e5a87e3fbd6..c22b5f0ec665a2 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -4974,6 +4974,15 @@ HRESULT CordbValueEnum::Init() m_iMax = localsCount; #else m_iMax = 0; + m_iMax = 0; +#ifdef FEATURE_CODE_VERSIONING + CordbReJitILCode* pCode = jil->GetReJitILCode(); + if (pCode != NULL) + { + IfFailRet(pCode->GetLocalVarSig(NULL, &localsCount)); + + // Grab the number of locals for the size of the enumeration. + m_iMax = localsCount; #endif // FEATURE_CODE_VERSIONING } break; From 332a2387ef3221c31773e3ae60798ac3af534aac Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 17 Oct 2025 09:53:47 +0200 Subject: [PATCH 5/8] Update src/coreclr/debug/daccess/request.cpp Co-authored-by: Jan Kotas --- src/coreclr/debug/daccess/request.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index a5c1302393ae69..9a8d161deefeeb 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -4688,7 +4688,6 @@ HRESULT ClrDataAccess::GetPendingReJITID(CLRDATA_ADDRESS methodDesc, int *pRejit HRESULT ClrDataAccess::GetReJITInformation(CLRDATA_ADDRESS methodDesc, int rejitId, struct DacpReJitData2 *pReJitData) { #ifdef FEATURE_CODE_VERSIONING -{ if (methodDesc == 0 || rejitId < 0 || pReJitData == NULL) { return E_INVALIDARG; From a969f19ccd43e330abcdc4e24ebb8b54a049e4ea Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 17 Oct 2025 09:53:57 +0200 Subject: [PATCH 6/8] Update src/coreclr/debug/daccess/request.cpp Co-authored-by: Jan Kotas --- src/coreclr/debug/daccess/request.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 9a8d161deefeeb..70aabb8cd1b25d 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -4732,7 +4732,6 @@ HRESULT ClrDataAccess::GetReJITInformation(CLRDATA_ADDRESS methodDesc, int rejit SOSDacLeave(); return hr; -} #else return E_NOTIMPL; #endif // FEATURE_CODE_VERSIONING From 4d7a01707966faf98311f012562219b63f535c3d Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 17 Oct 2025 10:13:12 +0200 Subject: [PATCH 7/8] Simplify logic --- src/coreclr/debug/di/rsthread.cpp | 18 +++--------------- src/coreclr/vm/codeversion.cpp | 1 + src/coreclr/vm/codeversion.h | 2 +- src/coreclr/vm/eventtrace.cpp | 12 ------------ 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index c22b5f0ec665a2..14fcf750a75d27 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -4954,35 +4954,23 @@ HRESULT CordbValueEnum::Init() } case LOCAL_VARS_REJIT_IL: { +#ifdef FEATURE_CODE_VERSIONING // Get the locals signature. ULONG localsCount; -#ifdef FEATURE_CODE_VERSIONING CordbReJitILCode* pCode = jil->GetReJitILCode(); -#else - void* pCode = NULL; -#endif // FEATURE_CODE_VERSIONING if (pCode == NULL) { m_iMax = 0; } else { -#ifdef FEATURE_CODE_VERSIONING IfFailRet(pCode->GetLocalVarSig(NULL, &localsCount)); // Grab the number of locals for the size of the enumeration. m_iMax = localsCount; + } #else - m_iMax = 0; - m_iMax = 0; -#ifdef FEATURE_CODE_VERSIONING - CordbReJitILCode* pCode = jil->GetReJitILCode(); - if (pCode != NULL) - { - IfFailRet(pCode->GetLocalVarSig(NULL, &localsCount)); - - // Grab the number of locals for the size of the enumeration. - m_iMax = localsCount; + m_iMax = 0; #endif // FEATURE_CODE_VERSIONING } break; diff --git a/src/coreclr/vm/codeversion.cpp b/src/coreclr/vm/codeversion.cpp index 1fdfa6f952f44e..d880cd3e5290f4 100644 --- a/src/coreclr/vm/codeversion.cpp +++ b/src/coreclr/vm/codeversion.cpp @@ -30,6 +30,7 @@ NativeCodeVersion::NativeCodeVersion(PTR_MethodDesc pMethod) : m_pMethodDesc(pMethod) {} BOOL NativeCodeVersion::IsDefaultVersion() const { return TRUE; } PCODE NativeCodeVersion::GetNativeCode() const { return m_pMethodDesc->GetNativeCode(); } +ReJITID NativeCodeVersion::GetILCodeVersionId() const { return 0; } #ifndef DACCESS_COMPILE BOOL NativeCodeVersion::SetNativeCodeInterlocked(PCODE pCode, PCODE pExpected) { return m_pMethodDesc->SetNativeCodeInterlocked(pCode, pExpected); } diff --git a/src/coreclr/vm/codeversion.h b/src/coreclr/vm/codeversion.h index 0e55b7fc3d7e89..d07572966b9d6d 100644 --- a/src/coreclr/vm/codeversion.h +++ b/src/coreclr/vm/codeversion.h @@ -61,10 +61,10 @@ class NativeCodeVersion NativeCodeVersionId GetVersionId() const; BOOL IsDefaultVersion() const; PCODE GetNativeCode() const; + ReJITID GetILCodeVersionId() const; #ifdef FEATURE_CODE_VERSIONING ILCodeVersion GetILCodeVersion() const; - ReJITID GetILCodeVersionId() const; #endif // FEATURE_CODE_VERSIONING #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index f316b9bbbb8253..de5e23c22cabf3 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -3544,28 +3544,16 @@ VOID ETW::MethodLog::MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrC TRACE_LEVEL_INFORMATION, CLR_JITTEDMETHODILTONATIVEMAP_KEYWORD)) { -#ifdef FEATURE_CODE_VERSIONING ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), pConfig->GetCodeVersion().GetILCodeVersionId()); -#else - ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, - ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, - pNativeCodeStartAddress, - pConfig->GetCodeVersion().GetVersionId(), - 0); -#endif // FEATURE_CODE_VERSIONING } if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context, JittedMethodRichDebugInfo)) { -#ifdef FEATURE_CODE_VERSIONING ETW::MethodLog::SendMethodRichDebugInfo(pMethodDesc, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), pConfig->GetCodeVersion().GetILCodeVersionId(), NULL); -#else - ETW::MethodLog::SendMethodRichDebugInfo(pMethodDesc, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetVersionId(), 0, NULL); -#endif // FEATURE_CODE_VERSIONING } } EX_CATCH { } EX_END_CATCH From eda84ed6f8b0d3e555c0451ff3475eeeea203cf1 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 17 Oct 2025 10:38:14 +0200 Subject: [PATCH 8/8] Fix formatting --- src/coreclr/debug/di/rsthread.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 14fcf750a75d27..0a0ec17470ad91 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -4972,7 +4972,6 @@ HRESULT CordbValueEnum::Init() #else m_iMax = 0; #endif // FEATURE_CODE_VERSIONING - } break; } }