You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On FEATURE_PORTABLE_ENTRYPOINTS targets (currently WebAssembly), a method's entry point slot holds a PortableEntryPoint address. The native runtime maps that address to a resolvable code start before handing it to diagnostics:
GetInterpreterCodeFromEntryPointIfPresent (src/coreclr/vm/precode.cpp) returns the interpreter bytecode for interpreted methods.
GetDiagnosticCodeStartFromEntryPoint (same file, shared by EventPipe method events and RuntimeMethodHandle_GetNativeCode) additionally maps native R2R portable entry points, whose actual code is a function-table index, to the synthetic virtual IP registered through ExecutionManager::AddVirtualIPRange.
The cDAC does neither:
RuntimeTypeSystem_1.GetNativeCode returns the raw entry-point slot value.
PrecodeStubs_1.GetInterpreterCodeFromInterpreterPrecodeIfPresent only recognizes interpreter StubPrecodes and has no portable-entry-point case, so it returns the PortableEntryPoint address unchanged.
As a result, SOS method data such as DacpMethodDescData.NativeCodeAddr and rejit NativeCodeAddr (SOSDacImpl.cs) should report a PortableEntryPoint address on wasm for both interpreted and R2R methods. That address does not resolve through ExecutionManager lookups (GetCodeBlockHandle, FindVirtualIPRangeSection).
This was found by code inspection while fixing #134145. It has not been reproduced against a live wasm target.
Suggested direction
When the portable-entrypoints feature flag is enabled, mirror the native mapping for a portable entry point:
If the method has interpreter code, return the bytecode start.
Otherwise, if it has a native entry point, map the function-table index to its virtual IP. Use FunctionTableIndexRangeSection data (already read by the wasm stack walk), the owning ReadyToRunInfo.MinVirtualIP, and the containing non-funclet RUNTIME_FUNCTION, matching ExecutionManager::GetWasmVirtualIPFromFunctionTableIndex.
The pieces are already exposed: Data.PortableEntryPoint (used by NonVirtualEntry2MethodDesc), FunctionTableIndexRangeSection, and the virtual-IP range list added in #133917. The contract docs under docs/design/datacontracts would need a matching update.
Description
On
FEATURE_PORTABLE_ENTRYPOINTStargets (currently WebAssembly), a method's entry point slot holds aPortableEntryPointaddress. The native runtime maps that address to a resolvable code start before handing it to diagnostics:GetInterpreterCodeFromEntryPointIfPresent(src/coreclr/vm/precode.cpp) returns the interpreter bytecode for interpreted methods.GetDiagnosticCodeStartFromEntryPoint(same file, shared by EventPipe method events andRuntimeMethodHandle_GetNativeCode) additionally maps native R2R portable entry points, whose actual code is a function-table index, to the synthetic virtual IP registered throughExecutionManager::AddVirtualIPRange.The cDAC does neither:
RuntimeTypeSystem_1.GetNativeCodereturns the raw entry-point slot value.PrecodeStubs_1.GetInterpreterCodeFromInterpreterPrecodeIfPresentonly recognizes interpreterStubPrecodes and has no portable-entry-point case, so it returns thePortableEntryPointaddress unchanged.As a result, SOS method data such as
DacpMethodDescData.NativeCodeAddrand rejitNativeCodeAddr(SOSDacImpl.cs) should report aPortableEntryPointaddress on wasm for both interpreted and R2R methods. That address does not resolve throughExecutionManagerlookups (GetCodeBlockHandle,FindVirtualIPRangeSection).This was found by code inspection while fixing #134145. It has not been reproduced against a live wasm target.
Suggested direction
When the portable-entrypoints feature flag is enabled, mirror the native mapping for a portable entry point:
FunctionTableIndexRangeSectiondata (already read by the wasm stack walk), the owningReadyToRunInfo.MinVirtualIP, and the containing non-funcletRUNTIME_FUNCTION, matchingExecutionManager::GetWasmVirtualIPFromFunctionTableIndex.The pieces are already exposed:
Data.PortableEntryPoint(used byNonVirtualEntry2MethodDesc),FunctionTableIndexRangeSection, and the virtual-IP range list added in #133917. The contract docs underdocs/design/datacontractswould need a matching update.Note
This issue was drafted with GitHub Copilot.