This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe class UnsafeUIntArray | |
{ | |
public int Length { get; init; } | |
private readonly uint[] _data; | |
private readonly uint* _dataPtr; | |
public UnsafeUIntArray(int length) | |
{ | |
Length = length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DisassemblyDiagnoser(maxDepth: 100)] | |
public class RandomRead | |
{ | |
[Params(64, 256, 512, 1024, 4096, 1024 * 16, 1024 * 1024)] | |
public int ArraySize { get; set; } | |
private uint[] _safeArray; | |
private UnsafeUIntArray _unsafeArray; | |
private int[] _sequence; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Method Program:ForEachSumExample(int[]):int (FullOpts) | |
G_M000_IG03: ;; offset=0x000D | |
mov r10d, edx | |
add eax, dword ptr [rcx+4*r10+0x10] | |
inc edx | |
cmp r8d, edx | |
jg SHORT G_M000_IG03 | |
G_M000_IG04: ;; offset=0x001C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Method ArrayAccessExample:Get(int):int:this (FullOpts) | |
G_M000_IG01: ;; offset=0x0000 | |
sub rsp, 40 | |
G_M000_IG02: ;; offset=0x0004 | |
mov rax, gword ptr [rcx+0x08] | |
cmp edx, dword ptr [rax+0x08] | |
jae SHORT G_M000_IG04 | |
mov ecx, edx | |
mov eax, dword ptr [rax+4*rcx+0x10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mov eax, ecx | |
imul rax, rax, 0x663D81 | |
shr rax, 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mov ecx, 641 | |
div edx:eax, ecx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//while (z < limit) | |
// { | |
// sum0 += (uint)(ptr[z + 0] + ptr[z + 4] + ptr[z + 8] + ptr[z + 12] | |
//PRO | |
G_M000_IG06: | |
cmp r11d, ecx | |
jae G_M000_IG17 | |
mov ebx, r11d | |
movzx rbx, byte ptr [rdx+rbx] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
G_M000_IG06: ;; offset=007BH | |
mov r15d, r11d | |
mov r12, qword ptr [rdx+r15] | |
mov r13, qword ptr [rdx+r15+08H] | |
mov rdi, qword ptr [rdx+r15+10H] | |
mov r15, qword ptr [rdx+r15+18H] | |
mov rcx, 0xFF00FF00FF00FF | |
and rcx, r12 | |
add rsi, rcx | |
mov rcx, 0xFF00FF00FF00FF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe static uint ChecksumSenior(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed(byte* ptr = arr) | |
{ | |
uint sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0; | |
uint z = 0; | |
var limit = arr.Length - 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static uint ChecksumPro(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
uint sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0; | |
int z = 0; | |
int rem = arr.Length % 16; | |
var limit = arr.Length - rem; |
NewerOlder