Skip to content

win-x86: Replace "ret n" thunks with assembly code #115089

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

Merged
merged 3 commits into from
Apr 28, 2025

Conversation

filipnavara
Copy link
Member

@filipnavara filipnavara commented Apr 27, 2025

Replace x86 COM "ret n" thunks with assembly code that emulates "ret [n]" for an "[n]" specified using a variable value stored in register.

"ret <n>" for an "<n>" specified using a variable value stored
in register.
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 27, 2025
@filipnavara
Copy link
Member Author

The motivation is mainly to reduce the number of unnecessary usages of ExecutableWriteHolder for dynamic codegen. While the assembly code is not the prettiest due to restriction to use only single GP register it's still simple arithmetic instead of an indirect jump. Given the code around it the performance difference should be negligable. We still use ret so call-ret prediction for speculative execution should work just fine.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an existing pattern used for this in this .asm file. Would it make sense to do the same here?

@jkotas
Copy link
Member

jkotas commented Apr 28, 2025

/ba-g deadletter

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants