mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Avoiding suspending BeefPerf thread
This commit is contained in:
parent
f1e2148769
commit
aa7cff43dd
2 changed files with 30 additions and 7 deletions
|
@ -216,6 +216,16 @@ BFGC::ThreadInfo::~ThreadInfo()
|
||||||
BfpThread_Release(mThreadHandle);
|
BfpThread_Release(mThreadHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BFGC::ThreadInfo::WantsSuspend()
|
||||||
|
{
|
||||||
|
#ifndef BP_DISABLED
|
||||||
|
BfpThreadId threadId = BpManager::Get()->mThreadId;
|
||||||
|
return threadId != (BfpThreadId)mThreadId;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef BF_GC_LOG_ENABLED
|
#ifdef BF_GC_LOG_ENABLED
|
||||||
|
@ -1371,7 +1381,7 @@ bool BFGC::ScanThreads()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BP_ZONE("ThreadCollect");
|
BP_ZONE_F("ThreadCollect %d", thread->mThreadId);
|
||||||
//Beefy::DebugTimeGuard suspendTimeGuard(10, "ThreadSuspend");
|
//Beefy::DebugTimeGuard suspendTimeGuard(10, "ThreadSuspend");
|
||||||
|
|
||||||
DWORD result = 0;
|
DWORD result = 0;
|
||||||
|
@ -1405,16 +1415,24 @@ bool BFGC::ScanThreads()
|
||||||
|
|
||||||
BFLOG2(GCLog::EVENT_SCAN_THREAD, (intptr)thread, (intptr)thread->mThreadId);
|
BFLOG2(GCLog::EVENT_SCAN_THREAD, (intptr)thread, (intptr)thread->mThreadId);
|
||||||
|
|
||||||
for (auto obj : thread->mStackMarkableObjects)
|
//
|
||||||
{
|
{
|
||||||
MarkMembers(obj);
|
BP_ZONE("StackMarkableObjects");
|
||||||
|
for (auto obj : thread->mStackMarkableObjects)
|
||||||
|
{
|
||||||
|
MarkMembers(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr regVals[64];
|
intptr regVals[64];
|
||||||
intptr stackPtr = 0;
|
intptr stackPtr = 0;
|
||||||
BfpThreadResult threadResult;
|
BfpThreadResult threadResult;
|
||||||
int regValCount = 64;
|
int regValCount = 64;
|
||||||
BfpThread_GetIntRegisters(thread->mThreadHandle, &stackPtr, regVals, ®ValCount, &threadResult);
|
///
|
||||||
|
{
|
||||||
|
BP_ZONE("BfpThread_GetIntRegisters");
|
||||||
|
BfpThread_GetIntRegisters(thread->mThreadHandle, &stackPtr, regVals, ®ValCount, &threadResult);
|
||||||
|
}
|
||||||
BF_ASSERT(threadResult == BfpThreadResult_Ok);
|
BF_ASSERT(threadResult == BfpThreadResult_Ok);
|
||||||
|
|
||||||
void** threadLoadAddressMap = (void**)((_TEB*)thread->mTEB)->ThreadLocalStorage;
|
void** threadLoadAddressMap = (void**)((_TEB*)thread->mTEB)->ThreadLocalStorage;
|
||||||
|
@ -1432,7 +1450,10 @@ bool BFGC::ScanThreads()
|
||||||
int length = thread->mStackStart - stackPtr;
|
int length = thread->mStackStart - stackPtr;
|
||||||
|
|
||||||
AdjustStackPtr(stackPtr, length);
|
AdjustStackPtr(stackPtr, length);
|
||||||
ConservativeScan((void*)stackPtr, length);
|
{
|
||||||
|
BP_ZONE("ConservativeScan stack");
|
||||||
|
ConservativeScan((void*)stackPtr, length);
|
||||||
|
}
|
||||||
mQueueMarkObjects = false;
|
mQueueMarkObjects = false;
|
||||||
|
|
||||||
if (mDoStackDeepMark)
|
if (mDoStackDeepMark)
|
||||||
|
@ -2260,7 +2281,7 @@ void BFGC::SuspendThreads()
|
||||||
auto curThreadId = GetCurrentThreadId();
|
auto curThreadId = GetCurrentThreadId();
|
||||||
for (auto thread : mThreadList)
|
for (auto thread : mThreadList)
|
||||||
{
|
{
|
||||||
if ((thread->mThreadId != curThreadId) && (thread->mRunning))
|
if ((thread->mThreadId != curThreadId) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||||
{
|
{
|
||||||
// We must lock this before suspending so we can access mStackMarkableObjects
|
// We must lock this before suspending so we can access mStackMarkableObjects
|
||||||
// Otherwise we could deadlock
|
// Otherwise we could deadlock
|
||||||
|
@ -2279,7 +2300,7 @@ void BFGC::ResumeThreads()
|
||||||
auto curThreadId = GetCurrentThreadId();
|
auto curThreadId = GetCurrentThreadId();
|
||||||
for (auto thread : mThreadList)
|
for (auto thread : mThreadList)
|
||||||
{
|
{
|
||||||
if ((thread->mThreadId != curThreadId) && (thread->mRunning))
|
if ((thread->mThreadId != curThreadId) && (thread->mRunning) && (thread->WantsSuspend()))
|
||||||
{
|
{
|
||||||
// Previously locked in SuspendThreads
|
// Previously locked in SuspendThreads
|
||||||
thread->mCritSect.Unlock();
|
thread->mCritSect.Unlock();
|
||||||
|
|
|
@ -186,6 +186,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~ThreadInfo();
|
~ThreadInfo();
|
||||||
|
|
||||||
|
bool WantsSuspend();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RawLeakInfo
|
struct RawLeakInfo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue