Skip to content

JIT: Improve wrapper method inliner heuristic #113266

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hez2010
Copy link
Contributor

@hez2010 hez2010 commented Mar 7, 2025

Extracted from #113256, with additional improvements for boxed structs return.

  • Extend support for newarr, newobj and initobj
  • Recognize {{ldloc.*} + box} + ret

@EgorBo

@Copilot Copilot AI review requested due to automatic review settings March 7, 2025 17:49
@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 Mar 7, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 7, 2025
Copy link
Contributor

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

@hez2010
Copy link
Contributor Author

hez2010 commented Mar 7, 2025

@MihuBot

@hez2010
Copy link
Contributor Author

hez2010 commented Mar 7, 2025

Diffs from MihuBot look promising to me.

@hez2010
Copy link
Contributor Author

hez2010 commented Mar 8, 2025

@MichalStrehovsky NativeAOT failures seem like an ilc preexisting bug?

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky NativeAOT failures seem like an ilc preexisting bug?

The scanner needs to precompute everything RyuJIT is going to look at. Looks like in this case RyuJIT decided to inline past a generic recursion cutoff.

Maybe a fix would be to add a call to NodeFactory.TypeSystemContext.DetectGenericCycles(caller, callee) some place like here:

public bool CanInline(MethodDesc caller, MethodDesc callee)
{
return _inliningPolicy.CanInline(caller, callee);
}

But I'm afraid RyuJIT will ask canInline with something useless like Foo<_Canon> inlining Foo<_Canon> instead of a useful thing like Foo<Gen<Gen<Gen<X>>>. If so, I don't immediately know what the fix could be, besides throwing away the managed scanner and replacing it with RyuJIT.

@JulieLeeMSFT JulieLeeMSFT requested a review from EgorBo April 7, 2025 16:18
@EgorBo
Copy link
Member

EgorBo commented Apr 21, 2025

@MihuBot

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 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