Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RIP-relative addressing for JIT access to class statics on x64 non-windows #8545

Closed
AndyAyersMS opened this issue Jul 14, 2017 · 2 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions JitUntriaged CLR JIT issues needing additional triage optimization os-freebsd FreeBSD OS os-linux Linux OS (any supported distro) os-mac-os-x macOS aka OSX tenet-performance Performance related issue
Milestone

Comments

@AndyAyersMS
Copy link
Member

getRelocTypeHint always returns false on Linux, so the JIT always ends up using a full literal 64 bit displacement to access static fields. This makes static field access relatively more expensive, both in terms of code size and instruction count (especially so since the JIT does not CSE large literals). For instance, to increment a static and return the incremented value:

;; Windows
G_M28232_IG02:
       8B058E0ADDFF         mov      eax, dword ptr [reloc classVar[0xea02f330]]
       8D5001               lea      edx, [rax+1]
       8915850ADDFF         mov      dword ptr [reloc classVar[0xea02f330]], edx

G_M28232_IG03:
       C3                   ret      

;; Linux
G_M5560_IG02:
       48B834474066A17F0000 mov      rax, 0x7FA166404734
       8B00                 mov      eax, dword ptr [rax]
       8D7801               lea      edi, [rax+1]
       48BE34474066A17F0000 mov      rsi, 0x7FA166404734
       893E                 mov      dword ptr [rsi], edi

G_M5560_IG03:
       C3                   ret      

category:cq
theme:runtime
skill-level:expert
cost:medium

@briansull
Copy link
Contributor

PR dotnet/coreclr#12831 should fix this.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@BruceForstall BruceForstall added the JitUntriaged CLR JIT issues needing additional triage label Oct 28, 2020
@EgorBo
Copy link
Member

EgorBo commented Jul 28, 2023

Just checked - it's already done e.g.

private static int f;

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test() => f;
; Assembly listing for method Program:Test():int
; Emitting BLENDED_CODE for X64 with AVX512 - Unix
; Tier-1 compilation
; optimized code
; rsp based frame
; partially interruptible
; No PGO data

G_M000_IG01:                ;; offset=0000H

G_M000_IG02:                ;; offset=0000H
       mov      eax, dword ptr [(reloc 0x7f2bc5557d58)]

G_M000_IG03:                ;; offset=0006H
       ret

; Total bytes of code 7

checked on ubuntu-x64

@EgorBo EgorBo closed this as completed Jul 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions JitUntriaged CLR JIT issues needing additional triage optimization os-freebsd FreeBSD OS os-linux Linux OS (any supported distro) os-mac-os-x macOS aka OSX tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

5 participants