Repository navigation
Share arm64 EH funclet call helpers and align arm64 funclet ABI with x64 - #137168
Conversation
Funclets on arm64 now save only FP and LR, like funclets on x64 do not save any callee-saved
registers. The runtime helpers that call funclets save all callee-saved registers instead.
- JIT: the arm64 funclet frame is FP/LR plus the outgoing argument space. This removes the five
funclet frame types and the padding that kept funclet frames in sync with the main frame.
- CallEHFunclet and CallEHFilterFunclet live in runtime/arm64/EHHelpers.{S,asm} and are shared
by CoreCLR and NativeAOT, following the x64 template.
- NativeAOT pops the ExInfos in arch-neutral code and resumes after a catch through
RhpResumeAfterCatch, like x64.
- ReadyToRun major version 34, since older runtimes do not preserve the callee-saved registers
around filter funclets.
Co-authored-by: Cursor <[email protected]>
|
Azure Pipelines: Successfully started running 7 pipeline(s). 8 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
SuperPMI asm diffs for linux-arm64 (x64-hosted checked arm64 JIT,
There are no size regressions; for example, libraries.crossgen2 has 13,049 contexts with diffs, of which 13,046 are smaller and 3 are the same size. A typical funclet that used to save a callee-saved register pair: G_M42448_IG07: ; funclet prolog
- stp fp, lr, [sp, #-0x20]!
- stp x19, x20, [sp, #0x10]
+ stp fp, lr, [sp, #-0x10]!
...
G_M42448_IG09: ; funclet epilog
- ldp x19, x20, [sp, #0x10]
- ldp fp, lr, [sp], #0x20
+ ldp fp, lr, [sp], #0x10
ret lr |
…defs Co-authored-by: Cursor <[email protected]>
|
WASI SDK download failure is #135025. |
There was a problem hiding this comment.
🔵 Needs a closer look
The coupled ARM64 funclet ABI, GC, and unwind changes require Windows and Unix EH/GC-stress and native-unwind validation beyond the static review performed.
No open issues 🎉
What changed in this PR
Extends the shared exception-handling helpers from #136639 to ARM64 and aligns ARM64 funclets with the x64 calling convention, addressing the frame-layout simplifications tracked in #114893.
Changes:
- Simplifies JIT-generated funclet frames to save only LR plus outgoing argument space, removing obsolete frame variants and stress-mode support.
- Shares ARM64 funclet helpers between CoreCLR and NativeAOT, updating register preservation, stack unwinding, and NativeAOT catch resumption.
- Advances ReadyToRun to version 34.0 for the changed calling convention.
| File | Description |
|---|---|
src/coreclr/vm/eetwain.cpp |
Passes the ARM64 context to the filter helper. |
src/coreclr/vm/CMakeLists.txt |
Includes shared ARM64 exception helpers. |
src/coreclr/vm/arm64/AsmMacros_Shared.h |
Adds context-based register-loading macros. |
src/coreclr/vm/arm64/asmhelpers.S |
Removes superseded Unix funclet helpers. |
src/coreclr/vm/arm64/asmhelpers.asm |
Removes superseded Windows funclet helpers. |
src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs |
Updates managed ReadyToRun constants to 34.0. |
src/coreclr/runtime/arm64/EHHelpers.S |
Adds shared Unix funclet helpers with register preservation. |
src/coreclr/runtime/arm64/EHHelpers.asm |
Adds shared Windows funclet helpers with register preservation. |
src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp |
Updates helper recognition and frame unwinding. |
src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h |
Updates NativeAOT ReadyToRun constants to 34.0. |
src/coreclr/nativeaot/Runtime/CMakeLists.txt |
Includes shared ARM64 helpers in NativeAOT. |
src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.S |
Replaces Unix funclet helpers with catch resumption and simplifies propagation. |
src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm |
Replaces Windows funclet helpers with catch resumption. |
src/coreclr/nativeaot/Runtime/arm64/AsmMacros_Shared.h |
Adds register load/store macros using NativeAOT’s register display. |
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs |
Updates ARM64 helper imports and propagation signature. |
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs |
Routes ARM64 dispatch through shared helpers and explicit exception-record cleanup. |
src/coreclr/jit/lclvars.cpp |
Removes handling for the obsolete stress mode. |
src/coreclr/jit/jitconfigvalues.h |
Removes documentation for stress mode 3. |
src/coreclr/jit/codegencommon.cpp |
Removes obsolete funclet-frame initialization. |
src/coreclr/jit/codegenarm64.cpp |
Simplifies funclet prologs, epilogs, and frame calculations. |
src/coreclr/jit/codegen.h |
Reduces funclet frame metadata and removes obsolete state. |
src/coreclr/inc/readytorun.h |
Raises current and minimum major versions to 34 and documents the ABI change. |
Review effort: Balanced
Co-authored-by: Cursor <[email protected]>
|
#137200 sits on top of these changes and ports riscv64 and loongarch64 on the same plan (and unifies JIT a bit more). |
…_GETTHREAD on arm64 Co-authored-by: Cursor <[email protected]>
…rm64' into chore/share-eh-funclet-helpers-arm64
…64 and arm64 Co-authored-by: Cursor <[email protected]>
AndyAyersMS
left a comment
There was a problem hiding this comment.
JIT changes LGTM. Much simpler.
@jakobbotsch maybe you can also take a look.
jakobbotsch
left a comment
There was a problem hiding this comment.
JIT side looks great to me as well.
Built on top of #137168. Funclets on riscv64 and loongarch64 now save only RA, like arm64. The runtime helpers that call funclets save all callee-saved registers instead. - JIT: the funclet frame is RA plus the outgoing argument space, shared with arm64. - CallEHFunclet and CallEHFilterFunclet live in runtime/{riscv64,loongarch64}/EHHelpers.S and are shared by CoreCLR and NativeAOT, following the arm64 template. - NativeAOT pops the ExInfos in arch-neutral code and resumes after a catch through RhpResumeAfterCatch. The unused RhpCallPropagateExceptionCallback is removed from these architectures since FEATURE_OBJCMARSHAL is Apple-only. - With all 64-bit targets on the shared helpers, the AMD64/ARM64 conditions become TARGET_64BIT. --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
Follow-up to #136639 for arm64. As discussed in #136639 (comment), this also aligns the funclet calling convention produced by the JIT on arm64 with x64 (https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/clr-abi.md#registers-on-entry-to-a-funclet), which is the second item of #114893.
JIT
str lr, [sp, #-16]!followed bysub sp, sp, #outszif needed. This deletes the five funclet frame types and the varargs/MonitorAcquired/async padding that kept funclet frames in sync with the main frame (the first item of Improve codegen of funclet prologs #114893), along with theJitSaveFpLrWithCalleeSavedRegisters=3stress mode that only forced funclet frame type 5.Runtime
CallEHFuncletandCallEHFilterFuncletmove tosrc/coreclr/runtime/arm64/EHHelpers.{S,asm}and are shared by CoreCLR and NativeAOT, using the x64 template: per-runtimeLOAD_FUNCLET_REGISTERS/LOAD_FUNCLET_FRAME_POINTER/STORE_FUNCLET_REGISTERSmacros in each runtime'sAsmMacros_Shared.hload from theCONTEXTon CoreCLR and through theREGDISPLAYon NativeAOT, and theTSF_DoNotTriggerGctoggle and register write-back are underFEATURE_NATIVEAOT.CallEHFuncletdid not save d8-d15, andCallEHFilterFuncletsaved only fp/lr). The frame is SP-based on both runtimes; NativeAOT's old helpers used an FP-based CFA and then overwrote FP, which broke native backtraces through them.RhpCallCatchFunclet/RhpCallFinallyFunclet/RhpCallFilterFuncletare removed, catch resume goes throughRhpResumeAfterCatchafterRhpPopExInfoin arch-neutral code,RhpCallPropagateExceptionCallbackno longer pops ExInfos, andUnwindFuncletInvokeThunkfollows the new frame layout.