dotnet/runtime

JIT: Reloc is not used in Tier1 for this simple snippet

Open

#71.545 geöffnet am 1. Juli 2022

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (5.445 Forks)batch import
area-CodeGen-coreclrhelp wantedtenet-performance

Repository-Metriken

Stars
 (17.886 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)

Beschreibung

public class Program
{
    public static void Main(string[] args)
    {
        for (int i = 0; i < 100; i++)
        {
            F();
            Thread.Sleep(16);
        }
    }

    static int f;

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void F() => f++;
}

Codegen for Tier0 and Tier1 for method F():

; Assembly listing for method Program:F()
; Tier-0 compilation
       55                   push     rbp
       488BEC               mov      rbp, rsp
       FF05CEDB1900         inc      dword ptr [(reloc 0x7ffa7536f918)]
       5D                   pop      rbp
       C3                   ret      


; Assembly listing for method Program:F()
; Tier-1 compilation
       48B818F93675FA7F0000 mov      rax, 0x7FFA7536F918
       FF00                 inc      dword ptr [rax]
       C3                   ret

Tier0 managed to use a reloc for inc while tier1 does not (the address remains the same)

category:cq theme:tiering skill-level:intermediate cost:small impact:medium

Contributor Guide