Skip to content

Write barrier elision on object reference assignment to a return buffer? #92662

@neon-sunset

Description

@neon-sunset

Description

Consider the method static (object, object) GetObj() => (new(), new());.

On win-x64 JIT emits the following codegen for it:

G_M000_IG01:                ;; offset=0x0000
       push     rdi
       push     rsi
       push     rbx
       sub      rsp, 32
       mov      rbx, rcx

G_M000_IG02:                ;; offset=0x000A
       mov      rsi, 0x7FFCD3835FA0
       mov      rcx, rsi
       call     CORINFO_HELP_NEWSFAST
       mov      rdi, rax
       mov      rcx, rsi
       call     CORINFO_HELP_NEWSFAST
       mov      rsi, rax
       mov      rdx, rdi
       mov      rcx, rbx
       call     CORINFO_HELP_CHECKED_ASSIGN_REF
       lea      rcx, bword ptr [rbx+0x08]
       mov      rdx, rsi
       call     CORINFO_HELP_CHECKED_ASSIGN_REF
       mov      rax, rbx

G_M000_IG03:                ;; offset=0x0044
       add      rsp, 32
       pop      rbx
       pop      rsi
       pop      rdi
       ret      
; Total bytes of code: 76

Are write barriers necessary given the fact that it is known that object references are being assigned to a return buffer? Is there something I am missing?

Configuration

.NET SDK:
 Version:   8.0.100-rtm.23471.13
 Commit:    1de2c23f77

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-rtm.23471.13\

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions