Skip to content
Open
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
10 changes: 5 additions & 5 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5425,7 +5425,7 @@ ClrDataAccess::RawGetMethodName(
MethodDesc* methodDesc = NULL;

{
EECodeInfo codeInfo(GetInterpreterCodeFromInterpreterPrecodeIfPresent(TO_TADDR(address)));
EECodeInfo codeInfo(GetInterpreterCodeFromEntryPointIfPresent(TO_TADDR(address)));
if (codeInfo.IsValid())
{
if (displacement)
Expand Down Expand Up @@ -5605,11 +5605,11 @@ ClrDataAccess::GetMethodVarInfo(MethodDesc* methodDesc,
{
return E_INVALIDARG;
}
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(requestedNativeCodeVersion.GetNativeCode()));
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromEntryPointIfPresent(requestedNativeCodeVersion.GetNativeCode(), methodDesc));
}
else
{
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(methodDesc->GetNativeCode()));
nativeCodeStartAddr = PCODEToPINSTR(GetInterpreterCodeFromEntryPointIfPresent(methodDesc->GetNativeCode(), methodDesc));
}

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

DebugInfoRequest request;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetNativeCodeInfoForAddr(CORDB_AD

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

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ HRESULT ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThre
void CopyNativeCodeVersionToReJitData(NativeCodeVersion nativeCodeVersion, NativeCodeVersion activeCodeVersion, DacpReJitData * pReJitData)
{
pReJitData->rejitID = nativeCodeVersion.GetILCodeVersion().GetVersionId();
pReJitData->NativeCodeAddr = GetInterpreterCodeFromInterpreterPrecodeIfPresent(nativeCodeVersion.GetNativeCode());
pReJitData->NativeCodeAddr = GetInterpreterCodeFromEntryPointIfPresent(nativeCodeVersion.GetNativeCode(), nativeCodeVersion.GetMethodDesc());

if (nativeCodeVersion != activeCodeVersion)
{
Expand Down Expand Up @@ -1021,7 +1021,7 @@ HRESULT ClrDataAccess::GetMethodDescData(
if (!requestedNativeCodeVersion.IsNull() && requestedNativeCodeVersion.GetNativeCode() != (PCODE)NULL)
{
methodDescData->bHasNativeCode = TRUE;
methodDescData->NativeCodeAddr = TO_CDADDR(PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent(requestedNativeCodeVersion.GetNativeCode())));
methodDescData->NativeCodeAddr = TO_CDADDR(PCODEToPINSTR(GetInterpreterCodeFromEntryPointIfPresent(requestedNativeCodeVersion.GetNativeCode(), pMD)));
}
else
{
Expand Down Expand Up @@ -1245,7 +1245,7 @@ HRESULT ClrDataAccess::GetTieredVersions(
int count = 0;
for (NativeCodeVersionIterator iter = nativeCodeVersions.Begin(); iter != nativeCodeVersions.End(); iter++)
{
TADDR pNativeCode = PCODEToPINSTR(GetInterpreterCodeFromInterpreterPrecodeIfPresent((*iter).GetNativeCode()));
TADDR pNativeCode = PCODEToPINSTR(GetInterpreterCodeFromEntryPointIfPresent((*iter).GetNativeCode(), pMD));
nativeCodeAddrs[count].NativeCodeAddr = pNativeCode;
PTR_NativeCodeVersionNode pNode = (*iter).AsNode();
nativeCodeAddrs[count].NativeCodeVersionNodePtr = PTR_CDADDR(pNode);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/functioninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ void DebuggerMethodInfo::CreateDJIsForMethodDesc(MethodDesc * pMethodDesc)
{
// Some versions may not be compiled yet - skip those for now
// if they compile later the JitCompiled callback will add a DJI to our cache at that time
PCODE codeAddr = GetInterpreterCodeFromInterpreterPrecodeIfPresent(itr->GetNativeCode());
PCODE codeAddr = GetInterpreterCodeFromEntryPointIfPresent(itr->GetNativeCode(), pMethodDesc);
LOG((LF_CORDB, LL_INFO10000, "DMI::CDJIFMD (%d) Native code for DJI - %p\n", ++count, codeAddr));
if (codeAddr)
{
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4417,7 +4417,9 @@ TADDR MethodAndStartAddressToEECodeInfoPointer(MethodDesc *pMethodDesc, PCODE pN
return 0;
}

return GetInterpreterCodeFromInterpreterPrecodeIfPresent(start);
start = GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc);

return start;
Comment on lines +4420 to +4422
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
start = GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc);
return start;
return GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc);

}

/****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ class MethodDesc
PCODE GetCodeForInterpreterOrJitted()
{
WRAPPER_NO_CONTRACT;
return GetInterpreterCodeFromInterpreterPrecodeIfPresent(GetNativeCode());
return GetInterpreterCodeFromEntryPointIfPresent(GetNativeCode(), this);
}

// Returns GetNativeCode() if it exists, but also checks to see if there
Expand Down
23 changes: 16 additions & 7 deletions src/coreclr/vm/precode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,32 +959,41 @@ BOOL StubPrecode::IsStubPrecodeByASM(PCODE addr)

#endif // !FEATURE_PORTABLE_ENTRYPOINTS

TADDR GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR codePointerMaybeInterpreterStub)
TADDR GetInterpreterCodeFromEntryPointIfPresent(TADDR entryPoint, MethodDesc* pMethodDesc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should not need to pass in MethodDesc as an extra argument. You can get the methoddesc from the portable entrypoint by calling PortableEntryPoint::GetMethodDesc

{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
} CONTRACTL_END;

#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
#ifdef FEATURE_INTERPRETER
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
....
#else
....
#endif // FEATURE_PORTABLE_ENTRYPOINTS
#endif // FEATURE_INTERPRETER

if (codePointerMaybeInterpreterStub == (TADDR)NULL)
if (entryPoint == (TADDR)NULL)
{
return (TADDR)NULL;
}

RangeSection * pRS = ExecutionManager::FindCodeRange(codePointerMaybeInterpreterStub, ExecutionManager::GetScanFlags());
RangeSection * pRS = ExecutionManager::FindCodeRange(entryPoint, 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)
if (dac_cast<PTR_StubPrecode>(PCODEToPINSTR(entryPoint))->GetType() == PRECODE_INTERPRETER)
{
codePointerMaybeInterpreterStub = (dac_cast<PTR_InterpreterPrecode>(PCODEToPINSTR(codePointerMaybeInterpreterStub)))->GetData()->ByteCodeAddr;
entryPoint = (dac_cast<PTR_InterpreterPrecode>(PCODEToPINSTR(entryPoint)))->GetData()->ByteCodeAddr;
}
}
}
#elif defined(FEATURE_INTERPRETER) && defined(FEATURE_PORTABLE_ENTRYPOINTS)
if (pMethodDesc != NULL)
{
PTR_InterpByteCodeStart pInterpCode = pMethodDesc->GetInterpreterCode();
if (pInterpCode != NULL)
{
return dac_cast<TADDR>(pInterpCode);
}
}
#endif

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

#endif // FEATURE_PORTABLE_ENTRYPOINTS

TADDR GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR codePointerMaybeInterpreterStub);
class MethodDesc;
TADDR GetInterpreterCodeFromEntryPointIfPresent(TADDR entryPoint, MethodDesc* pMethodDesc = NULL);
Comment thread
pavelsavara marked this conversation as resolved.

#endif // __PRECODE_H__
6 changes: 5 additions & 1 deletion src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,12 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J
if (isInterpreterCode)
{
// If this is interpreter code, we need to get the native code start address from the interpreter Precode
Comment thread
pavelsavara marked this conversation as resolved.
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
InterpByteCodeStart* interpreterCode = (InterpByteCodeStart*)PortableEntryPoint::GetInterpreterData(pCode);
#else // !FEATURE_PORTABLE_ENTRYPOINTS
InterpreterPrecode* pPrecode = InterpreterPrecode::FromEntryPoint(pCode);
InterpByteCodeStart* interpreterCode = dac_cast<InterpByteCodeStart*>(pPrecode->GetData()->ByteCodeAddr);
#endif // FEATURE_PORTABLE_ENTRYPOINTS
pNativeCodeStartAddress = PINSTRToPCODE(dac_cast<TADDR>(interpreterCode));
}
#endif // FEATURE_INTERPRETER
Expand Down Expand Up @@ -2540,7 +2544,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
// Check to see if the entrypoint is into the interpreter. If so, grab the interpreter codes from the stub and put that directly
// into the MethodDesc
TADDR functionAddress = GetOrCreatePrecode()->GetTarget();
TADDR byteCodeStartOrFunctionAddress = GetInterpreterCodeFromInterpreterPrecodeIfPresent(functionAddress);
TADDR byteCodeStartOrFunctionAddress = GetInterpreterCodeFromEntryPointIfPresent(functionAddress);
if (byteCodeStartOrFunctionAddress != functionAddress)
{
// Then we must have an InterpByteCodeStart
Expand Down
Loading