Skip to content

Fix assumptions about PEP from the JIT / aot compiler code - #133546

Open
jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:dev/jtschuster/wasm-jit-pep
Open

Fix assumptions about PEP from the JIT / aot compiler code#133546
jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:dev/jtschuster/wasm-jit-pep

Conversation

@jtschuster

Copy link
Copy Markdown
Member

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jtschuster jtschuster added this to the 12.0.0 milestone Sep 9, 2026
@jtschuster jtschuster self-assigned this Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 22:52
@jtschuster jtschuster added arch-wasm WebAssembly architecture area-NativeAOT-coreclr labels Sep 9, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@jkotas
jkotas requested review from a team and adamperlin September 9, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new shared getWasmTypeSymbol uses an unchecked nuintint 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 WasmLowering to ReadyToRun builds.
  • Move getWasmTypeSymbol implementation into shared CorInfoImpl.cs, and add a NodeFactory overload to build Wasm type nodes from CorInfoWasmType[].
  • Update Wasm JIT lowering/codegen to allow direct calls when JIT_FLAG_PORTABLE_ENTRY_POINTS is 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

Comment on lines +3682 to +3685
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;

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.

Not needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-NativeAOT-coreclr

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants