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

Devirtualiazation and unboxing regression #11443

Closed
benaadams opened this issue Nov 11, 2018 · 7 comments
Closed

Devirtualiazation and unboxing regression #11443

benaadams opened this issue Nov 11, 2018 · 7 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@benaadams
Copy link
Member

Seen in dotnet/coreclr#20936 (comment)

For AsyncTaskMethodBuilder``1:AwaitUnsafeOnCompleted(byref,byref):this

https://github.com/dotnet/coreclr/blob/463ba889b0c010eb9c6f9807eaf0ab4ab5624450/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs#L382-L396

It looks like the boxing is back for ValueTaskAwaiter<T> and TaskAwaiter

G_M5080_IG02:
       488B4D10             mov      rcx, bword ptr [rbp+10H]
       488B5520             mov      rdx, bword ptr [rbp+20H]
       E8E3F6FFFF           call     AsyncTaskMethodBuilder`1:GetStateMachineBox(byref):ref:this
       488945E8             mov      gword ptr [rbp-18H], rax
       33D2                 xor      rdx, rdx
       488955E0             mov      qword ptr [rbp-20H], rdx
       488D55E0             lea      rdx, bword ptr [rbp-20H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E87EE8785F           call     CORINFO_HELP_BOX
       4885C0               test     rax, rax
       745B                 je       SHORT G_M5080_IG04
       488B5518             mov      rdx, bword ptr [rbp+18H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E866E8785F           call     CORINFO_HELP_BOX
       488945A8             mov      gword ptr [rbp-58H], rax
       488B55A8             mov      rdx, gword ptr [rbp-58H]
       48B9D0012EA0FA7F0000 mov      rcx, 0x7FFAA02E01D0
       E8AFD2785F           call     CORINFO_HELP_ISINSTANCEOFINTERFACE
       4885C0               test     rax, rax
       742C                 je       SHORT G_M5080_IG04
       488B4D18             mov      rcx, bword ptr [rbp+18H]
       E841EF8359           call     Unsafe:As(byref):byref
       488945D8             mov      bword ptr [rbp-28H], rax
       488B4DD8             mov      rcx, bword ptr [rbp-28H]
       488B09               mov      rcx, gword ptr [rcx]
       488B55E8             mov      rdx, gword ptr [rbp-18H]
       41B801000000         mov      r8d, 1
       E867268859           call     TaskAwaiter:UnsafeOnCompletedInternal(ref,ref,bool)
       90                   nop      

G_M5080_IG03:
       488D65F0             lea      rsp, [rbp-10H]
       5E                   pop      rsi
       5F                   pop      rdi
       5D                   pop      rbp
       C3                   ret      

G_M5080_IG04:
       33D2                 xor      rdx, rdx
       488955E0             mov      qword ptr [rbp-20H], rdx
       488D55E0             lea      rdx, bword ptr [rbp-20H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E805E8785F           call     CORINFO_HELP_BOX
       4885C0               test     rax, rax
       745E                 je       SHORT G_M5080_IG06
       488B5518             mov      rdx, bword ptr [rbp+18H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E8EDE7785F           call     CORINFO_HELP_BOX
       488945A0             mov      gword ptr [rbp-60H], rax
       488B55A0             mov      rdx, gword ptr [rbp-60H]
       48B910022EA0FA7F0000 mov      rcx, 0x7FFAA02E0210
       E836D2785F           call     CORINFO_HELP_ISINSTANCEOFINTERFACE
       4885C0               test     rax, rax
       742F                 je       SHORT G_M5080_IG06
       488B4D18             mov      rcx, bword ptr [rbp+18H]
       E898EDCDFF           call     Unsafe:As(byref):byref
       488945D0             mov      bword ptr [rbp-30H], rax
       4C8B45D0             mov      r8, bword ptr [rbp-30H]
       450FB64008           movzx    r8, byte  ptr [r8+8]
       488B4DD0             mov      rcx, bword ptr [rbp-30H]
       488B09               mov      rcx, gword ptr [rcx]
       488B55E8             mov      rdx, gword ptr [rbp-18H]
       E8EB258859           call     TaskAwaiter:UnsafeOnCompletedInternal(ref,ref,bool)
       90                   nop      

G_M5080_IG05:
       488D65F0             lea      rsp, [rbp-10H]
       5E                   pop      rsi
       5F                   pop      rdi
       5D                   pop      rbp
       C3                   ret      

G_M5080_IG06:
       33D2                 xor      rdx, rdx
       488955E0             mov      qword ptr [rbp-20H], rdx
       488D55E0             lea      rdx, bword ptr [rbp-20H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E889E7785F           call     CORINFO_HELP_BOX
       4885C0               test     rax, rax
       7479                 je       SHORT G_M5080_IG08
       488B5518             mov      rdx, bword ptr [rbp+18H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E871E7785F           call     CORINFO_HELP_BOX
       48894598             mov      gword ptr [rbp-68H], rax
       488B5598             mov      rdx, gword ptr [rbp-68H]
       48B980042EA0FA7F0000 mov      rcx, 0x7FFAA02E0480
       E8BAD1785F           call     CORINFO_HELP_ISINSTANCEOFINTERFACE
       4885C0               test     rax, rax
       744A                 je       SHORT G_M5080_IG08

G_M5080_IG07:
       488B5518             mov      rdx, bword ptr [rbp+18H]
       48B9701C31A0FA7F0000 mov      rcx, 0x7FFAA0311C70
       E842E7785F           call     CORINFO_HELP_BOX
       48894590             mov      gword ptr [rbp-70H], rax
       488B5590             mov      rdx, gword ptr [rbp-70H]
       48B980042EA0FA7F0000 mov      rcx, 0x7FFAA02E0480
       E84BD2785F           call     CORINFO_HELP_CHKCASTINTERFACE
       48894588             mov      gword ptr [rbp-78H], rax
       488B4D88             mov      rcx, gword ptr [rbp-78H]
       488B55E8             mov      rdx, gword ptr [rbp-18H]
       49BB70113246FA7F0000 mov      r11, 0x7FFA46321170
       3909                 cmp      dword ptr [rcx], ecx
       FF156D5EB8FF         call     [IStateMachineBoxAwareAwaiter:AwaitUnsafeOnCompleted(ref):this]
       EB29                 jmp      SHORT G_M5080_IG09

G_M5080_IG08:
       488B4DE8             mov      rcx, gword ptr [rbp-18H]
       49BB68113246FA7F0000 mov      r11, 0x7FFA46321168
       3909                 cmp      dword ptr [rcx], ecx
       FF154D5EB8FF         call     [IAsyncStateMachineBox:get_MoveNextAction():ref:this]
       48894580             mov      gword ptr [rbp-80H], rax
       488B5580             mov      rdx, gword ptr [rbp-80H]
       488B4D18             mov      rcx, bword ptr [rbp+18H]
       E854238859           call     TaskAwaiter:UnsafeOnCompleted(ref):this
       EB00                 jmp      SHORT G_M5080_IG09

Regression of dotnet/coreclr#14698?

/cc @AndyAyersMS @stephentoub

@benaadams
Copy link
Member Author

Might be tiered jit?

@benaadams
Copy link
Member Author

WIndows Update just broke my WSL so I can't retest by switching off tiering 😢

@benaadams
Copy link
Member Author

Return; after making several requests this is definitely tiering as the asm output again; later but without boxing etc

@stephentoub
Copy link
Member

It's tiered JIT. All of the boxing-related optimizations are disabled in tier 0. There's an open issues to consider enabling them and others that would actually help the JIT to be faster.

@benaadams benaadams reopened this Mar 3, 2019
@danmoseley
Copy link
Member

Cc @kouvel

@AndyAyersMS AndyAyersMS self-assigned this Mar 6, 2019
@AndyAyersMS
Copy link
Member

Putting in 3.0 for now ... I will look into enable boxing-related opts in Tier0.

@AndyAyersMS
Copy link
Member

Most of the interesting discussion on this is happening over in dotnet/coreclr#22984.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

5 participants