-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix interpreter delegate args alignment #122163
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
Fix interpreter delegate args alignment #122163
Conversation
The recent fix to handle alignment of the first argument of a delegate call when we were removing the delegate obj from the stack was not complete. It only handled the case when the first argument required 16 byte alignment. But the same issue exists if any of the args requires this alignment. This change fixes it by finding the first argument that requires 16 byte alignment and then moving the args before that as usual and moving that arg and all following ones to 16 byte aligned location. This preserves the alignment for the rest of the stuff too.
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 bug in the interpreter's delegate argument alignment handling when removing the delegate object from the argument list. The previous fix only handled the case where the first argument required 16-byte alignment, but the issue also occurred when any argument required this alignment.
Key Changes:
- Modified the compiler to calculate the size of all arguments up to (but not including) the first 16-byte aligned argument
- Updated the runtime execution to properly shift arguments in two phases: non-aligned arguments first, then aligned arguments to their correct 16-byte boundaries
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/interpreter/compiler.cpp | Changed from calculating offset of first target argument to calculating cumulative size of all target arguments before the first 16-byte aligned argument |
| src/coreclr/vm/interpexec.cpp | Modified argument shifting logic to use two separate memmove operations: one for non-aligned arguments and one for aligned arguments, preserving 16-byte alignment where required |
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
davidwrighton
left a comment
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.
Copilot looks like it might have a point, but otherwise things look good.
Co-authored-by: Copilot <[email protected]>
The recent fix to handle alignment of the first argument of a delegate call when we were removing the delegate obj from the stack was not complete. It only handled the case when the first argument required 16 byte alignment. But the same issue exists if any of the args requires this alignment.
This change fixes it by finding the first argument that requires 16 byte alignment and then moving the args before that as usual and moving that arg and all following ones to 16 byte aligned location. This preserves the alignment for the rest of the stuff too.