[browser][coreCLR] Support interpreter code resolution on portable entrypoint platforms#127370
[browser][coreCLR] Support interpreter code resolution on portable entrypoint platforms#127370pavelsavara wants to merge 4 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
This PR fixes EventPipe/ETW instruction-pointer (IP) to managed-method resolution for interpreted methods on WASM, where CoreCLR uses FEATURE_PORTABLE_ENTRYPOINTS instead of interpreter precodes. This enables the sampling profiler to correctly attribute samples to interpreted managed methods.
Changes:
- Update
MethodDesc::JitCompileCodeLockedEventWrapperto derive the interpreted-method “native start address” fromPortableEntryPointinterpreter data whenFEATURE_PORTABLE_ENTRYPOINTSis enabled. - Update
MethodAndStartAddressToEECodeInfoPointerto fall back toMethodDesc::GetInterpreterCode()(returning theInterpByteCodeStartpointer) when no explicit start address is supplied on portable-entrypoint interpreter builds.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/vm/prestub.cpp | Uses PortableEntryPoint::GetInterpreterData to compute the method start address for interpreted-method ETW events under portable entrypoints. |
| src/coreclr/vm/eventtrace.cpp | Adds a portable-entrypoints interpreter fallback so method events can resolve InterpByteCodeStart when no explicit start address is provided. |
58f8b7d to
e077850
Compare
| start = GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc); | ||
|
|
||
| return start; |
There was a problem hiding this comment.
| start = GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc); | |
| return start; | |
| return GetInterpreterCodeFromEntryPointIfPresent(start, pNativeCodeStartAddress ? NULL : pMethodDesc); |
| #endif // !FEATURE_PORTABLE_ENTRYPOINTS | ||
|
|
||
| TADDR GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR codePointerMaybeInterpreterStub) | ||
| TADDR GetInterpreterCodeFromEntryPointIfPresent(TADDR entryPoint, MethodDesc* pMethodDesc) |
There was a problem hiding this comment.
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_END; | ||
|
|
||
| #if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS) |
There was a problem hiding this comment.
| #if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS) | |
| #ifdef FEATURE_INTERPRETER | |
| #ifdef FEATURE_PORTABLE_ENTRYPOINTS | |
| .... | |
| #else | |
| .... | |
| #endif // FEATURE_PORTABLE_ENTRYPOINTS | |
| #endif // FEATURE_INTERPRETER |
Summary
Generalizes
GetInterpreterCodeFromInterpreterPrecodeIfPresent(renamed toGetInterpreterCodeFromEntryPointIfPresent) to resolve interpreter bytecode addresses on platforms that useFEATURE_PORTABLE_ENTRYPOINTS(e.g., browser WASM) whereInterpreterPrecodedoes not exist.Motivation
The sampling profiler does not work on WASM because the EventPipe code paths that resolve instruction pointers (IPs) to method information assume the traditional
InterpreterPrecodemechanism. On WASM, CoreCLR uses portable entrypoints (FEATURE_PORTABLE_ENTRYPOINTS) instead of interpreter precodes, so the existing code silently returns wrong or zero addresses, causing the profiler to fail to attribute samples to managed methods.Split from #126324 for smaller reviews
Changes
Renamed function with new signature
GetInterpreterCodeFromInterpreterPrecodeIfPresent(TADDR)→GetInterpreterCodeFromEntryPointIfPresent(TADDR, MethodDesc*)pMethodDescparameter (defaulting toNULL) enables resolution on portable entrypoint platforms viaMethodDesc::GetInterpreterCode().New portable entrypoint code path (
precode.cpp)Added
#elif defined(FEATURE_INTERPRETER) && defined(FEATURE_PORTABLE_ENTRYPOINTS)branch:pMethodDescis provided, callspMethodDesc->GetInterpreterCode()to get theInterpByteCodeStartpointer directly from the MethodDesc, bypassing the precode entirely.pMethodDescis NULL or no interpreter code exists.Portable entrypoint handling in
prestub.cppAdded
#ifdef FEATURE_PORTABLE_ENTRYPOINTSbranch inJitCompileCodeLockedEventWrapperto usePortableEntryPoint::GetInterpreterData(pCode)instead ofInterpreterPrecode::FromEntryPoint(pCode)when extracting theInterpByteCodeStartfor ETW method-jitted events.Caller updates (DAC/debugger/ETW)
All callers updated to pass the new
MethodDesc*parameter where available:daccess.cpp—GetMethodVarInfo,GetMethodNativeMap,RawGetMethodNamedacdbiimpl.cpp—GetNativeCodeInfoForAddrrequest.cpp—CopyNativeCodeVersionToReJitData,GetMethodDescData,GetTieredVersionsfunctioninfo.cpp—CreateDJIsForMethodDesceventtrace.cpp—MethodAndStartAddressToEECodeInfoPointer(passesNULLwhen a specific code address was provided,pMethodDescotherwise)method.hpp—GetCodeForInterpreterOrJitted