-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[release/10.0] JIT: Use r9,r10 for GS cookie check in Swift reverse pinvokes #120744
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
Conversation
Swift returns values in r8, so it cannot be used for the cookie check. Switch it to r9,r10 instead.
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.
Pull Request Overview
This PR fixes a regression in the JIT compiler where return values from Swift reverse pinvokes were corrupted when 4 registers were used for return values and the method required a GS (Guard Stack) cookie check. The fix changes the registers used for GS cookie checks in Swift calling convention from R8/R9 to R9/R10, avoiding conflicts with Swift return value registers.
- Updates register allocation for GS cookie checks in Swift calling convention
- Prevents corruption of Swift reverse pinvoke return values when using unsafe code
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
|
|
Since this PR is targeting release/10.0, this is a reminder that code complete is Monday November 17. If you want the changes in the PR in the release, please merge it on time. |
|
Won't push this for servicing given Swift reverse pinvoke + GS cookie check + macOS x64 requirements, and no customer reports. |
Customer Impact
The JIT corrupts return values from x64 Swift reverse pinvokes when 4 registers are used to return in if the method simultaneously uses unsafe value types that induce a GS cookie check.
Regression
Introduced by #119864.
Testing
Internal stress testing (that forces GS cookie check) caught this in our existing Swift tests.
Risk
Low. Change only affects Swift reverse pinvokes with GS cookie checks.