Repository navigation
Conversation
|
Azure Pipelines: Successfully started running 5 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 |
09249cd to
548f7c9
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
NativeAOT exception-handling and frame ABI changes across six architectures require runtime validation beyond static review to establish GC relocation, hijack recovery, unwind behavior, and Windows CET/CFG correctness.
No open issues 🎉
What changed in this PR
This PR reduces duplication between NativeAOT and CoreCLR by sharing transition-frame assembly macros and centralizing NativeAOT exception setup in C++ workers.
Changes:
- Moves transition-block macros into shared architecture files and updates NativeAOT interface dispatch to call
RhpCidResolvedirectly. - Refactors throw helpers to capture the throw-site context, with shared workers managing
ExInfoand dedicated assembly helpers entering managed exception dispatch. - Simplifies managed transition-block offsets, replaces funclet-related
DWORD_PTRtypes withUINT_PTR, and corrects stale comments.
| File | Description |
|---|---|
| src/coreclr/vm/exceptionhandling.cpp | Uses UINT_PTR for funclet results. |
| src/coreclr/vm/eetwain.cpp | Updates funclet result types and comments. |
| src/coreclr/vm/arm64/asmmacros.h | Removes macros moved to shared ARM64 code. |
| src/coreclr/vm/amd64/AsmMacros.inc | Removes macros moved to shared AMD64 code. |
| src/coreclr/runtime/riscv64/AsmMacros_Unix.inc | Hosts shared RISC-V transition-block macros. |
| src/coreclr/runtime/loongarch64/AsmMacros_Unix.inc | Hosts shared LoongArch transition-block macros. |
| src/coreclr/runtime/arm64/AsmMacros_Windows.h | Hosts shared Windows ARM64 transition-block macros. |
| src/coreclr/runtime/arm64/AsmMacros_Unix.inc | Hosts shared Unix ARM64 transition-block macros. |
| src/coreclr/runtime/arm/AsmMacros_Unix.inc | Hosts shared ARM transition-block macros. |
| src/coreclr/runtime/amd64/AsmMacros_Windows.inc | Hosts shared Windows AMD64 transition-block macros. |
| src/coreclr/runtime/amd64/AsmMacros_Unix.inc | Hosts shared Unix AMD64 transition-block macros. |
| src/coreclr/pal/inc/unixasmmacrosriscv64.inc | Removes relocated RISC-V macros. |
| src/coreclr/pal/inc/unixasmmacrosloongarch64.inc | Removes relocated LoongArch macros. |
| src/coreclr/pal/inc/unixasmmacrosarm64.inc | Removes relocated ARM64 macros. |
| src/coreclr/pal/inc/unixasmmacrosarm.inc | Removes relocated ARM macros. |
| src/coreclr/pal/inc/unixasmmacrosamd64.inc | Removes relocated AMD64 macros. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosriscv64.inc | Defines floating-point argument save-area size. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc | Defines floating-point argument save-area size. |
| src/coreclr/nativeaot/Runtime/unix/unixasmmacrosarm64.inc | Defines the q0–q7 save-area size. |
| src/coreclr/nativeaot/Runtime/thread.h | Declares throw-site unhijacking helper. |
| src/coreclr/nativeaot/Runtime/thread.cpp | Centralizes throw-site unhijacking logic. |
| src/coreclr/nativeaot/Runtime/riscv64/UniversalTransition.S | Uses shared macros and direct dispatch resolution. |
| src/coreclr/nativeaot/Runtime/riscv64/ExceptionHandling.S | Delegates exception setup to shared workers. |
| src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S | Simplifies transition handoff using t5. |
| src/coreclr/nativeaot/Runtime/loongarch64/UniversalTransition.S | Uses shared macros and direct dispatch resolution. |
| src/coreclr/nativeaot/Runtime/loongarch64/ExceptionHandling.S | Delegates exception setup to shared workers. |
| src/coreclr/nativeaot/Runtime/loongarch64/DispatchResolve.S | Removes obsolete resolver-address setup. |
| src/coreclr/nativeaot/Runtime/i386/ExceptionHandling.asm | Uses shared workers and new dispatcher-call helpers. |
| src/coreclr/nativeaot/Runtime/i386/AsmMacros.inc | Declares decorated exception-worker symbols. |
| src/coreclr/nativeaot/Runtime/EHHelpers.cpp | Adds shared exception setup and dispatch workers. |
| src/coreclr/nativeaot/Runtime/arm64/UniversalTransition.S | Uses shared macros and direct dispatch resolution. |
| src/coreclr/nativeaot/Runtime/arm64/UniversalTransition.asm | Shares transition layout while retaining guarded dispatch. |
| src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.S | Uses shared workers and dispatcher-call frames. |
| src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.asm | Updates Windows throw helpers to use shared workers. |
| src/coreclr/nativeaot/Runtime/arm64/DispatchResolve.S | Passes the dispatch cell directly in x11. |
| src/coreclr/nativeaot/Runtime/arm64/DispatchResolve.asm | Removes obsolete transition argument setup. |
| src/coreclr/nativeaot/Runtime/arm64/AsmMacros.h | Adds save-area size and worker declarations. |
| src/coreclr/nativeaot/Runtime/arm/UniversalTransition.S | Uses shared transition macros and r12 dispatch cell. |
| src/coreclr/nativeaot/Runtime/arm/ExceptionHandling.S | Uses shared workers and dispatcher-call frames. |
| src/coreclr/nativeaot/Runtime/arm/DispatchResolve.S | Removes hidden stack arguments for transition calls. |
| src/coreclr/nativeaot/Runtime/amd64/UniversalTransition.S | Uses shared macros and direct dispatch resolution. |
| src/coreclr/nativeaot/Runtime/amd64/UniversalTransition.asm | Shares transition layout while retaining guarded dispatch. |
| src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.S | Shares context capture and delegates exception setup. |
| src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.asm | Uses shared workers and dispatcher-call frames. |
| src/coreclr/nativeaot/Runtime/amd64/DispatchResolve.S | Removes obsolete resolver-address setup. |
| src/coreclr/nativeaot/Runtime/amd64/DispatchResolve.asm | Removes obsolete resolver-address setup. |
| src/coreclr/nativeaot/Runtime/amd64/AsmMacros.inc | Adds outgoing argument-space size and worker declarations. |
| src/coreclr/nativeaot/Common/src/Internal/Runtime/TransitionBlock.cs | Replaces unused layout abstractions with this offsets. |
| src/coreclr/jit/codegenarmarch.cpp | Corrects a varargs comment; no code behavior change. |
| src/coreclr/inc/eetwain.h | Aligns funclet declarations on UINT_PTR. |
Review effort: Balanced
jkotas
left a comment
There was a problem hiding this comment.
This is again a type of change that would be easier to review and polish for a single arch first.
- RhpUniversalTransitionTailCall becomes RhpInterfaceDispatchSlow, like in CoreCLR. It is built with the PROLOG_WITH_TRANSITION_BLOCK and EPILOG_WITH_TRANSITION_BLOCK_TAILCALL macros, which move from CoreCLR to the shared runtime/<arch> macro files, and calls RhpCidResolve directly. The arguments are still reported conservatively. - The throw helpers set up and link their ExInfo with RhpPushExInfo instead of doing it in assembly. The unhijack in RhpThrowEx is removed, since it is not tail called. Also removes leftovers of the old funclet ABI: DWORD_PTR in EECodeManager::CallFunclet and a stale PSPSym comment. Co-authored-by: Cursor <[email protected]>
548f7c9 to
7b5cac0
Compare
The hijack code passes the return address from the stack, which has the Thumb bit set on arm, so the return address of a thunk such as RhpInterfaceDispatchSlow did not match its label. Co-authored-by: Cursor <[email protected]>
`INLINE_GETTHREAD` saves `x0` and `lr` around the TLS lookup, and the `EPILOG_RESTORE_REG_PAIR_INDEXED` that pops them emits `.cfi_restore` for both. That resets `lr` to its rule at function entry, which is wrong in functions that saved `lr` in their prologue before using the macro, such as `CallEHFunclet`. For the rest of such a function the CFI claims that `lr` holds the caller's return address, so after the call into a funclet lldb computes `CallEHFunclet` as its own caller and stops unwinding. Wrap the macro in `.cfi_remember_state` / `.cfi_restore_state` so the caller's unwind rules are restored as they were. Co-authored-by: Cursor <[email protected]>
@jkotas, I can split it in four parts: x64, arm64, {RV,LA}64 and 32-bit if that's preferred. |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
`ReturnAddressToCanonicalPC` in `IsValidReturnAddress` also strips the PAC signature on arm64, but its callers pass either an already stripped return address or an unsigned context IP. Only arm needed a change, so clear the Thumb bit at the hijack call site instead, the same way arm64 calls `PacStripPtr` there. Co-authored-by: Cursor <[email protected]>
The hijack code passes the return address from the stack, so let IsValidReturnAddress canonicalize it instead of duplicating ReturnAddressToCanonicalPC at the call site. Co-authored-by: Cursor <[email protected]>
RhpUniversalTransitionTailCallbecomesRhpInterfaceDispatchSlow, like in CoreCLR. It is built with thePROLOG_WITH_TRANSITION_BLOCK/EPILOG_WITH_TRANSITION_BLOCK_TAILCALLmacros, which move from CoreCLR to the sharedruntime/<arch>macro files, and callsRhpCidResolvedirectly. The arguments are still reported conservatively.ExInfowithRhpPushExInfoinstead of doing it in assembly. The unhijack inRhpThrowExis removed, since it is not tail called.Also removes leftovers of the old funclet ABI:
DWORD_PTRinEECodeManager::CallFuncletand a stale PSPSym comment.