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: boost inlining when callee unboxes an arg #110596

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndyAyersMS
Copy link
Member

Especially so if the caller is passing an exact type. This may lead to the JIT being able to stack allocate the box and promote the underlying payload.

Fixes #104479

Especially so if the caller is passing an exact type. This may lead
to the JIT being able to stack allocate the box and promote the underlying
payload.

Fixes dotnet#104479
@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 Dec 10, 2024
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

@MihuBot

@AndyAyersMS
Copy link
Member Author

On the example from #104479:

; Method Program:<<Main>$>g__BoxTest|0_0():int (FullOpts)
G_M15828_IG01:  ;; offset=0x0000
       sub      rsp, 40
						;; size=4 bbWeight=1 PerfScore 0.25

G_M15828_IG02:  ;; offset=0x0004
       mov      ecx, 42
       call     [System.Number:Int32ToDecStr(int):System.String]
       mov      rdx, rax
       mov      rcx, 0x7FFC28EF66C0      ; Program:<<Main>$>g__Consume|0_2[System.String](System.String)
       call     [Program:<<Main>$>g__Consume|0_2[System.__Canon](System.__Canon)]
       mov      eax, 42
						;; size=35 bbWeight=1 PerfScore 7.00

G_M15828_IG03:  ;; offset=0x0027
       add      rsp, 40
       ret      
						;; size=5 bbWeight=1 PerfScore 1.25
; Total bytes of code: 4

SPMI sees some diffs and quite a few missed contexts.

MihuBot did not see many diffs, however:

15 total methods with Code Size differences (0 improved, 15 regressed), 232918 unchanged.

So we may need a bespoke SPMI to really evaluate the imapact here.

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.

A simple method that performs unboxing is considered unprofitable inlinee, preventing box stack allocation
1 participant