MihuBot / runtime-utils

0 stars 0 forks source link

[JitDiff X64] [xtqqczze] Avoid `OverflowException` in `Boolean.TryFormat` #689

Open MihuBot opened 2 weeks ago

MihuBot commented 2 weeks ago

Job completed in 18 minutes 33 seconds. https://github.com/dotnet/runtime/pull/108572

Diffs

Found 263 files with textual diffs.

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 39447446
Total bytes of diff: 39447394
Total bytes of delta: -52 (-0.00 % of base)
Total relative delta: -0.36
    diff is an improvement.
    relative diff is an improvement.

Top file improvements (bytes):
         -44 : System.Private.CoreLib.dasm (-0.00 % of base)
          -8 : System.Net.HttpListener.dasm (-0.01 % of base)

2 total files with Code Size differences (2 improved, 0 regressed), 257 unchanged.

Top method improvements (bytes):
         -44 (-34.65 % of base) : System.Private.CoreLib.dasm - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
          -8 (-1.01 % of base) : System.Net.HttpListener.dasm - System.Net.HttpConnection:.ctor(System.Net.Sockets.Socket,System.Net.HttpEndPointListener,ubyte,System.Security.Cryptography.X509Certificates.X509Certificate):this (FullOpts)

Top method improvements (percentages):
         -44 (-34.65 % of base) : System.Private.CoreLib.dasm - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
          -8 (-1.01 % of base) : System.Net.HttpListener.dasm - System.Net.HttpConnection:.ctor(System.Net.Sockets.Socket,System.Net.HttpEndPointListener,ubyte,System.Security.Cryptography.X509Certificates.X509Certificate):this (FullOpts)

2 total methods with Code Size differences (2 improved, 0 regressed), 232538 unchanged.

--------------------------------------------------------------------------------

Artifacts:

MihuBot commented 2 weeks ago

Top method improvements

-44 (-34.65 % of base) - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this ```diff ; Assembly listing for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts) ; Emitting BLENDED_CODE for X64 with AVX - Unix ; FullOpts code ; optimized code ; rbp based frame ; partially interruptible ; No PGO data -; 0 inlinees with PGO data; 6 single block inlinees; 4 inlinees without PGO data +; 0 inlinees with PGO data; 2 single block inlinees; 0 inlinees without PGO data ; Final local variable assignments ; -; V00 this [V00,T02] ( 3, 3 ) byref -> rdi this single-def +; V00 this [V00,T01] ( 3, 3 ) byref -> rdi this single-def ;* V01 arg1 [V01 ] ( 0, 0 ) struct (16) zero-ref multireg-arg ld-addr-op single-def ; V02 arg2 [V02,T00] ( 5, 3.50) byref -> rcx single-def -;* V03 loc0 [V03 ] ( 0, 0 ) long -> zero-ref ld-addr-op -;* V04 loc1 [V04 ] ( 0, 0 ) long -> zero-ref ld-addr-op +;* V03 loc0 [V03 ] ( 0, 0 ) long -> zero-ref +;* V04 loc1 [V04 ] ( 0, 0 ) long -> zero-ref ;# V05 OutArgs [V05 ] ( 1, 1 ) struct ( 0) [rsp+0x00] do-not-enreg[XS] addr-exposed "OutgoingArgSpace" -;* V06 tmp1 [V06 ] ( 0, 0 ) struct (16) zero-ref "spilled call-like call argument" -;* V07 tmp2 [V07 ] ( 0, 0 ) struct (16) zero-ref "spilled call-like call argument" -;* V08 tmp3 [V08 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V09 tmp4 [V09 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "NewObj constructor temp" -;* V10 tmp5 [V10 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V11 tmp6 [V11 ] ( 0, 0 ) byref -> zero-ref single-def "Inlining Arg" -; V12 tmp7 [V12,T04] ( 2, 2 ) int -> rax "Inlining Arg" -;* V13 tmp8 [V13 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V14 tmp9 [V14 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V15 tmp10 [V15 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V16 tmp11 [V16 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "NewObj constructor temp" -;* V17 tmp12 [V17 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V18 tmp13 [V18 ] ( 0, 0 ) byref -> zero-ref single-def "Inlining Arg" -; V19 tmp14 [V19,T05] ( 2, 2 ) int -> rax "Inlining Arg" -;* V20 tmp15 [V20 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -;* V21 tmp16 [V21 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" -; V22 tmp17 [V22,T03] ( 4, 2.50) byref -> rsi single-def "field V01._reference (fldOffset=0x0)" P-INDEP -; V23 tmp18 [V23,T01] ( 5, 3 ) int -> rdx single-def "field V01._length (fldOffset=0x8)" P-INDEP -;* V24 tmp19 [V24 ] ( 0, 0 ) byref -> zero-ref "field V06._reference (fldOffset=0x0)" P-INDEP -;* V25 tmp20 [V25 ] ( 0, 0 ) int -> zero-ref "field V06._length (fldOffset=0x8)" P-INDEP -;* V26 tmp21 [V26 ] ( 0, 0 ) byref -> zero-ref "field V07._reference (fldOffset=0x0)" P-INDEP -;* V27 tmp22 [V27 ] ( 0, 0 ) int -> zero-ref "field V07._length (fldOffset=0x8)" P-INDEP -;* V28 tmp23 [V28 ] ( 0, 0 ) byref -> zero-ref single-def "field V08._reference (fldOffset=0x0)" P-INDEP -;* V29 tmp24 [V29 ] ( 0, 0 ) int -> zero-ref "field V08._length (fldOffset=0x8)" P-INDEP -;* V30 tmp25 [V30 ] ( 0, 0 ) byref -> zero-ref single-def "field V09._reference (fldOffset=0x0)" P-INDEP -;* V31 tmp26 [V31 ] ( 0, 0 ) int -> zero-ref "field V09._length (fldOffset=0x8)" P-INDEP -;* V32 tmp27 [V32 ] ( 0, 0 ) byref -> zero-ref single-def "field V10._reference (fldOffset=0x0)" P-INDEP -;* V33 tmp28 [V33 ] ( 0, 0 ) int -> zero-ref "field V10._length (fldOffset=0x8)" P-INDEP -;* V34 tmp29 [V34 ] ( 0, 0 ) byref -> zero-ref single-def "field V13._reference (fldOffset=0x0)" P-INDEP -;* V35 tmp30 [V35 ] ( 0, 0 ) int -> zero-ref "field V13._length (fldOffset=0x8)" P-INDEP -;* V36 tmp31 [V36 ] ( 0, 0 ) byref -> zero-ref single-def "field V14._reference (fldOffset=0x0)" P-INDEP -;* V37 tmp32 [V37 ] ( 0, 0 ) int -> zero-ref "field V14._length (fldOffset=0x8)" P-INDEP -;* V38 tmp33 [V38 ] ( 0, 0 ) byref -> zero-ref single-def "field V15._reference (fldOffset=0x0)" P-INDEP -;* V39 tmp34 [V39 ] ( 0, 0 ) int -> zero-ref "field V15._length (fldOffset=0x8)" P-INDEP -;* V40 tmp35 [V40 ] ( 0, 0 ) byref -> zero-ref single-def "field V16._reference (fldOffset=0x0)" P-INDEP -;* V41 tmp36 [V41 ] ( 0, 0 ) int -> zero-ref "field V16._length (fldOffset=0x8)" P-INDEP -;* V42 tmp37 [V42 ] ( 0, 0 ) byref -> zero-ref single-def "field V17._reference (fldOffset=0x0)" P-INDEP -;* V43 tmp38 [V43 ] ( 0, 0 ) int -> zero-ref "field V17._length (fldOffset=0x8)" P-INDEP -;* V44 tmp39 [V44 ] ( 0, 0 ) byref -> zero-ref single-def "field V20._reference (fldOffset=0x0)" P-INDEP -;* V45 tmp40 [V45 ] ( 0, 0 ) int -> zero-ref "field V20._length (fldOffset=0x8)" P-INDEP -;* V46 tmp41 [V46 ] ( 0, 0 ) byref -> zero-ref single-def "field V21._reference (fldOffset=0x0)" P-INDEP -;* V47 tmp42 [V47 ] ( 0, 0 ) int -> zero-ref "field V21._length (fldOffset=0x8)" P-INDEP +;* V06 tmp1 [V06 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" +;* V07 tmp2 [V07 ] ( 0, 0 ) struct (16) zero-ref ld-addr-op "Inlining Arg" +; V08 tmp3 [V08,T02] ( 4, 2.50) byref -> rsi single-def "field V01._reference (fldOffset=0x0)" P-INDEP +; V09 tmp4 [V09,T03] ( 3, 2 ) int -> rdx single-def "field V01._length (fldOffset=0x8)" P-INDEP +;* V10 tmp5 [V10 ] ( 0, 0 ) byref -> zero-ref single-def "field V06._reference (fldOffset=0x0)" P-INDEP +;* V11 tmp6 [V11 ] ( 0, 0 ) int -> zero-ref "field V06._length (fldOffset=0x8)" P-INDEP +;* V12 tmp7 [V12 ] ( 0, 0 ) byref -> zero-ref single-def "field V07._reference (fldOffset=0x0)" P-INDEP +;* V13 tmp8 [V13 ] ( 0, 0 ) int -> zero-ref "field V07._length (fldOffset=0x8)" P-INDEP ; ; Lcl frame size = 0 G_M62266_IG01: push rbp mov rbp, rsp ;; size=4 bbWeight=1 PerfScore 1.25 G_M62266_IG02: cmp byte ptr [rdi], 0 jne SHORT G_M62266_IG05 ;; size=5 bbWeight=1 PerfScore 4.00 G_M62266_IG03: - cmp edx, 4 - jle SHORT G_M62266_IG06 - imul eax, edx, 2 - jo SHORT G_M62266_IG11 - cmp eax, 8 - jb SHORT G_M62266_IG10 + cmp edx, 5 + jl SHORT G_M62266_IG06 mov rax, 0xD1FFAB1E mov qword ptr [rsi], rax mov word ptr [rsi+0x08], 101 mov dword ptr [rcx], 5 mov eax, 1 - ;; size=45 bbWeight=0.50 PerfScore 4.50 + ;; size=35 bbWeight=0.50 PerfScore 2.38 G_M62266_IG04: pop rbp ret ;; size=2 bbWeight=0.50 PerfScore 0.75 G_M62266_IG05: - cmp edx, 3 - jg SHORT G_M62266_IG08 + cmp edx, 4 + jge SHORT G_M62266_IG08 ;; size=5 bbWeight=0.50 PerfScore 0.62 G_M62266_IG06: xor eax, eax mov dword ptr [rcx], eax ;; size=4 bbWeight=0.50 PerfScore 0.62 G_M62266_IG07: pop rbp ret ;; size=2 bbWeight=0.50 PerfScore 0.75 G_M62266_IG08: - imul eax, edx, 2 - jo SHORT G_M62266_IG11 - cmp eax, 8 - jb SHORT G_M62266_IG10 mov rax, 0xD1FFAB1E mov qword ptr [rsi], rax mov dword ptr [rcx], 4 mov eax, 1 - ;; size=34 bbWeight=0.50 PerfScore 3.38 + ;; size=24 bbWeight=0.50 PerfScore 1.25 G_M62266_IG09: pop rbp ret ;; size=2 bbWeight=0.50 PerfScore 0.75 -G_M62266_IG10: - mov edi, 40 - mov rax, 0xD1FFAB1E ; code for System.ThrowHelper:ThrowArgumentOutOfRangeException(int) - call [rax]System.ThrowHelper:ThrowArgumentOutOfRangeException(int) - int3 - ;; size=18 bbWeight=0 PerfScore 0.00 -G_M62266_IG11: - call CORINFO_HELP_OVERFLOW - int3 - ;; size=6 bbWeight=0 PerfScore 0.00 -; Total bytes of code 127, prolog size 4, PerfScore 16.62, instruction count 39, allocated bytes for code 127 (MethodHash=7f390cc5) for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts) +; Total bytes of code 83, prolog size 4, PerfScore 12.38, instruction count 25, allocated bytes for code 83 (MethodHash=7f390cc5) for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts) ; ============================================================ ```

Note: some changes were skipped as they were likely noise.

MihuBot commented 2 weeks ago

@xtqqczze