Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 44 additions & 42 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 GetILCodeVersionNode 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)
{
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/debug/daccess/dacdbiimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4679,9 +4680,14 @@ HRESULT ClrDataAccess::GetPendingReJITID(CLRDATA_ADDRESS methodDesc, int *pRejit
SOSDacLeave();

return hr;
#else
return E_NOTIMPL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return *pRejitId = -1; and hr = S_FALSE;?

#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)
{
Expand Down Expand Up @@ -4728,10 +4734,15 @@ HRESULT ClrDataAccess::GetReJITInformation(CLRDATA_ADDRESS methodDesc, int rejit

return hr;
}
#else
return E_NOTIMPL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just return pReJitData->flags = DacpReJitData2::kActive; - same as with no code versioning?

#endif // FEATURE_CODE_VERSIONING
}


HRESULT ClrDataAccess::GetProfilerModifiedILInformation(CLRDATA_ADDRESS methodDesc, struct DacpProfilerILData *pILData)
{
#ifdef FEATURE_CODE_VERSIONING
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ifdef can be smaller (just CodeVersionManager* pCodeVersionManager = pMD->GetCodeVersionManager(); block) so that the method succeeds as if there was no code versioning event.

if (methodDesc == 0 || pILData == NULL)
{
return E_INVALIDARG;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4814,6 +4829,9 @@ HRESULT ClrDataAccess::GetMethodsWithProfilerModifiedIL(CLRDATA_ADDRESS mod, CLR
SOSDacLeave();

return hr;
#else
return E_NOTIMPL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can succeed with returning *pcMethodDescs = 0;

#endif // FEATURE_CODE_VERSIONING
}

HRESULT ClrDataAccess::GetNumberGenerations(unsigned int *pGenerations)
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/coreclr/debug/di/rsfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand All @@ -576,6 +581,9 @@ HRESULT CordbFunction::GetActiveReJitRequestILCode(ICorDebugILCode **ppReJitedIL
}
PUBLIC_API_END(hr);
return hr;
#else
return E_NOTIMPL;
#endif // FEATURE_CODE_VERSIONING
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
Expand All @@ -1298,3 +1307,4 @@ HRESULT CordbFunction::LookupOrCreateReJitILCode(VMPTR_ILCodeVersionNode vmILCod
*ppILCode = pILCode;
return S_OK;
}
#endif // FEATURE_CODE_VERSIONING
16 changes: 16 additions & 0 deletions src/coreclr/debug/di/rspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<CordbReJitILCode> m_reJitILCodes;
#endif // FEATURE_CODE_VERSIONING
};

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -5878,6 +5885,7 @@ class CordbReJitILCode : public CordbILCode,
ULONG32 m_cILMap;
NewArrayHolder<COR_IL_MAP> m_pILMap;
};
#endif // FEATURE_CODE_VERSIONING

/* ------------------------------------------------------------------------- *
* CordbNativeCode class. These correspond to MethodDesc's on the left-side.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -7479,7 +7491,9 @@ class CordbJITILFrame : public CordbBase, public ICorDebugILFrame, public ICorDe
static HRESULT BuildInstantiationForCallsite(CordbModule *pModule, NewArrayHolder<CordbType*> &types, Instantiation &inst, Instantiation *currentInstantiation, mdToken targetClass, SigParser funcGenerics);

CordbILCode* GetOriginalILCode();
#ifdef FEATURE_CODE_VERSIONING
CordbReJitILCode* GetReJitILCode();
#endif // FEATURE_CODE_VERSIONING
void AdjustIPAfterException();

private:
Expand Down Expand Up @@ -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<CordbReJitILCode> m_pReJitCode;
#endif // FEATURE_CODE_VERSIONING
BOOL m_adjustedIP;
};

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/debug/di/rsstackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CordbReJitILCode> pReJitCode;
EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY
{
Expand All @@ -766,6 +767,9 @@ HRESULT CordbStackWalk::GetFrameWorker(ICorDebugFrame ** ppFrame)
}
}
EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY
#else
void* pReJitCode = NULL;
#endif // FEATURE_CODE_VERSIONING



Expand Down
Loading
Loading