Skip to content
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

JIT: more inlining with EH prep work #113023

Merged
merged 2 commits into from
Mar 1, 2025

Conversation

AndyAyersMS
Copy link
Member

@AndyAyersMS AndyAyersMS commented Feb 28, 2025

Don't try an inline managed methods with unmanaged calling conventions. This mainly copes with x86 where unmanaged calling conventions use reversed arg order, but I've disabled it in general. No diffs as these methods seem to always include EH.

Remove uses of compXcptnsCount as this goes stale whenever we clone or remove EH, or (eventually) inline methods with EH. Instead, rely on compHndBBtabCount.

Defer allocating x86's shadow SP var and area until later in jitting, so this reflects any changes in EH table structure. In particular we often are able to eliminate EH in part or all together and this saves a low-offset allocation and so leads to some nice code size savings on x86.

Also on x86 remove the runtime-dependent catch class case from the computation for keeping this alive, as we now transform such into runtime lookups in filters (that may well keep this alive).

Contributes to #108900.

Don't try an inline managed methods with unmanaged calling conventions.
This mainly copes with x86 where unmanaged calling conventions use reversed
arg order, but I've disabled it in general. No diffs as these methods seem
to always include EH.

Remove uses of `compXcptnsCount` as this goes stale whenever we clone or
remove EH, or (eventually) inline methods with EH. Instead, rely on
`compHndBBtabCount`.

Defer allocating x86's shadow SP var and area until later in jitting,
so this reflects any changes in EH table structure. In particular we
often are able to eliminate EH in part or all together and this saves
a low-offset allocation and so leads to some nice code size savings on
x86.

Also on x86 remove the runtime-dependent catch class case from the
computation for keeping this alive, as we now transform such into
runtime lookups in filters (that may well keep this alive).
@Copilot Copilot bot review requested due to automatic review settings February 28, 2025 21:33
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 28, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

@AndyAyersMS
Copy link
Member Author

Splitting off more changes from #112998.

Should be zero-diff, except x86.

@EgorBo PTAL
cc @dotnet/jit-contrib

Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@AndyAyersMS
Copy link
Member Author

Diffs

x86 shows good savings, everything else unaffected. Oddly there are some minopts diffs, which I was not expecting. Going to take a look at some of those.

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Mar 1, 2025

I may back out the keep alive this changes, perhaps there is more going on there (edit: seems like they were related to the too small nesting level number)

Seems like we're still leaving some size wins on the table, eg we needlessly set up and tear down the frame if there was EH and we eliminated it:

image

Will hold off on further improvements in this PR and look at that as a follow-up.

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Mar 1, 2025

Here is a sample minopts diff, the shadow area is 4 bytes smaller which alters the prolog zeroing strategy:

image

ehMaxHndNestingCount needs to be one greater than the maxumum handler nesting. Will fix.

@AndyAyersMS
Copy link
Member Author

CI not triggering, let me bounce and see if that fixes it.

@AndyAyersMS AndyAyersMS closed this Mar 1, 2025
@AndyAyersMS AndyAyersMS reopened this Mar 1, 2025
@AndyAyersMS
Copy link
Member Author

Updated diffs ... still a few in minopts.

@MichalPetryka
Copy link
Contributor

@MihuBot

@AndyAyersMS
Copy link
Member Author

Looks like these remaining minopts diffs are in methods with unreachable EH (not imported even in Tier0) and we now don't allocate the shadow SP slots there either.

@AndyAyersMS AndyAyersMS merged commit 12bf864 into dotnet:main Mar 1, 2025
114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants