-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
bool IsValue(ReadOnlySpan<byte> a) => a.SequenceEqual("value"u8);; Method P:IsValue(System.ReadOnlySpan`1[ubyte]):bool:this
sub rsp, 40
mov r8, 0xD1FFAB1E ;; address of RVA field
mov rcx, bword ptr [rdx]
mov edx, dword ptr [rdx+08H]
mov bword ptr [rsp+20H], r8
cmp edx, 5
jne SHORT G_M29601_IG04
mov edx, 5
mov r8, rdx
mov rdx, bword ptr [rsp+20H]
call [System.SpanHelpers:SequenceEqual(byref,byref,ulong):bool]
jmp SHORT G_M29601_IG05
G_M29601_IG04:
xor eax, eax
add rsp, 40
ret
; Total bytes of code: 58
Should be unrolled similar to UTF-16:
bool IsValue(ReadOnlySpan<char> a) => a.SequenceEqual("value");; Method P:IsValue(System.ReadOnlySpan`1[ushort]):bool:this
mov rax, bword ptr [rdx]
cmp dword ptr [rdx+08H], 5
jne SHORT G_M10905_IG04
mov rdx, 0x75006C00610076
xor rdx, qword ptr [rax]
mov eax, dword ptr [rax+06H]
xor eax, 0x650075
or rax, rdx
sete al
movzx rax, al
jmp SHORT G_M10905_IG05
G_M10905_IG04:
xor eax, eax
G_M10905_IG05:
ret
; Total bytes of code: 44Motivation
To clean up various places like:
- JsonSerializer.Read.HandleMetadata.cs
- aspnetcore's HttpHeaders.Generated.cs
- ^ similar to that in runtime: HeaderDescriptor.cs - this currently picks a candidate and then does non-optimized comparison while it could do comparison against u8 literal in each case
- Should optimize TE benchmarks as well e.g. here BenchmarkApplication.cs
Work items
- SequenceEqual
- OrdinalIgnoreCase
- StartsWith
benaadams, jasper-d, omariom, neon-sunset and MihaZupan
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI