-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NativeAOT-LLVM] Implement two-pass exception handling #2284
[NativeAOT-LLVM] Implement two-pass exception handling #2284
Conversation
353b548
to
b501ae4
Compare
b501ae4
to
d3fd459
Compare
@dotnet/nativeaot-llvm |
I understand why we can't use the native stack for |
It is a very good question - why not use the shadow stack for such
I also considered allocating a pinned managed array, this would have been the simplest and most robust solution of all, but also the least performant (so I rejected it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Implements the two-pass system which #2145 laid the groundwork for.
The general idea is that we use native exception handling for the first pass, caching second-pass handlers in a linked list, to be invoked in the second pass. With this, our EH semantics should align fully with .NET proper modulo bugs.
One area where a two-pass scheme like this causes problems is dynamic stack allocation. We can no longer use the native stack in cases where the underlying data may escape into handlers, and so much of this change is focused on adding the implementation and tests for another kind of "stack" - "the dynamic stack", a specialized allocator, used only for
localloc
s in methods with EH. This allocator tracks the shadow stack to know how much state to release and is invoked by codegen on method return (handling normal flow) and by the dispatchers at the very end of the second pass (handling exceptional flow).Contributes to #2169.