Skip to content

[wasm][coreclr] Fix vtable issue and interpreter I4/I8 arithmetic#125376

Open
radekdoulik wants to merge 1 commit intodotnet:mainfrom
radekdoulik:clr-wasm-fix-vtable-and-i4-i8-arithmetic
Open

[wasm][coreclr] Fix vtable issue and interpreter I4/I8 arithmetic#125376
radekdoulik wants to merge 1 commit intodotnet:mainfrom
radekdoulik:clr-wasm-fix-vtable-and-i4-i8-arithmetic

Conversation

@radekdoulik
Copy link
Member

Fix #124222, there were 2 problems:

  1. prestub.cpp: When a stub-based method (delegate invoke, array ops) is prestubbed, use the method's own PortableEntryPoint rather than the stub's. This maintains the 1:1 MethodDesc-to-entrypoint mapping that GetMethodDescForSlot_NoThrow relies on, similar to previous FCall fix.

  2. interpreter/compiler.cpp: Enable I4/I8 mixed arithmetic widening on 32-bit targets by removing the TARGET_64BIT guard. On 32-bit WASM, ldloca results are bashed to StackTypeI (= I4), but IL like sin3double uses conv.i8 before arithmetic, producing I4 + I8 which was rejected as invalid. The widening to I8 already existed for 64-bit; now it applies unconditionally.

…32-bit

Fix dotnet#124222, there were 2 problems:

1. prestub.cpp: When a stub-based method (delegate invoke, array ops) is
   prestubbed, use the method's own PortableEntryPoint rather than the
   stub's. This maintains the 1:1 MethodDesc-to-entrypoint mapping that
   GetMethodDescForSlot_NoThrow relies on, similar to previous FCall fix.

2. interpreter/compiler.cpp: Enable I4/I8 mixed arithmetic widening on
   32-bit targets by removing the TARGET_64BIT guard. On 32-bit WASM,
   ldloca results are bashed to StackTypeI (= I4), but IL like sin3double
   uses conv.i8 before arithmetic, producing I4 + I8 which was rejected
   as invalid. The widening to I8 already existed for 64-bit; now it
   applies unconditionally.
@radekdoulik radekdoulik added this to the Future milestone Mar 10, 2026
Copilot AI review requested due to automatic review settings March 10, 2026 12:00
@radekdoulik radekdoulik added arch-wasm WebAssembly architecture area-VM-coreclr labels Mar 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two WASM/CoreCLR interpreter issues that surfaced as a vtable/MethodDesc mapping assert (issue #124222) and as invalid mixed-width integer arithmetic handling on 32-bit interpreter targets.

Changes:

  • CoreCLR prestub: when prestubbing stub-based methods under portable entrypoints, publish the method’s own PortableEntryPoint (and attach the stub’s interpreter data to it) to preserve a 1:1 MethodDesc to entrypoint mapping.
  • Interpreter: allow implicit I4 to I8 widening for mixed I4/I8 arithmetic on 32-bit targets by removing the TARGET_64BIT guard.
  • Tests: remove WASM-specific ActiveIssue suppression for the affected Methodical tests now that the runtime behavior is fixed.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/vm/prestub.cpp Ensures stub-based methods use their own portable entrypoint while reusing the stub’s interpreter data, preserving MethodDesc to entrypoint invariants.
src/coreclr/interpreter/compiler.cpp Enables I4/I8 mixed arithmetic widening on 32-bit interpreter targets to match expected IL numeric promotion behavior.
src/tests/JIT/Methodical/switch/switch6.il Removes WASM ActiveIssue gating tied to #124222.
src/tests/JIT/Methodical/flowgraph/bug619534/moduleHandleCache.cs Removes WASM ActiveIssue gating tied to #124222.
src/tests/JIT/Methodical/Boxing/morph/sin3double.il Removes WASM ActiveIssue gating tied to #124222 (keeps unrelated existing gating).

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

Labels

arch-wasm WebAssembly architecture area-VM-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][coreclr] ASSERT FAILED Expression: slotNumber >= GetNumVirtuals() || pMDRet == m_pDeclMT->GetMethodDescForSlot_NoThrow(slotNumber)

3 participants