Skip to content

Bring x86, ARM and WASM EH helpers to x64/arm64 plan - #137256

Merged
jkotas merged 2 commits into
dotnet:mainfrom
am11:chore/share-eh-funclet-helpers-32bit
Nov 12, 2026
Merged

jkotas merged 2 commits into
dotnet:mainfrom
am11:chore/share-eh-funclet-helpers-32bit

Conversation

@am11

@am11 am11 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

With this change, all architectures call funclets through CallEHFunclet and CallEHFilterFunclet, and
the architecture conditions around the funclet helpers are removed.

  • ARM: funclets now save only LR. CallEHFunclet and CallEHFilterFunclet live in
    runtime/arm/EHHelpers.S and are shared by CoreCLR and NativeAOT. They save r4-r11, lr and d8-d15
    with an SP based frame, since r7 and r11 are set to the parent's values before calling the funclet.
  • x86: funclets already did not save any registers, so only the helpers change. They live in
    runtime/i386/EHHelpers.asm and are shared by CoreCLR and NativeAOT. CoreCLR calls them with
    __fastcall and NativeAOT with the managed calling convention, which passes the stack arguments in
    reverse order, so the stack argument offsets come from the per-runtime AsmMacros_Shared.inc.
  • WASM: NativeAOT implements CallEHFunclet, CallEHFilterFunclet and RhpResumeAfterCatch on top of
    the existing funclet call bridges, and CoreCLR implements CallEHFunclet and CallEHFilterFunclet
    over its bridges, which removes the WASM specific path in EECodeManager::CallFunclet.
  • NativeAOT pops the ExInfos in arch-neutral code and resumes after a catch through
    RhpResumeAfterCatch on all architectures.

Fixes #114893

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 10, 2026
@azure-pipelines

azure-pipelines Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@am11

am11 commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

cc @jkotas

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment thread src/coreclr/jit/codegen.h Resolved
Comment thread src/coreclr/jit/codegen.h Resolved
With this change, all architectures call funclets through CallEHFunclet and CallEHFilterFunclet, and
the architecture conditions around the funclet helpers are removed.

- ARM: funclets now save only LR. CallEHFunclet and CallEHFilterFunclet live in
  runtime/arm/EHHelpers.S and are shared by CoreCLR and NativeAOT. They save r4-r11, lr and d8-d15
  with an SP based frame, since r7 and r11 are set to the parent's values before calling the funclet.
- x86: funclets already did not save any registers, so only the helpers change. They live in
  runtime/i386/EHHelpers.asm and are shared by CoreCLR and NativeAOT. CoreCLR calls them with
  __fastcall and NativeAOT with the managed calling convention, which passes the stack arguments in
  reverse order, so the stack argument offsets come from the per-runtime AsmMacros_Shared.inc.
- WASM: NativeAOT implements CallEHFunclet, CallEHFilterFunclet and RhpResumeAfterCatch on top of
  the existing funclet call bridges, and CoreCLR implements CallEHFunclet and CallEHFilterFunclet
  over its bridges, which removes the WASM specific path in EECodeManager::CallFunclet.
- NativeAOT pops the ExInfos in arch-neutral code and resumes after a catch through
  RhpResumeAfterCatch on all architectures.

Contributes to dotnet#114893

Co-authored-by: Cursor <[email protected]>
@am11
am11 force-pushed the chore/share-eh-funclet-helpers-32bit branch from 6f4ff93 to dfa8705 Compare November 11, 2026 01:20
@am11
am11 marked this pull request as ready for review November 11, 2026 01:20
@jkotas
jkotas requested a balanced review from Copilot November 11, 2026 01:23
@jkotas

jkotas commented Nov 11, 2026

Copy link
Copy Markdown
Member

Contributes to #114893

Anything left in that issue after this gets merged?

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.

🔵 Needs a closer look

Coupled funclet ABI, unwind-layout, and GC-sensitive catch-resumption changes require ARM, x86, and WASM EH/GC-stress validation across CoreCLR and NativeAOT that this static-only review could not perform.

