[+] FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING

[+] ThreadingConfig::bPreferEmulatedWakeOnAddress
This commit is contained in:
Reece Wilson 2023-07-30 09:52:41 +01:00
parent c306c12763
commit ceb5b2961e
2 changed files with 21 additions and 4 deletions

View File

@ -334,6 +334,7 @@ namespace Aurora
bool bPreferNt51XpCondvarsOver8 { false }; bool bPreferNt51XpCondvarsOver8 { false };
bool bPreferNtCondvarModernWinSpin { false }; bool bPreferNtCondvarModernWinSpin { false };
bool bPreferNtCondvarOlderWinSpin { true }; bool bPreferNtCondvarOlderWinSpin { true };
bool bPreferEmulatedWakeOnAddress { false };
}; };
struct RuntimeStartInfo struct RuntimeStartInfo

View File

@ -16,6 +16,7 @@
#include <Time/Time.hpp> #include <Time/Time.hpp>
#define HACK_NO_INVALID_ACCESS_LEAK_SHARED_REF_ON_DESTROYED_THREAD #define HACK_NO_INVALID_ACCESS_LEAK_SHARED_REF_ON_DESTROYED_THREAD
//#define FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING
namespace Aurora::Threading namespace Aurora::Threading
{ {
@ -183,7 +184,7 @@ namespace Aurora::Threading
bool WaitEntry::TryWakeNoLockNoReallyNoLock(const void *pAddress) bool WaitEntry::TryWakeNoLockNoReallyNoLock(const void *pAddress)
{ {
#if 0 #if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING)
if (AuReinterpretCast<const char *>(this->pAddress) > AuReinterpretCast<const char *>(pAddress) || if (AuReinterpretCast<const char *>(this->pAddress) > AuReinterpretCast<const char *>(pAddress) ||
AuReinterpretCast<const char *>(this->pAddress) + this->uSize <= AuReinterpretCast<const char *>(pAddress)) AuReinterpretCast<const char *>(this->pAddress) + this->uSize <= AuReinterpretCast<const char *>(pAddress))
{ {
@ -203,7 +204,7 @@ namespace Aurora::Threading
bool WaitEntry::TryWakeNoLock(const void *pAddress) bool WaitEntry::TryWakeNoLock(const void *pAddress)
{ {
#if 0 #if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING)
if (AuReinterpretCast<const char *>(this->pAddress) > AuReinterpretCast<const char *>(pAddress) || if (AuReinterpretCast<const char *>(this->pAddress) > AuReinterpretCast<const char *>(pAddress) ||
AuReinterpretCast<const char *>(this->pAddress) + this->uSize <= AuReinterpretCast<const char *>(pAddress)) AuReinterpretCast<const char *>(this->pAddress) + this->uSize <= AuReinterpretCast<const char *>(pAddress))
{ {
@ -350,17 +351,32 @@ namespace Aurora::Threading
WaitEntry *ProcessWaitContainer::WaitBufferFrom(void *pAddress, AuUInt8 uSize) WaitEntry *ProcessWaitContainer::WaitBufferFrom(void *pAddress, AuUInt8 uSize)
{ {
return this->list[AuHashCode(pAddress) % AuArraySize(this->list)].WaitBufferFrom(pAddress, uSize); #if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING)
auto pAddressIDC = (void *)(AuUInt(pAddress) & ~(8 - 1));
#else
auto pAddressIDC = pAddress;
#endif
return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].WaitBufferFrom(pAddress, uSize);
} }
template <typename T> template <typename T>
bool ProcessWaitContainer::IterateWake(void *pAddress, T callback) bool ProcessWaitContainer::IterateWake(void *pAddress, T callback)
{ {
return this->list[AuHashCode(pAddress) % AuArraySize(this->list)].IterateWake(callback); #if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING)
auto pAddressIDC = (void *)(AuUInt(pAddress) & ~(8 - 1));
#else
auto pAddressIDC = pAddress;
#endif
return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].IterateWake(callback);
} }
AUKN_SYM bool IsWaitOnRecommended() AUKN_SYM bool IsWaitOnRecommended()
{ {
if (gRuntimeConfig.threadingConfig.bPreferEmulatedWakeOnAddress)
{
return false;
}
#if defined(AURORA_IS_MODERNNT_DERIVED) #if defined(AURORA_IS_MODERNNT_DERIVED)
return pWaitOnAddress && return pWaitOnAddress &&
AuSwInfo::IsWindows8Point1OrGreater(); AuSwInfo::IsWindows8Point1OrGreater();