Skip to content

[JitDiff X64] [EgorBo] Remove WriteBarrier FCall #1225

Open

Description

@MihuBot

Job completed in 17 minutes 29 seconds (remote runner delay: 57 seconds).
dotnet/runtime#117583

Diffs

Found 84 files with textual diffs.

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 40949964
Total bytes of diff: 40949924
Total bytes of delta: -40 (-0.00 % of base)
Total relative delta: -0.16
    diff is an improvement.
    relative diff is an improvement.


Top file improvements (bytes):
         -40 : System.Private.CoreLib.dasm (-0.00 % of base)

1 total files with Code Size differences (1 improved, 0 regressed), 259 unchanged.

Top method regressions (bytes):
           2 (3.12 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object) (FullOpts)
           2 (2.04 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object) (FullOpts)

Top method improvements (bytes):
         -44 (-20.85 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object) (FullOpts)

Top method regressions (percentages):
           2 (3.12 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object) (FullOpts)
           2 (2.04 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object) (FullOpts)

Top method improvements (percentages):
         -44 (-20.85 % of base) : System.Private.CoreLib.dasm - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object) (FullOpts)

3 total methods with Code Size differences (1 improved, 2 regressed), 247992 unchanged.

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

Artifacts:

Activity

  1. MihuBot commented on Jul 13, 2025

    @MihuBot
    OwnerAuthor

    Top method regressions

    2 (3.12 % of base) - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object)
     ; Assembly listing for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object) (FullOpts)
     ; Emitting BLENDED_CODE for generic X64 + VEX + EVEX on Unix
     ; FullOpts code
     ; optimized code
     ; rbp based frame
     ; partially interruptible
     ; No PGO data
     ; Final local variable assignments
     ;
     ;  V00 arg0         [V00,T00] (  3,  3   )   byref  ->  rbx         single-def
     ;  V01 arg1         [V01,T02] (  3,  3   )    long  ->  rsi         single-def
     ;  V02 arg2         [V02,T01] (  3,  3   )     ref  ->  rdx         class-hnd single-def <System.Object>
     ;  V03 loc0         [V03,T03] (  3,  3   )     ref  ->  rax         class-hnd single-def <System.Object>
     ;# V04 OutArgs      [V04    ] (  1,  1   )  struct ( 0) [rsp+0x00]  do-not-enreg[XS] addr-exposed "OutgoingArgSpace" <Empty>
     ;
     ; Lcl frame size = 8
     
     G_M12151_IG01:
            push     rbp
            push     rbx
            push     rax
            lea      rbp, [rsp+0x10]
            mov      rbx, rdi
     						;; size=11 bbWeight=1 PerfScore 3.75
     G_M12151_IG02:
            mov      rdi, rsi
            mov      rsi, rdx
            mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:IsInstanceOfAny_NoCacheLookup(ptr,System.Object):System.Object
            call     [rax]System.Runtime.CompilerServices.CastHelpers:IsInstanceOfAny_NoCacheLookup(ptr,System.Object):System.Object
            test     rax, rax
            je       SHORT G_M12151_IG04
            mov      rdi, rbx
            mov      rsi, rax
    -						;; size=29 bbWeight=1 PerfScore 5.50
    +       call     CORINFO_HELP_CHECKED_ASSIGN_REF
    +       nop      
    +						;; size=35 bbWeight=1 PerfScore 6.75
     G_M12151_IG03:
            add      rsp, 8
            pop      rbx
            pop      rbp
    -       jmp      System.Runtime.CompilerServices.CastHelpers:WriteBarrier(byref,System.Object)
    -						;; size=11 bbWeight=1 PerfScore 3.25
    +       ret      
    +						;; size=7 bbWeight=1 PerfScore 2.25
     G_M12151_IG04:
            mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException()
            call     [rax]System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException()
            int3     
     						;; size=13 bbWeight=0.50 PerfScore 1.75
     
    -; Total bytes of code 64, prolog size 8, PerfScore 14.25, instruction count 20, allocated bytes for code 64 (MethodHash=c71bd088) for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object) (FullOpts)
    +; Total bytes of code 66, prolog size 8, PerfScore 14.50, instruction count 22, allocated bytes for code 66 (MethodHash=c71bd088) for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object) (FullOpts)
     ; ============================================================
    2 (2.04 % of base) - System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object)
     ; Assembly listing for method System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object) (FullOpts)
     ; Emitting BLENDED_CODE for generic X64 + VEX + EVEX on Unix
     ; FullOpts code
     ; optimized code
     ; rbp based frame
     ; fully interruptible
     ; No PGO data
     ; Final local variable assignments
     ;
     ;  V00 arg0         [V00,T00] (  5,  5   )     ref  ->  rdi         class-hnd single-def <System.Object[]>
     ;  V01 arg1         [V01,T02] (  4,  4   )    long  ->  rsi         single-def
     ;  V02 arg2         [V02,T01] (  6,  4.50)     ref  ->  rdx         class-hnd single-def <System.Object>
     ;  V03 loc0         [V03,T03] (  4,  2.50)   byref  ->  rax         single-def
     ;  V04 loc1         [V04,T05] (  3,  2   )    long  ->  rsi        
     ;# V05 OutArgs      [V05    ] (  1,  1   )  struct ( 0) [rsp+0x00]  do-not-enreg[XS] addr-exposed "OutgoingArgSpace" <Empty>
     ;  V06 cse0         [V06,T04] (  3,  2.50)    long  ->  rdi         "CSE #01: aggressive"
     ;
     ; Lcl frame size = 0
     
     G_M17415_IG01:
            push     rbp
            mov      rbp, rsp
     						;; size=4 bbWeight=1 PerfScore 1.25
     G_M17415_IG02:
            mov      eax, dword ptr [rdi+0x08]
            cmp      rax, rsi
            jbe      SHORT G_M17415_IG09
            lea      rax, bword ptr [rdi+8*rsi+0x10]
            mov      rdi, qword ptr [rdi]
            mov      rsi, qword ptr [rdi+0x30]
            test     rdx, rdx
    -       jne      SHORT G_M17415_IG05
    +       jne      SHORT G_M17415_IG04
     						;; size=25 bbWeight=1 PerfScore 9.50
     G_M17415_IG03:
            xor      rdx, rdx
            mov      gword ptr [rax], rdx
    -						;; size=5 bbWeight=0.50 PerfScore 0.62
    +       jmp      SHORT G_M17415_IG07
    +						;; size=7 bbWeight=0.50 PerfScore 1.62
     G_M17415_IG04:
    -       pop      rbp
    -       ret      
    -						;; size=2 bbWeight=0.50 PerfScore 0.75
    -G_M17415_IG05:
            cmp      rsi, qword ptr [rdx]
    -       je       SHORT G_M17415_IG07
    +       je       SHORT G_M17415_IG06
            mov      rcx, 0xD1FFAB1E      ; System.Object[]
            cmp      rdi, rcx
    -       je       SHORT G_M17415_IG07
    +       je       SHORT G_M17415_IG06
            mov      rdi, rax
            mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object)
     						;; size=33 bbWeight=0.50 PerfScore 3.00
    -G_M17415_IG06:
    +G_M17415_IG05:
            pop      rbp
            tail.jmp [rax]System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object)
     						;; size=4 bbWeight=0.50 PerfScore 2.25
    -G_M17415_IG07:
    +G_M17415_IG06:
            mov      rdi, rax
            mov      rsi, rdx
    -						;; size=6 bbWeight=0.50 PerfScore 0.25
    +       call     CORINFO_HELP_ASSIGN_REF
    +						;; size=11 bbWeight=0.50 PerfScore 0.75
    +G_M17415_IG07:
    +       nop      
    +						;; size=1 bbWeight=0.50 PerfScore 0.12
     G_M17415_IG08:
            pop      rbp
    -       jmp      System.Runtime.CompilerServices.CastHelpers:WriteBarrier(byref,System.Object)
    -						;; size=6 bbWeight=0.50 PerfScore 1.25
    +       ret      
    +						;; size=2 bbWeight=0.50 PerfScore 0.75
     G_M17415_IG09:
            mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:ThrowIndexOutOfRangeException()
            call     [rax]System.Runtime.CompilerServices.CastHelpers:ThrowIndexOutOfRangeException()
            int3     
     						;; size=13 bbWeight=0.50 PerfScore 1.75
     
    -; Total bytes of code 98, prolog size 4, PerfScore 20.62, instruction count 30, allocated bytes for code 98 (MethodHash=9da9bbf8) for method System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object) (FullOpts)
    +; Total bytes of code 100, prolog size 4, PerfScore 21.00, instruction count 31, allocated bytes for code 100 (MethodHash=9da9bbf8) for method System.Runtime.CompilerServices.CastHelpers:StelemRef(System.Object[],nint,System.Object) (FullOpts)
     ; ============================================================
  2. MihuBot commented on Jul 13, 2025

    @MihuBot
    OwnerAuthor

    Top method improvements

    -44 (-20.85 % of base) - System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object)
     ; Assembly listing for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object) (FullOpts)
     ; Emitting BLENDED_CODE for generic X64 + VEX + EVEX on Unix
     ; FullOpts code
     ; optimized code
     ; rbp based frame
     ; fully interruptible
     ; No PGO data
    -; 0 inlinees with PGO data; 6 single block inlinees; 2 inlinees without PGO data
    +; 0 inlinees with PGO data; 6 single block inlinees; 1 inlinees without PGO data
     ; Final local variable assignments
     ;
    -;  V00 arg0         [V00,T09] (  4,  3   )   byref  ->  rbx         single-def
    +;  V00 arg0         [V00,T09] (  4,  3   )   byref  ->  rdi         single-def
     ;  V01 arg1         [V01,T07] (  5,  5.50)    long  ->  rsi         single-def
    -;  V02 arg2         [V02,T08] (  5,  4   )     ref  ->  rax         class-hnd single-def <System.Object>
    +;  V02 arg2         [V02,T08] (  5,  4   )     ref  ->  rdx         class-hnd single-def <System.Object>
     ;# V03 OutArgs      [V03    ] (  1,  1   )  struct ( 0) [rsp+0x00]  do-not-enreg[XS] addr-exposed "OutgoingArgSpace" <Empty>
    -;  V04 tmp1         [V04,T13] (  2,  1   )     int  ->  r11         "Inline return value spill temp"
    -;  V05 tmp2         [V05,T11] (  2,  4   )     ref  ->  rdi         class-hnd single-def "Inlining Arg" <int[]>
    -;  V06 tmp3         [V06,T06] (  4, 14   )   byref  ->  rdi         single-def "Inline stloc first use temp"
    +;  V04 tmp1         [V04,T12] (  2,  1   )     int  ->  rbx         "Inline return value spill temp"
    +;  V05 tmp2         [V05,T11] (  2,  4   )     ref  ->  rax         class-hnd single-def "Inlining Arg" <int[]>
    +;  V06 tmp3         [V06,T06] (  4, 14   )   byref  ->  rax         single-def "Inline stloc first use temp"
     ;  V07 tmp4         [V07,T02] (  3, 20   )    long  ->  rcx         "Inlining Arg"
    -;  V08 tmp5         [V08,T04] (  4, 17   )     int  ->  rdx         "Inline stloc first use temp"
    -;  V09 tmp6         [V09,T03] (  5, 17   )     int  ->   r8         "Inline stloc first use temp"
    -;  V10 tmp7         [V10,T01] (  5, 26.50)   byref  ->   r9         "Inline stloc first use temp"
    -;  V11 tmp8         [V11,T00] (  5, 28.50)     int  ->  r10         "Inline stloc first use temp"
    -;  V12 tmp9         [V12,T05] (  2, 16   )    long  ->  r11         "Inline stloc first use temp"
    -;  V13 tmp10        [V13,T10] (  3,  4.50)    long  ->  r11         "Inline stloc first use temp"
    +;  V08 tmp5         [V08,T04] (  4, 17   )     int  ->   r8         "Inline stloc first use temp"
    +;  V09 tmp6         [V09,T03] (  5, 17   )     int  ->   r9         "Inline stloc first use temp"
    +;  V10 tmp7         [V10,T01] (  5, 26.50)   byref  ->  r10         "Inline stloc first use temp"
    +;  V11 tmp8         [V11,T00] (  5, 28.50)     int  ->  r11         "Inline stloc first use temp"
    +;  V12 tmp9         [V12,T05] (  2, 16   )    long  ->  rbx         "Inline stloc first use temp"
    +;  V13 tmp10        [V13,T10] (  3,  4.50)    long  ->  rbx         "Inline stloc first use temp"
     ;* V14 tmp11        [V14    ] (  0,  0   )     int  ->  zero-ref    "Inline stloc first use temp"
    -;  V15 tmp12        [V15,T12] (  3,  1.50)     ref  ->  rax         class-hnd single-def "Inline stloc first use temp" <System.Object>
     ;
     ; Lcl frame size = 8
     
     G_M63111_IG01:
            push     rbp
            push     rbx
            push     rax
            lea      rbp, [rsp+0x10]
    -       mov      rbx, rdi
    -       mov      rax, rdx
    -						;; size=14 bbWeight=1 PerfScore 4.00
    +						;; size=8 bbWeight=1 PerfScore 3.50
     G_M63111_IG02:
    -       mov      rdi, 0xD1FFAB1E      ; data for System.Runtime.CompilerServices.CastHelpers:s_table
    -       mov      rdi, gword ptr [rdi]
    -       mov      rcx, qword ptr [rax]
    -       add      rdi, 16
    -       rorx     rdx, rcx, 32
    -       xor      rdx, rsi
    -       mov      r8, 0xD1FFAB1E
    -       imul     rdx, r8
    -       mov      r8d, dword ptr [rdi]
    -       shrx     rdx, rdx, r8
    -       xor      r8d, r8d
    +       mov      rax, 0xD1FFAB1E      ; data for System.Runtime.CompilerServices.CastHelpers:s_table
    +       mov      rax, gword ptr [rax]
    +       mov      rcx, qword ptr [rdx]
    +       add      rax, 16
    +       rorx     r8, rcx, 32
    +       xor      r8, rsi
    +       mov      r9, 0xD1FFAB1E
    +       imul     r8, r9
    +       mov      r9d, dword ptr [rax]
    +       shrx     r8, r8, r9
    +       xor      r9d, r9d
            align    [0 bytes for IG03]
     						;; size=54 bbWeight=1 PerfScore 10.25
     G_M63111_IG03:
    -       lea      r9d, [rdx+0x01]
    -       movsxd   r9, r9d
    -       lea      r9, [r9+2*r9]
    -       lea      r9, bword ptr [rdi+8*r9]
    -       mov      r10d, dword ptr [r9]
    -       mov      r11, qword ptr [r9+0x08]
    -       and      r10d, -2
    -       cmp      r11, rcx
    +       lea      r10d, [r8+0x01]
    +       movsxd   r10, r10d
    +       lea      r10, [r10+2*r10]
    +       lea      r10, bword ptr [rax+8*r10]
    +       mov      r11d, dword ptr [r10]
    +       mov      rbx, qword ptr [r10+0x08]
    +       and      r11d, -2
    +       cmp      rbx, rcx
            jne      SHORT G_M63111_IG05
     						;; size=31 bbWeight=8 PerfScore 58.00
     G_M63111_IG04:
    -       mov      r11, rsi
    -       xor      r11, qword ptr [r9+0x10]
    -       cmp      r11, 1
    +       mov      rbx, rsi
    +       xor      rbx, qword ptr [r10+0x10]
    +       cmp      rbx, 1
            jbe      SHORT G_M63111_IG07
     						;; size=13 bbWeight=2 PerfScore 9.00
     G_M63111_IG05:
    -       test     r10d, r10d
    +       test     r11d, r11d
            je       SHORT G_M63111_IG06
    -       inc      r8d
    -       add      edx, r8d
    -       and      edx, dword ptr [rdi+0x04]
    -       cmp      r8d, 8
    +       inc      r9d
    +       add      r8d, r9d
    +       and      r8d, dword ptr [rax+0x04]
    +       cmp      r9d, 8
            jl       SHORT G_M63111_IG03
    -						;; size=20 bbWeight=4 PerfScore 24.00
    +						;; size=21 bbWeight=4 PerfScore 24.00
     G_M63111_IG06:
    -       mov      rdi, rsi
    -       mov      rsi, rax
    -       mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:IsInstanceOfAny_NoCacheLookup(ptr,System.Object):System.Object
    -       call     [rax]System.Runtime.CompilerServices.CastHelpers:IsInstanceOfAny_NoCacheLookup(ptr,System.Object):System.Object
    -       test     rax, rax
    -       jne      SHORT G_M63111_IG08
    -       mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException()
    -       call     [rax]System.Runtime.CompilerServices.CastHelpers:ThrowArrayMismatchException()
    -       int3     
    -						;; size=36 bbWeight=0.50 PerfScore 4.25
    +       mov      rax, 0xD1FFAB1E      ; code for System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object)
    +       call     [rax]System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper_NoCacheLookup(byref,ptr,System.Object)
    +       jmp      SHORT G_M63111_IG08
    +						;; size=14 bbWeight=0.50 PerfScore 2.62
     G_M63111_IG07:
    -       cmp      r10d, dword ptr [r9]
    +       cmp      r11d, dword ptr [r10]
            jne      SHORT G_M63111_IG06
    -       cmp      r11d, 1
    +       cmp      ebx, 1
            jne      SHORT G_M63111_IG06
    -       mov      rdi, rbx
    -       mov      rsi, rax
    -       call     System.Runtime.CompilerServices.CastHelpers:WriteBarrier(byref,System.Object)
    -       jmp      SHORT G_M63111_IG09
    -						;; size=24 bbWeight=0.50 PerfScore 4.38
    +       mov      rsi, rdx
    +       call     CORINFO_HELP_CHECKED_ASSIGN_REF
    +						;; size=18 bbWeight=0.50 PerfScore 3.25
     G_M63111_IG08:
    -       mov      rdi, rbx
    -       mov      rsi, rax
    -       call     System.Runtime.CompilerServices.CastHelpers:WriteBarrier(byref,System.Object)
    -						;; size=11 bbWeight=0.50 PerfScore 0.75
    -G_M63111_IG09:
            nop      
     						;; size=1 bbWeight=1 PerfScore 0.25
    -G_M63111_IG10:
    +G_M63111_IG09:
            add      rsp, 8
            pop      rbx
            pop      rbp
            ret      
     						;; size=7 bbWeight=1 PerfScore 2.25
     
    -; Total bytes of code 211, prolog size 14, PerfScore 117.12, instruction count 63, allocated bytes for code 211 (MethodHash=c3ec0978) for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object) (FullOpts)
    +; Total bytes of code 167, prolog size 8, PerfScore 113.12, instruction count 50, allocated bytes for code 167 (MethodHash=c3ec0978) for method System.Runtime.CompilerServices.CastHelpers:StelemRef_Helper(byref,ptr,System.Object) (FullOpts)
     ; ============================================================
  3. MihuBot commented on Jul 13, 2025

    @MihuBot
    OwnerAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions