-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 const RVA access (via const index) #78783
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsCloses #64823 static ReadOnlySpan<byte> RVA => new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
// Case1: read byte at a const position (2):
byte ReadByte() => RVA[2];
// Case2: Read Int32 at the give const offset (4)
int ReadInt() =>
Unsafe.ReadUnaligned<int>(
ref Unsafe.Add(ref MemoryMarshal.GetReference(RVA), 4));
// Case3: IsWhiteSpace is implemented using RVA table under its hood
bool IsWhiteSpace() => char.IsWhiteSpace(' '); Previous codegen: ; Assembly listing for method Prog:ReadByte():ubyte:this
48B8AA2B11DB96010000 mov rax, 0x196DB112BAA
0FB600 movzx rax, byte ptr [rax]
C3 ret
; Assembly listing for method Prog:ReadInt():int:this
48B8AC2B11DB96010000 mov rax, 0x196DB112BAC
8B00 mov eax, dword ptr [rax]
C3 ret
; Assembly listing for method Prog:IsWhiteSpace():bool:this
33C0 xor eax, eax
F6057723AD5E80 test byte ptr [(reloc 0x7ffadf84d5f0)], 128
0F95C0 setne al
C3 ret New codegen: ; Method Prog:ReadByte():ubyte
B803000000 mov eax, 3
C3 ret
; Method Prog:ReadInt():int
B805060708 mov eax, 0x8070605
C3 ret
; Method Prog:IsWhiteSpace():bool
B801000000 mov eax, 1
C3 ret TODO:
|
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jan Kotas <[email protected]>
@jkotas does VM side look good otherwise? |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
8823ab9
to
142ad61
Compare
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Show resolved
Hide resolved
VM/AOT side looks good. |
…foImpl.ReadyToRun.cs Co-authored-by: Jan Kotas <[email protected]>
@jakobbotsch @SingleAccretion when you have time can you please take a look at the JIT side? A couple of notes: I needed that because currently we can't obtain FieldSeq* out of a VN (it might be a good idea to encode that info to VN like Single suggested but it's more work for little value IMO). The jit-diffs are small from this change (just 8 methods improved) but I plan a couple of optimizations on top of this in C#. Also, e.g. a lot of Char apis can now be folded into a constant for constant input (e.g. after inlining). |
/azp list |
This comment was marked as resolved.
This comment was marked as resolved.
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr jitstressregs |
Azure Pipelines successfully started running 3 pipeline(s). |
Closes #64823
Previous codegen:
New codegen:
TODO: