Uh oh!
There was an error while loading. Please reload this page.
Remove invalid Unsafe.As from array helpers - #99778
Conversation
Uh oh!
There was an error while loading. Please reload this page.
jkotas
commented
Mar 15, 2024
| has clone of this code with the same potential issue. |
MichalPetryka
commented
Mar 15, 2024
What's the |
jkotas
commented
Mar 15, 2024
I think we build |
MichalPetryka
commented
Mar 16, 2024
Do we want to cleanup the code then and remove those paths later (and keep it as is for now)? Or should I also change the |
jkotas
commented
Mar 16, 2024
Any of these options is fine with me. |
jkotas
commented
Mar 16, 2024
Is the code for helper same or better with this change? |
MichalPetryka
commented
Mar 16, 2024
The codegen for normal path is almost the same (the operands for G_M56901_IG04:
- call CORINFO_HELP_RNGCHKFAIL- ;; size=5 bbWeight=0 PerfScore 0.00-G_M56901_IG05:
mov rax, 0xD1FFAB1E ; code for System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException():byref
call [rax]System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException():byref
+ ;; size=12 bbWeight=0 PerfScore 0.00+G_M56901_IG05:+ mov rax, 0xD1FFAB1E ; code for System.Runtime.CompilerServices.CastHelpers:ThrowIndexOutOfRangeException()+ call [rax]System.Runtime.CompilerServices.CastHelpers:ThrowIndexOutOfRangeException()
int3 ;; size=13 bbWeight=0 PerfScore 0.00 |
MichalPetryka
commented
Mar 16, 2024
MichalPetryka
commented
Mar 16, 2024
@jkotas Do you know what's going on with the CI refusing to run pipelines on PRs as of recently? |
jkotas
commented
Mar 16, 2024
Yes, it is broken. The people responsible for our eng system are not on-call during the weekend, so it may take till Monday to resolve. It actually runs them, just the github status is not updating. For example, here is the pipeline link for this PR |
MichalPetryka
commented
Mar 16, 2024
| #if INPLACE_RUNTIME | ||
| if ((nuint)index >= (uint)array.Length) | ||
| ThrowIndexOutOfRangeException(array); |
There was a problem hiding this comment.
This can just use ThrowHelper.ThrowIndexOutOfRangeException given that is for INPLACE_RUNTIME. It is unnecessary to go through GetClasslibException indirection for INPLACE_RUNTIME. The main point of INPLACE_RUNTIME is to avoid these indirections.
There was a problem hiding this comment.
I wanted to remove the !INPLACE_RUNTIME code in the next PR and to keep this like earlier for now.
Also I think that ThrowHelper is not in the Test.CoreLib (not sure what that is for tbh but right now there's a build failure here due to MemoryMarshal not being there too).
There was a problem hiding this comment.
Test.CoreLib is very minimal implementation of CoreLib for testing, debugging and various experiments. It is fine to add minimal implementations of MemoryMarshal or ThrowHelper to it to keep it working.
Uh oh!
There was an error while loading. Please reload this page.
MichalPetryka
commented
Mar 17, 2024
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
MichalPetryka
commented
Mar 17, 2024
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
MichalPetryka
commented
Mar 17, 2024
@jkotas This caused |
jkotas
commented
Mar 17, 2024
Does it affect performance of any of the fast paths?
|
MichalPetryka
commented
Mar 17, 2024
Ah wait nevermind, I've accidentally diffed The non cached one being inlined is the only difference now then: MihuBot/runtime-utils#332 (comment) |
huoyaoyuan
commented
Mar 19, 2024
I wonder what the problem would be. Is there any context? |
jkotas
commented
Mar 19, 2024
|
jkotas
commented
Mar 19, 2024
@MichalPetryka Did you have a chance to check the perf impact of these changes? |
MichalPetryka
commented
Mar 19, 2024
I'll do so today. |
@jkotas I've benchmarked with Full codegen: Details.NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteNull(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprdx,raxjae short M01_L02learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+38]testr8,r8jne short M01_L00xorecx,ecxmov[rax],rcxaddrsp,28retM01_L00:cmprdx,[r8]je short M01_L01movr10,offset MT_System.Object[]cmp[rcx],r10je short M01_L01movrcx,raxaddrsp,28jmp qword ptr [7FFB68CB4498]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)M01_L01:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M01_L02:call CORINFO_HELP_RNGCHKFAILint3; Total bytes of code 93; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrdi,rcxmovrbx,rdxmovrsi,r8movrcx,290F9800B80movrcx,[rcx]movrax,[rsi]addrcx,10rorxrdx,rax,20xorrdx,rbxmovr8,9E3779B97F4A7C15imulrdx,r8movr8d,[rcx]shrxrdx,rdx,r8xorr8d,r8dM02_L00:lear10d,[rdx+1]movsxdr10,r10dlear10,[r10+r10*2]lear10,[rcx+r10*8]movr9d,[r10]movr11,[r10+8]andr9d,0FFFFFFFEcmpr11,raxjne short M02_L01movr11,rbxxorr11,[r10+10]cmpr11,1jbe short M02_L02M02_L01:testr9d,r9dje short M02_L03incr8daddedx,r8dandedx,[rcx+4]cmpr8d,8jl short M02_L00jmp short M02_L03M02_L02:cmpr9d,[r10]jne short M02_L03cmpr11d,1jne short M02_L03movrcx,7FFB69DC54C8call CORINFO_HELP_COUNTPROFILE32movrcx,rdimovrdx,rsicall System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:movrcx,7FFB69DC54CCcall CORINFO_HELP_COUNTPROFILE32movrcx,rdimovrdx,rbxmovr8,rsicall qword ptr [7FFB68CB44B0]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)nopaddrsp,20poprbxpoprsipoprdiret; Total bytes of code 221; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrsi,rcxmovrdi,rdxmovrbx,r8testrbx,rbxjne short M03_L00movrdx,2D18E150008movrcx,rdxcall qword ptr [7FFB68D1D3B0]M03_L00:movrcx,rdimovrdx,rbxcall System.Runtime.CompilerServices.CastHelpers.IsInstanceOfAny_NoCacheLookup(Void*, System.Object)movrbx,raxtestrbx,rbxje short M03_L01movrcx,rsimovrdx,rbxaddrsp,20poprbxpoprsipoprdijmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M03_L01:movrcx,offset MT_System.ArrayTypeMismatchExceptioncall CORINFO_HELP_NEWSFASTmovrbx,raxmovrcx,rbxcall qword ptr [7FFB69827C78]movrcx,rbxcall CORINFO_HELP_THROWint3; Total bytes of code 113Extern method .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteNull(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprax,rdxjbe short M01_L01learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+30]testr8,r8jne short M01_L02xorecx,ecxmov[rax],rcxaddrsp,28retM01_L00:movr10,offset MT_System.Object[]cmp[rcx],r10je short M01_L03movrcx,raxaddrsp,28jmp qword ptr [7FFB6BDB44B0]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)M01_L01:call qword ptr [7FFB6BDB4450]int3M01_L02:cmprdx,[r8]jne short M01_L00M01_L03:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object); Total bytes of code 94; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrdi,rcxmovrbx,rdxmovrsi,r8call qword ptr [7FFBC8B31840]movrdx,[rax+0B50]movrax,[rsi]addrdx,10movr8,raxrolr8,20xorr8,rbxmovr10,9E3779B97F4A7C15imulr8,r10movecx,[rdx]shrr8,clxorecx,ecxM02_L00:lear10d,[r8+1]movsxdr10,r10dlear10,[r10+r10*2]lear10,[rdx+r10*8]movr9d,[r10]movr11,[r10+8]andr9d,0FFFFFFFEcmpr11,raxjne short M02_L01movr11,rbxxorr11,[r10+10]cmpr11,1jbe short M02_L02M02_L01:testr9d,r9dje short M02_L03incecxaddr8d,ecxandr8d,[rdx+4]cmpecx,8jl short M02_L00jmp short M02_L03M02_L02:cmpr9d,[r10]jne short M02_L03cmpr11d,1jne short M02_L03movrcx,rdimovrdx,rsicall qword ptr [7FFBC8B4A2A8]; System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:movrcx,rbxmovrdx,rsicall qword ptr [7FFBC8B4A288]; System.Runtime.CompilerServices.CastHelpers.IsInstanceOfAny_NoCacheLookup(Void*, System.Object)testrax,raxje short M02_L04movrcx,rdimovrdx,raxcall qword ptr [7FFBC8B4A2A8]; System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L04:call qword ptr [7FFBC8B4A2E0]int3; Total bytes of code 209Extern method .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteNull(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall CORINFO_HELP_ARRADDR_STincedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53.NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToObject(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprdx,raxjae short M01_L02learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+38]testr8,r8je short M01_L01cmprdx,[r8]je short M01_L00movr10,offset MT_System.Object[]cmp[rcx],r10jne short M01_L03M01_L00:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M01_L01:xorecx,ecxmov[rax],rcxaddrsp,28retM01_L02:call CORINFO_HELP_RNGCHKFAILM01_L03:movrcx,raxaddrsp,28jmp qword ptr [7FFB68CD4498]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object); Total bytes of code 92; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrdi,rcxmovrbx,rdxmovrsi,r8call qword ptr [7FFBC7912090]movrdx,[rax+0B48]movr8,[rsi]addrdx,10movrax,r8rolrax,20xorrax,rbxmovr10,9E3779B97F4A7C15imulrax,r10movecx,[rdx]shrrax,clxorecx,ecxM02_L00:lear10d,[rax+1]movsxdr10,r10dlear10,[r10+r10*2]lear10,[rdx+r10*8]movr9d,[r10]movr11,[r10+8]andr9d,0FFFFFFFEcmpr11,r8jne short M02_L01movr11,rbxxorr11,[r10+10]cmpr11,1jbe short M02_L02M02_L01:testr9d,r9dje short M02_L03incecxaddeax,ecxandeax,[rdx+4]cmpecx,8jl short M02_L00jmp short M02_L03M02_L02:cmpr9d,[r10]jne short M02_L03cmpr11d,1jne short M02_L03movrcx,rdimovrdx,rsicall qword ptr [7FFBC792CD88]; System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:movrcx,rdimovrdx,rbxmovr8,rsicall qword ptr [7FFBC792CDC8]; Precode of System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)nopaddrsp,20poprbxpoprsipoprdiret; Total bytes of code 186Extern method .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToObject(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprax,rdxjbe short M01_L02learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+30]testr8,r8je short M01_L01cmprdx,[r8]je short M01_L00movr10,offset MT_System.Object[]cmp[rcx],r10jne short M01_L03M01_L00:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M01_L01:xorecx,ecxmov[rax],rcxaddrsp,28retM01_L02:call qword ptr [7FFB68CA4450]int3M01_L03:movrcx,raxaddrsp,28jmp qword ptr [7FFB68CA44B0]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object); Total bytes of code 94; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrdi,rcxmovrbx,rdxmovrsi,r8call qword ptr [7FFBC8661840]movrdx,[rax+0B50]movrax,[rsi]addrdx,10movr8,raxrolr8,20xorr8,rbxmovr10,9E3779B97F4A7C15imulr8,r10movecx,[rdx]shrr8,clxorecx,ecxM02_L00:lear10d,[r8+1]movsxdr10,r10dlear10,[r10+r10*2]lear10,[rdx+r10*8]movr9d,[r10]movr11,[r10+8]andr9d,0FFFFFFFEcmpr11,raxjne short M02_L01movr11,rbxxorr11,[r10+10]cmpr11,1jbe short M02_L02M02_L01:testr9d,r9dje short M02_L03incecxaddr8d,ecxandr8d,[rdx+4]cmpecx,8jl short M02_L00jmp short M02_L03M02_L02:cmpr9d,[r10]jne short M02_L03cmpr11d,1jne short M02_L03movrcx,rdimovrdx,rsicall qword ptr [7FFBC867A2A8]; System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:movrcx,rbxmovrdx,rsicall qword ptr [7FFBC867A288]; System.Runtime.CompilerServices.CastHelpers.IsInstanceOfAny_NoCacheLookup(Void*, System.Object)testrax,raxje short M02_L04movrcx,rdimovrdx,raxcall qword ptr [7FFBC867A2A8]; System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L04:call qword ptr [7FFBC867A2E0]int3; Total bytes of code 209Extern method .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToObject(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+8]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall CORINFO_HELP_ARRADDR_STincedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53.NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToInterface(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+10]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array, IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprdx,raxjae short M01_L00learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+38]testr8,r8je short M01_L02cmprdx,[r8]je short M01_L01movr10,offset MT_System.Object[]cmp[rcx],r10je short M01_L01movrcx,raxaddrsp,28jmp qword ptr [7FFB68CD4498]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)M01_L00:call CORINFO_HELP_RNGCHKFAILM01_L01:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M01_L02:xorecx,ecxmov[rax],rcxaddrsp,28ret; Total bytes of code 92; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrax,25A67800B80movrax,[rax]movr10,[r8]addrax,10rorxr9,r10,20xorr9,rdxmovr11,9E3779B97F4A7C15imulr9,r11movr11d,[rax]shrxr9,r9,r11xorr11d,r11dM02_L00:leaebx,[r9+1]movsxdrbx,ebxlearbx,[rbx+rbx*2]learbx,[rax+rbx*8]movesi,[rbx]movrdi,[rbx+8]andesi,0FFFFFFFEcmprdi,r10jne short M02_L01movrdi,rdxxorrdi,[rbx+10]cmprdi,1jbe short M02_L02M02_L01:testesi,esije short M02_L03incr11daddr9d,r11dandr9d,[rax+4]cmpr11d,8jl short M02_L00jmp short M02_L03M02_L02:cmpesi,[rbx]jne short M02_L03cmpedi,1jne short M02_L03movrdx,r8call System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:call qword ptr [7FFB68CD44B0]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)nopaddrsp,20poprbxpoprsipoprdiret; Total bytes of code 166; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrsi,rcxmovrdi,rdxmovrbx,r8testrbx,rbxjne short M03_L00movrcx,[7FFBC79636C8]movrdx,[rcx]movrcx,rdxcall qword ptr [7FFBC79300B8]M03_L00:movrcx,rdimovrdx,rbxcall qword ptr [7FFBC792CD68]; System.Runtime.CompilerServices.CastHelpers.IsInstanceOfAny_NoCacheLookup(Void*, System.Object)movrbx,raxtestrbx,rbxje short M03_L01movrdx,rbxmovrcx,rsilearax,[7FFBC792CD90]addrsp,20poprbxpoprsipoprdijmp qword ptr [rax]M03_L01:call qword ptr [7FFBC791B5E8]movrbx,raxmovrcx,rbxcall qword ptr [7FFBC7924598]movrcx,rbxcall qword ptr [7FFBC7911760]; CORINFO_HELP_THROWint3; Total bytes of code 111Extern method .NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToInterface(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+10]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)incedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53; System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Object[], IntPtr, System.Object)subrsp,28moveax,[rcx+8]cmprax,rdxjbe short M01_L00learax,[rcx+rdx*8+10]movrdx,[rcx]movrdx,[rdx+30]testr8,r8je short M01_L02cmprdx,[r8]je short M01_L01movr10,offset MT_System.Object[]cmp[rcx],r10je short M01_L01movrcx,raxaddrsp,28jmp qword ptr [7FFB68CC44B0]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)M01_L00:call qword ptr [7FFB68CC4450]int3M01_L01:movrcx,raxmovrdx,r8addrsp,28jmp near ptr System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)M01_L02:xorecx,ecxmov[rax],rcxaddrsp,28ret; Total bytes of code 94; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)pushrdipushrsipushrbxsubrsp,20movrax,21C53C00B88movrax,[rax]movr10,[r8]addrax,10rorxr9,r10,20xorr9,rdxmovr11,9E3779B97F4A7C15imulr9,r11movr11d,[rax]shrxr9,r9,r11xorr11d,r11dM02_L00:leaebx,[r9+1]movsxdrbx,ebxlearbx,[rbx+rbx*2]learbx,[rax+rbx*8]movesi,[rbx]movrdi,[rbx+8]andesi,0FFFFFFFEcmprdi,r10jne short M02_L01movrdi,rdxxorrdi,[rbx+10]cmprdi,1jbe short M02_L02M02_L01:testesi,esije short M02_L03incr11daddr9d,r11dandr9d,[rax+4]cmpr11d,8jl short M02_L00jmp short M02_L03M02_L02:cmpesi,[rbx]jne short M02_L03cmpedi,1jne short M02_L03movrdx,r8call System.Runtime.CompilerServices.CastHelpers.WriteBarrier(System.Object ByRef, System.Object)nopaddrsp,20poprbxpoprsipoprdiretM02_L03:call qword ptr [7FFB68CC44C8]; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)nopaddrsp,20poprbxpoprsipoprdiret; Total bytes of code 166; System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper_NoCacheLookup(System.Object ByRef, Void*, System.Object)pushrbxsubrsp,20movrbx,rcxmovrax,r8movrcx,rdxmovrdx,raxcall qword ptr [7FFBC867A288]; System.Runtime.CompilerServices.CastHelpers.IsInstanceOfAny_NoCacheLookup(Void*, System.Object)testrax,raxje short M03_L00movrdx,raxmovrcx,rbxlearax,[7FFBC867A2B0]addrsp,20poprbxjmp qword ptr [rax]M03_L00:call qword ptr [7FFBC867A2E0]int3; Total bytes of code 56Extern method .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToInterface(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+10]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01M00_L00:movsxdrdx,edimovrcx,rsimovr8,rbxcall CORINFO_HELP_ARRADDR_STincedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 53.NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToType(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+18]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01nop dword ptr [rax+rax]M00_L00:learcx,[rsi+rdi*8+10]movrdx,rbxcall CORINFO_HELP_ASSIGN_REFincedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 60.NET 9.0.0 (42.42.42.42424), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToType(System.String)pushrdipushrsipushrbppushrbxsubrsp,28movrbx,rdxmovrsi,[rcx+18]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01nop dword ptr [rax+rax]M00_L00:learcx,[rsi+rdi*8+10]movrdx,rbxcall CORINFO_HELP_ASSIGN_REFincedicmpebp,edijg short M00_L00M00_L01:addrsp,28poprbxpoprbppoprsipoprdiret; Total bytes of code 60.NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI; ConsoleApp7.Benchmark.WriteToType(System.String)pushrdipushrsipushrbppushrbxmovrbx,rdxmovrsi,[rcx+18]xoredi,edimovebp,[rsi+8]testebp,ebpjle short M00_L01nop dword ptr [rax]nop dword ptr [rax+rax]M00_L00:movecx,edilearcx,[rsi+rcx*8+10]movrdx,rbxcall CORINFO_HELP_ASSIGN_REFincedicmpebp,edijg short M00_L00M00_L01:poprbxpoprbppoprsipoprdiret; Total bytes of code 58 |
I agree that the cold blocks ordering with PGO can be better in some case. I do not see any material code difference caused by this change. The exact code for these helpers can differ from workload to workload and from run to run depending on how PGO rolls the dice. I have pushed a commit with a minor cleanup as I was looking at the code. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This probably doesn't cause issues today but it might start to do so when we start inlining helpers.
Causes almost no diffs outside of calling a managed throw helper now.