No open issues 🎉

What changed in this PR

This PR aligns x86, ARM, and WASM exception-handling funclet calls with the shared helper model used by x64 and ARM64. It contributes to #114893 by simplifying ARM funclet frames and consolidating runtime-specific helper code.

Changes:

  • Share x86 and ARM funclet invocation helpers between CoreCLR and NativeAOT, and adapt WASM bridges to the same interface.
  • Move ARM callee-saved register preservation into runtime helpers, simplifying JIT-generated funclet prologs and epilogs.
  • Unify NativeAOT exception-record cleanup and catch resumption, updating stack unwinding and build integration.
File Description
src/​coreclr/​vm/​wasm/​helpers.cpp Wraps WASM bridges in common funclet helpers.
src/​coreclr/​vm/​i386/​ehhelpers.asm Removes superseded CoreCLR-only x86 helpers.
src/​coreclr/​vm/​i386/​AsmMacros_Shared.inc Defines CoreCLR x86 argument offsets and register loads.
src/​coreclr/​vm/​eetwain.cpp Uses common funclet calls across architectures.
src/​coreclr/​vm/​CMakeLists.txt Includes shared x86 and ARM helpers.
src/​coreclr/​vm/​arm/​ehhelpers.S Removes migrated ARM funclet helpers.
src/​coreclr/​vm/​arm/​AsmMacros_Shared.h Adds ARM register loads from CoreCLR contexts.
src/​coreclr/​vm/​arm/​asmconstants.h Defines and validates the floating-point context offset.
src/​coreclr/​runtime/​i386/​EHHelpers.asm Adds shared x86 funclet invocation helpers.
src/​coreclr/​runtime/​arm/​EHHelpers.S Adds shared ARM helpers with register preservation.
src/​coreclr/​nativeaot/​Runtime/​wasm/​ExceptionHandling.cpp Adopts common helpers and separate catch resumption.
src/​coreclr/​nativeaot/​Runtime/​StackFrameIterator.cpp Updates helper recognition and x86/ARM frame unwinding.
src/​coreclr/​nativeaot/​Runtime/​i386/​ExceptionHandling.asm Replaces x86 invocation helpers with catch resumption.
src/​coreclr/​nativeaot/​Runtime/​i386/​AsmMacros_Shared.inc Adds NativeAOT x86 argument offsets and register access.
src/​coreclr/​nativeaot/​Runtime/​CMakeLists.txt Extends shared helper inclusion to x86 and ARM.
src/​coreclr/​nativeaot/​Runtime/​arm/​ExceptionHandling.S Replaces ARM invocation helpers with catch resumption.
src/​coreclr/​nativeaot/​Runtime/​arm/​AsmMacros_Shared.h Adds ARM register-display load and store macros.
src/​coreclr/​nativeaot/​Runtime.Base/​src/​System/​Runtime/​InternalCalls.cs Unifies managed helper declarations across architectures.
src/​coreclr/​nativeaot/​Runtime.Base/​src/​System/​Runtime/​ExceptionHandling.cs Unifies funclet dispatch, exception cleanup, and resumption.
src/​coreclr/​jit/​codegenarm.cpp Simplifies ARM funclet frames, prologs, and epilogs.
src/​coreclr/​jit/​codegen.h Shares the funclet frame descriptor with ARM.

Review effort: Balanced

@am11

am11 commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Nothing left: both ARM64 items went away with #137168, and this PR removes the remaining PSPSym padding from the ARM32 funclet frame, so I changed it to "Fixes".

Comment thread src/coreclr/jit/codegen.h Resolved

@jkotas jkotas left a comment

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.

Thank you!

@jkotas

jkotas commented Nov 12, 2026

Copy link
Copy Markdown
Member

/ba-g filled #137423 on the test failure

@jkotas
jkotas merged commit ed4824e into dotnet:main Nov 12, 2026
144 of 146 checks passed
@am11
am11 deleted the chore/share-eh-funclet-helpers-32bit branch November 12, 2026 15:29
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve codegen of funclet prologs

3 participants