Tier0: fix pattern precaching

Fix taken from IcePixelx/silver-bun@e11bfb7fa7

We should migrate to the new header only implementation once there's more time to mifrate the code + testing it.
This commit is contained in:
Kawe Mazidjatari 2024-04-03 01:44:08 +02:00
parent a546836a10
commit a26e51ae00

View File

@ -91,9 +91,9 @@ CMemory CMemory::FindPattern(const char* szPattern, const Direction searchDirect
{ {
// If either the current byte equals to the byte in our pattern or our current byte in the pattern is a wildcard // If either the current byte equals to the byte in our pattern or our current byte in the pattern is a wildcard
// our if clause will be false. // our if clause will be false.
uint8_t currentByte = *(pScanBytes + nMemOffset + j); uint8_t* const pCurrentAddr = (pScanBytes + nMemOffset + j);
_mm_prefetch(reinterpret_cast<const CHAR*>(static_cast<int64>(currentByte + nMemOffset + 64)), _MM_HINT_T0); // precache some data in L1. _mm_prefetch(reinterpret_cast<const char*>(pCurrentAddr + 64), _MM_HINT_T0); // precache some data in L1.
if (currentByte != bytesInfo.second[j] && bytesInfo.second[j] != -1) if (*pCurrentAddr != bytesInfo.second[j] && bytesInfo.second[j] != -1)
{ {
bFound = false; bFound = false;
break; break;
@ -138,9 +138,9 @@ CMemory CMemory::FindPatternSelf(const char* szPattern, const Direction searchDi
{ {
// If either the current byte equals to the byte in our pattern or our current byte in the pattern is a wildcard // If either the current byte equals to the byte in our pattern or our current byte in the pattern is a wildcard
// our if clause will be false. // our if clause will be false.
uint8_t currentByte = *(pScanBytes + nMemOffset + j); uint8_t* const pCurrentAddr = (pScanBytes + nMemOffset + j);
_mm_prefetch(reinterpret_cast<const CHAR*>(static_cast<int64>(currentByte + nMemOffset + 64)), _MM_HINT_T0); // precache some data in L1. _mm_prefetch(reinterpret_cast<const char*>(pCurrentAddr + 64), _MM_HINT_T0); // precache some data in L1.
if (currentByte != bytesInfo.second[j] && bytesInfo.second[j] != -1) if (*pCurrentAddr != bytesInfo.second[j] && bytesInfo.second[j] != -1)
{ {
bFound = false; bFound = false;
break; break;