I noticed in .NET Core 2.1.0-rtm-26502-02 that the following code
private static readonly byte[] inputBytes = new byte[] {1, 2, 3, 4};
private static string inputString = "Hello World";
[Benchmark]
public ReadOnlySpan<byte> CodeQualityBytes()
{
return inputBytes.AsSpan();
}
[Benchmark]
public ReadOnlySpan<char> CodeQualityString()
{
return inputString.AsSpan();
}
has a tiny code quality issue for the CodeQualityString, it has a couple of unused
mov rdx,rcx and mov rcx,rdx at the end.
(Those do not appear to be Benchmark.Net artifacts, they show up with longer methods too).
I think I've seen this before, but couldn't find anything, if this is a duplicate, please close.
The output of Benchmark.Net 0.10.14 for CodeQualityString is:
00007ffb`c5580f90 SpanJson.Benchmarks.SelectedBenchmarks.CodeQualityString()
IL_0000: ldsfld System.String SpanJson.Benchmarks.SelectedBenchmarks::inputString
IL_0005: call System.ReadOnlySpan`1<System.Char> System.MemoryExtensions::AsSpan(System.String)
IL_000a: ret
00007ffb`c5580f98 48b9b0fd62c5fb7f0000 mov rcx,7FFBC562FDB0h
00007ffb`c5580fa2 ba08000000 mov edx,8
00007ffb`c5580fa7 e844fcac5f call coreclr!coreclr_shutdown_2+0x39680 (00007ffc`25050bf0)
00007ffb`c5580fac 48b8a89f7629c3010000 mov rax,1C329769FA8h
00007ffb`c5580fb6 488b00 mov rax,qword ptr [rax]
00007ffb`c5580fb9 4885c0 test rax,rax
00007ffb`c5580fbc 7506 jne 00007ffb`c5580fc4
00007ffb`c5580fbe 33d2 xor edx,edx
00007ffb`c5580fc0 33c9 xor ecx,ecx
00007ffb`c5580fc2 eb15 jmp 00007ffb`c5580fd9
00007ffb`c5580fc4 488d500c lea rdx,[rax+0Ch]
00007ffb`c5580fc8 488bca mov rcx,rdx
00007ffb`c5580fcb 8b4008 mov eax,dword ptr [rax+8]
00007ffb`c5580fce 488bd1 mov rdx,rcx
00007ffb`c5580fd1 488bca mov rcx,rdx
00007ffb`c5580fd4 488bd1 mov rdx,rcx
00007ffb`c5580fd7 8bc8 mov ecx,eax
The output of Benchmark.NET 0.10.14 for CodeQualityBytes is:
00007ffb`c5590f90 SpanJson.Benchmarks.SelectedBenchmarks.CodeQualityBytes()
IL_0000: ldsfld System.Byte[] SpanJson.Benchmarks.SelectedBenchmarks::inputBytes
IL_0005: call System.Span`1<!!0> System.MemoryExtensions::AsSpan<System.Byte>(!!0[])
IL_000a: call System.ReadOnlySpan`1<!0> System.Span`1<System.Byte>::op_Implicit(System.Span`1<!0>)
IL_000f: ret
00007ffb`c5590f98 48b9b0fd63c5fb7f0000 mov rcx,7FFBC563FDB0h
00007ffb`c5590fa2 ba08000000 mov edx,8
00007ffb`c5590fa7 e844fcab5f call coreclr!coreclr_shutdown_2+0x39680 (00007ffc`25050bf0)
00007ffb`c5590fac 48b8a09f0bd6a4010000 mov rax,1A4D60B9FA0h
00007ffb`c5590fb6 488b00 mov rax,qword ptr [rax]
00007ffb`c5590fb9 4885c0 test rax,rax
00007ffb`c5590fbc 7506 jne 00007ffb`c5590fc4
00007ffb`c5590fbe 33d2 xor edx,edx
00007ffb`c5590fc0 33c9 xor ecx,ecx
00007ffb`c5590fc2 eb07 jmp 00007ffb`c5590fcb
00007ffb`c5590fc4 488d5010 lea rdx,[rax+10h]
00007ffb`c5590fc8 8b4808 mov ecx,dword ptr [rax+8]
No ILOffsetMap found
System.MemoryExtensions.AsSpan(!!0[])
category:cq
theme:register-allocator
skill-level:expert
cost:medium
I noticed in .NET Core 2.1.0-rtm-26502-02 that the following code
has a tiny code quality issue for the
CodeQualityString, it has a couple of unusedmov rdx,rcxandmov rcx,rdxat the end.(Those do not appear to be Benchmark.Net artifacts, they show up with longer methods too).
I think I've seen this before, but couldn't find anything, if this is a duplicate, please close.
The output of Benchmark.Net 0.10.14 for
CodeQualityStringis:The output of Benchmark.NET 0.10.14 for
CodeQualityBytesis:category:cq
theme:register-allocator
skill-level:expert
cost:medium