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
15 changes: 14 additions & 1 deletion src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4417,7 +4417,20 @@ TADDR MethodAndStartAddressToEECodeInfoPointer(MethodDesc *pMethodDesc, PCODE pN
return 0;
}

return GetInterpreterCodeFromInterpreterPrecodeIfPresent(start);
start = GetInterpreterCodeFromInterpreterPrecodeIfPresent(start);
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.

Should this be fixed in GetInterpreterCodeFromInterpreterPrecodeIfPresent instead?

Also, GetInterpreterCodeFromInterpreterPrecodeIfPresent may want to be renamed to GetInterpreterCodeFromEntryPointIfPresent to better represent what it does.


#if defined(FEATURE_INTERPRETER) && defined(FEATURE_PORTABLE_ENTRYPOINTS)
if (pNativeCodeStartAddress == (PCODE)0)
{
PTR_InterpByteCodeStart pInterpCode = pMethodDesc->GetInterpreterCode();
if (pInterpCode != NULL)
{
return dac_cast<TADDR>(pInterpCode);
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

In the portable-entrypoints + interpreter fallback, the returned address should be encoded consistently with other interpreter code addresses (e.g., JitCompileCodeLockedEventWrapper passes PINSTRToPCODE(dac_cast<TADDR>(interpreterCode)) to ETW). Returning dac_cast<TADDR>(pInterpCode) bypasses PINSTRToPCODE, which can cause mismatches on architectures where PCODE carries tagging (e.g., ARM THUMB bit) and may break comparisons/method event correlation. Consider returning PINSTRToPCODE(dac_cast<TADDR>(pInterpCode)) (or equivalent) instead of the raw pointer value.

Suggested change
return dac_cast<TADDR>(pInterpCode);
return PINSTRToPCODE(dac_cast<TADDR>(pInterpCode));

Copilot uses AI. Check for mistakes.
}
}
#endif // defined(FEATURE_INTERPRETER) && defined(FEATURE_PORTABLE_ENTRYPOINTS)

return start;
}

/****************************************************************************/
Expand Down
4 changes: 4 additions & 0 deletions 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
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

The comment mentions getting the native start address from the interpreter Precode, but in the FEATURE_PORTABLE_ENTRYPOINTS branch the data comes from PortableEntryPoint interpreter data. Update the comment to reflect both cases; optionally, you could avoid duplicating the extraction logic by using MethodDesc::GetInterpreterCode() (which JitCompileCodeLocked already sets) when isInterpreterCode is true.

Suggested change
// If this is interpreter code, we need to get the native code start address from the interpreter Precode
// If this is interpreter code, get the native code start address from the
// interpreter entrypoint data: PortableEntryPoint interpreter data when
// FEATURE_PORTABLE_ENTRYPOINTS is enabled, otherwise the interpreter Precode.

Copilot uses AI. Check for mistakes.
#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
Loading