Fix assumptions about PEP from the JIT / aot compiler code - #133546
Fix assumptions about PEP from the JIT / aot compiler code#133546jtschuster wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Azure Pipelines: Successfully started running 6 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
There was a problem hiding this comment.
🟡 Changes recommended
The new shared getWasmTypeSymbol uses an unchecked nuint→int cast for span length; a checked cast (and a basic pointer/length assert) would prevent truncation/overflow and unsafe copies on unexpected inputs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates Wasm JIT/AOT toolchain code to stop assuming Portable Entry Points (PEP) are always used, by gating PEP-specific behavior (NativeAOT vs ReadyToRun and JIT-flag-controlled behavior) and consolidating Wasm type symbol handling in the shared JitInterface implementation.
Changes:
- Gate Wasm signature PEP parameter emission in
WasmLoweringto ReadyToRun builds. - Move
getWasmTypeSymbolimplementation into sharedCorInfoImpl.cs, and add aNodeFactoryoverload to build Wasm type nodes fromCorInfoWasmType[]. - Update Wasm JIT lowering/codegen to allow direct calls when
JIT_FLAG_PORTABLE_ENTRY_POINTSis not set, and to conditionally include PEP in managed helper signatures.
File summaries
| File | Description |
|---|---|
| src/coreclr/tools/Common/JitInterface/WasmLowering.cs | Gates PEP parameter emission in Wasm signature construction to ReadyToRun builds. |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Adds shared getWasmTypeSymbol implementation for Wasm type symbol creation. |
| src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs | Removes the NativeAOT stub getWasmTypeSymbol in favor of shared implementation. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs | Removes the ReadyToRun-local getWasmTypeSymbol in favor of shared implementation. |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs | Adds WasmTypeNode(CorInfoWasmType[]) overload to support shared symbol creation. |
| src/coreclr/jit/lowerwasm.cpp | Makes direct-call eligibility depend on the PEP JIT flag rather than always forcing indirect. |
| src/coreclr/jit/codegenwasm.cpp | Allows direct helper call addresses when available and conditionally adjusts helper signatures/PEP pushing based on the PEP flag. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
| private CORINFO_WASM_TYPE_SYMBOL_STRUCT_* getWasmTypeSymbol(CorInfoWasmType* types, nuint typesSize) | ||
| { | ||
| CorInfoWasmType[] typeArray = new ReadOnlySpan<CorInfoWasmType>(types, (int)typesSize).ToArray(); | ||
|
|
|
|
||
| using ILCompiler; | ||
| using ILCompiler.DependencyAnalysis; | ||
| using ILCompiler.DependencyAnalysis.Wasm; |
In a number of places, the JIT or shared aot compiler code assume portable entrypoints are used. This isn't true for nativeaot, so those assumptions need to be gated on whether the JIT flag is set or
#ifdefed out from nativeaot code.Also, move getWasmType to the shared CorInfoImpl.cs.