Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5088,7 +5088,7 @@ ClrDataAccess::FollowStubStep(
methodDesc = PTR_MethodDesc(CORDB_ADDRESS_TO_TADDR(inBuffer->u.addr));
if (methodDesc->HasNativeCode())
{
*outAddr = methodDesc->GetNativeCode();
*outAddr = methodDesc->GetCodeForInterpreterOrJitted();
*outFlags = CLRDATA_FOLLOW_STUB_EXIT;
return S_OK;
}
Expand Down Expand Up @@ -5737,7 +5737,7 @@ ClrDataAccess::RawGetMethodName(
MethodDesc* methodDesc = NULL;

{
EECodeInfo codeInfo(TO_TADDR(address));
EECodeInfo codeInfo(GetInterpreterCodeFromInterpreterPrecodeIfPresent(TO_TADDR(address)));
if (codeInfo.IsValid())
{
if (displacement)
Expand Down Expand Up @@ -5886,7 +5886,7 @@ ClrDataAccess::GetMethodExtents(MethodDesc* methodDesc,
// for all types of managed code.
//

PCODE methodStart = methodDesc->GetNativeCode();
PCODE methodStart = methodDesc->GetCodeForInterpreterOrJitted();
if (!methodStart)
{
return E_NOINTERFACE;
Expand Down Expand Up @@ -5940,11 +5940,11 @@ ClrDataAccess::GetMethodVarInfo(MethodDesc* methodDesc,
{
return E_INVALIDARG;
}
nativeCodeStartAddr = PCODEToPINSTR(requestedNativeCodeVersion.GetNativeCode());
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(requestedNativeCodeVersion.GetNativeCode()));
}
else
{
nativeCodeStartAddr = PCODEToPINSTR(methodDesc->GetNativeCode());
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(methodDesc->GetNativeCode()));
}

DebugInfoRequest request;
Expand Down Expand Up @@ -5999,11 +5999,11 @@ ClrDataAccess::GetMethodNativeMap(MethodDesc* methodDesc,
{
return E_INVALIDARG;
}
nativeCodeStartAddr = PCODEToPINSTR(requestedNativeCodeVersion.GetNativeCode());
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(requestedNativeCodeVersion.GetNativeCode()));
}
else
{
nativeCodeStartAddr = PCODEToPINSTR(methodDesc->GetNativeCode());
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(methodDesc->GetNativeCode()));
}

DebugInfoRequest request;
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ void DacDbiInterfaceImpl::GetMethodRegionInfo(MethodDesc * pMethodDe
CONTRACTL_END;

IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0};
PCODE functionAddress = pMethodDesc->GetNativeCode();
PCODE functionAddress = pMethodDesc->GetCodeForInterpreterOrJitted();

// get the start address of the hot region and initialize the jit manager
pCodeInfo->m_rgCodeRegions[kHot].pAddress = CORDB_ADDRESS(PCODEToPINSTR(functionAddress));
Expand Down Expand Up @@ -1229,6 +1229,12 @@ void DacDbiInterfaceImpl::GetNativeCodeInfoForAddr(VMPTR_MethodDesc vmMe
IJitManager::MethodRegionInfo methodRegionInfo = {(TADDR)NULL, 0, (TADDR)NULL, 0};
TADDR codeAddr = CORDB_ADDRESS_TO_TADDR(hotCodeStartAddr);

EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY
{
codeAddr = GetInterpreterCodeFromInterpreterPrecodeIfPresent(codeAddr);
}
EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY;

#ifdef TARGET_ARM
// TADDR should not have the thumb code bit set.
_ASSERTE((codeAddr & THUMB_CODE) == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ HRESULT ClrDataAccess::DumpManagedExcepObject(CLRDataEnumMemoryFlags flags, OBJE
// Pulls in data to translate from token to MethodDesc
FindLoadedMethodRefOrDef(pMD->GetMethodTable()->GetModule(), pMD->GetMemberDef());

PCODE addr = pMD->GetNativeCode();
PCODE addr = pMD->GetCodeForInterpreterOrJitted();
if (addr != (PCODE)NULL)
{
EECodeInfo codeInfo(addr);
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ BOOL DacValidateMD(PTR_MethodDesc pMD)

if (retval && pMD->HasNativeCode() && !pMD->IsFCall())
{
PCODE jitCodeAddr = pMD->GetNativeCode();
PCODE jitCodeAddr = pMD->GetCodeForInterpreterOrJitted();

MethodDesc *pMDCheck = ExecutionManager::GetCodeMethodDesc(jitCodeAddr);
if (pMDCheck)
Expand Down Expand Up @@ -901,7 +901,7 @@ HRESULT ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThre
void CopyNativeCodeVersionToReJitData(NativeCodeVersion nativeCodeVersion, NativeCodeVersion activeCodeVersion, DacpReJitData * pReJitData)
{
pReJitData->rejitID = nativeCodeVersion.GetILCodeVersion().GetVersionId();
pReJitData->NativeCodeAddr = nativeCodeVersion.GetNativeCode();
pReJitData->NativeCodeAddr = GetInterpreterCodeFromInterpreterPrecodeIfPresent(nativeCodeVersion.GetNativeCode());

if (nativeCodeVersion != activeCodeVersion)
{
Expand Down Expand Up @@ -1011,7 +1011,7 @@ HRESULT ClrDataAccess::GetMethodDescData(
if (!requestedNativeCodeVersion.IsNull() && requestedNativeCodeVersion.GetNativeCode() != (PCODE)NULL)
{
methodDescData->bHasNativeCode = TRUE;
methodDescData->NativeCodeAddr = TO_CDADDR(PCODEToPINSTR(requestedNativeCodeVersion.GetNativeCode()));
methodDescData->NativeCodeAddr = TO_CDADDR(PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(requestedNativeCodeVersion.GetNativeCode())));
}
else
{
Expand Down Expand Up @@ -1235,7 +1235,7 @@ HRESULT ClrDataAccess::GetTieredVersions(
int count = 0;
for (NativeCodeVersionIterator iter = nativeCodeVersions.Begin(); iter != nativeCodeVersions.End(); iter++)
{
TADDR pNativeCode = PCODEToPINSTR((*iter).GetNativeCode());
TADDR pNativeCode = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent((*iter).GetNativeCode()));
nativeCodeAddrs[count].NativeCodeAddr = pNativeCode;
PTR_NativeCodeVersionNode pNode = (*iter).AsNode();
nativeCodeAddrs[count].NativeCodeVersionNodePtr = PTR_CDADDR(pNode);
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,13 @@ class MethodDesc
// Returns the address of the native code.
PCODE GetNativeCode();

// Returns either the jitted code or the interpreter code (will not return the InterpreterStub which GetNativeCode might return)
PCODE GetCodeForInterpreterOrJitted()
{
WRAPPER_NO_CONTRACT;
return GetInterpreterCodeFromInterpreterPrecodeIfPresent(GetNativeCode());
}

// Returns GetNativeCode() if it exists, but also checks to see if there
// is a non-default code version that is populated with a code body and returns that.
// Perf warning: takes the CodeVersionManagerLock on every call
Expand Down
30 changes: 30 additions & 0 deletions src/coreclr/vm/precode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,33 @@ BOOL StubPrecode::IsStubPrecodeByASM(PCODE addr)
}

#endif // !FEATURE_PORTABLE_ENTRYPOINTS

TADDR GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR codePointerMaybeInterpreterStub)
{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
} CONTRACTL_END;

#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
if (codePointerMaybeInterpreterStub == (TADDR)NULL)
{
return (TADDR)NULL;
}

RangeSection * pRS = ExecutionManager::FindCodeRange(codePointerMaybeInterpreterStub, ExecutionManager::GetScanFlags());
if (pRS != NULL && pRS->_flags & RangeSection::RANGE_SECTION_RANGELIST)
{
if (pRS->_pRangeList->GetCodeBlockKind() == STUB_CODE_BLOCK_STUBPRECODE)
{
if (dac_cast<PTR_StubPrecode>(PCODEToPINSTR(codePointerMaybeInterpreterStub))->GetType() == PRECODE_INTERPRETER)
{
codePointerMaybeInterpreterStub = (dac_cast<PTR_InterpreterPrecode>(PCODEToPINSTR(codePointerMaybeInterpreterStub)))->GetData()->ByteCodeAddr;
}
}
}
#endif

return codePointerMaybeInterpreterStub;
}
2 changes: 2 additions & 0 deletions src/coreclr/vm/precode.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,4 +864,6 @@ extern InterleavedLoaderHeapConfig s_fixupStubPrecodeHeapConfig;

#endif // FEATURE_PORTABLE_ENTRYPOINTS

TADDR GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR codePointerMaybeInterpreterStub);

#endif // __PRECODE_H__
9 changes: 9 additions & 0 deletions src/coreclr/vm/stubmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,15 @@ BOOL PrecodeStubManager::CheckIsStub_Internal(PCODE stubStartAddress)
else if (stubKind == STUB_CODE_BLOCK_STUBPRECODE)
{
Precode* pPrecode = Precode::GetPrecodeFromEntryPoint(stubStartAddress);
#ifdef DACCESS_COMPILE
// The DAC always treats GetPrecodeFromEntryPoint as if the speculative flag is TRUE.
// so it may return NULL
if (pPrecode == NULL)
{
return FALSE;
}
#endif

switch (pPrecode->GetType())
{
case PRECODE_STUB:
Expand Down