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

JIT: Fold constant access to RVA #64613

Closed
EgorBo opened this issue Feb 1, 2022 · 3 comments
Closed

JIT: Fold constant access to RVA #64613

EgorBo opened this issue Feb 1, 2022 · 3 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI help wanted [up-for-grabs] Good issue for external contributors tenet-performance Performance related issue
Milestone

Comments

@EgorBo
Copy link
Member

EgorBo commented Feb 1, 2022

Fold constant accesses to RVA data (from #64612). Example:

static ReadOnlySpan<byte> data => new byte[] { 1, 2, 3, 4, 5 };

byte Test() => data[3];

Current codegen:

; Method Prog:Test():ubyte:this
       48B8A32BAD36FD010000 mov      rax, 0x1FD36AD2BA3
       0FB600               movzx    rax, byte  ptr [rax]
       C3                   ret      
; Total bytes of code: 14

Expected codegen:

; Method Prog:Test():ubyte:this
       B804000000           mov      eax, 4
       C3                   ret      
; Total bytes of code: 6

NOTES:

  • JIT is already able to do it for string literals e.g. "hello"[2] (see fgMorphArrayIndex)
  • C# should soon get a support for ROS<any primitive> = RVA, not just byte/bool as it is currently
  • We probably can't do it for RVAs in C++/CLI/CX which are mutable (check for mixed-mode)
  • This task most likely needs a new JIT-EE API or maybe the existing getArrayInitializationData is enough
@EgorBo EgorBo added the tenet-performance Performance related issue label Feb 1, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Feb 1, 2022
@ghost

This comment has been minimized.

@EgorBo EgorBo added help wanted [up-for-grabs] Good issue for external contributors and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Feb 1, 2022
@EgorBo EgorBo added this to the Future milestone Feb 1, 2022
@EgorBo EgorBo added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 1, 2022
@ghost

This comment has been minimized.

@EgorBo EgorBo closed this as completed Feb 7, 2022
@EgorBo
Copy link
Member Author

EgorBo commented Feb 7, 2022

Closed in favor of #64823

@ghost ghost locked as resolved and limited conversation to collaborators Mar 9, 2022
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 help wanted [up-for-grabs] Good issue for external contributors tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

1 participant