mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Better mHadPendingGCDataOverflow handling, null TEB fix
This commit is contained in:
parent
14e1ffa5ac
commit
60b6437f69
1 changed files with 33 additions and 23 deletions
|
@ -257,6 +257,7 @@ public:
|
||||||
EVENT_FINALIZE_LIST,
|
EVENT_FINALIZE_LIST,
|
||||||
EVENT_LEAK,
|
EVENT_LEAK,
|
||||||
EVENT_DELETE,
|
EVENT_DELETE,
|
||||||
|
EVENT_FOUND,
|
||||||
EVENT_FREE,
|
EVENT_FREE,
|
||||||
EVENT_WB_MOVE,
|
EVENT_WB_MOVE,
|
||||||
EVENT_WEAK_REF,
|
EVENT_WEAK_REF,
|
||||||
|
@ -278,7 +279,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Beefy::CritSect mCritSect;
|
Beefy::CritSect mCritSect;
|
||||||
static const int BUFFSIZE = 1024*1024;
|
static const int BUFFSIZE = 4*1024*1024;
|
||||||
static const int BUFFSIZE_MASK = BUFFSIZE-1;
|
static const int BUFFSIZE_MASK = BUFFSIZE-1;
|
||||||
Entry mBuffer[BUFFSIZE];
|
Entry mBuffer[BUFFSIZE];
|
||||||
volatile int mHead;
|
volatile int mHead;
|
||||||
|
@ -381,7 +382,7 @@ public:
|
||||||
fprintf(fp, "GCUnfreeze MarkId:%d Tick:%d\n", ent.mParam1, ent.mParam2);
|
fprintf(fp, "GCUnfreeze MarkId:%d Tick:%d\n", ent.mParam1, ent.mParam2);
|
||||||
break;
|
break;
|
||||||
case EVENT_MARK:
|
case EVENT_MARK:
|
||||||
fprintf(fp, "GCMark Obj:%p Flags:%X Parent:%p\n", ent.mParam1, ent.mParam2, ent.mParam3);
|
fprintf(fp, "GCMark Obj:%p Flags:0x%X Parent:%p\n", ent.mParam1, ent.mParam2, ent.mParam3);
|
||||||
break;
|
break;
|
||||||
case EVENT_WB_MARK:
|
case EVENT_WB_MARK:
|
||||||
fprintf(fp, "WriteBarrierMark Obj:%p Type:%s Thread:%p\n", ent.mParam1, GetNameStr((bf::System::Type*)ent.mParam2), ent.mParam3);
|
fprintf(fp, "WriteBarrierMark Obj:%p Type:%s Thread:%p\n", ent.mParam1, GetNameStr((bf::System::Type*)ent.mParam2), ent.mParam3);
|
||||||
|
@ -398,6 +399,9 @@ public:
|
||||||
case EVENT_LEAK:
|
case EVENT_LEAK:
|
||||||
fprintf(fp, "Leak Detected:%p Type:%s\n", ent.mParam1, GetNameStr((bf::System::Type*)ent.mParam2));
|
fprintf(fp, "Leak Detected:%p Type:%s\n", ent.mParam1, GetNameStr((bf::System::Type*)ent.mParam2));
|
||||||
break;
|
break;
|
||||||
|
case EVENT_FOUND:
|
||||||
|
fprintf(fp, "Found Obj:%p Flags:0x%X\n", ent.mParam1, ent.mParam2);
|
||||||
|
break;
|
||||||
case EVENT_FREE:
|
case EVENT_FREE:
|
||||||
fprintf(fp, "Free Obj:%p\n", ent.mParam1);
|
fprintf(fp, "Free Obj:%p\n", ent.mParam1);
|
||||||
break;
|
break;
|
||||||
|
@ -417,7 +421,7 @@ public:
|
||||||
fprintf(fp, "ConservativeScan:%p to %p\n", ent.mParam1, ent.mParam2);
|
fprintf(fp, "ConservativeScan:%p to %p\n", ent.mParam1, ent.mParam2);
|
||||||
break;
|
break;
|
||||||
case EVENT_GC_DONE:
|
case EVENT_GC_DONE:
|
||||||
fprintf(fp, "GCDone\n");
|
fprintf(fp, "GCDone MarkCount:%d HadOverflow:%d\n", ent.mParam1, ent.mParam2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BF_FATAL("Unknown event");
|
BF_FATAL("Unknown event");
|
||||||
|
@ -979,6 +983,8 @@ void BFGC::SweepSpan(tcmalloc_obj::Span* span, int expectedStartPage)
|
||||||
if (objectFlags == 0)
|
if (objectFlags == 0)
|
||||||
mCurSweepFoundPermanentCount++;
|
mCurSweepFoundPermanentCount++;
|
||||||
|
|
||||||
|
BFLOG2(GCLog::EVENT_FOUND, (intptr)obj, obj->mObjectFlags);
|
||||||
|
|
||||||
int markId = objectFlags & BF_OBJECTFLAG_MARK_ID_MASK;
|
int markId = objectFlags & BF_OBJECTFLAG_MARK_ID_MASK;
|
||||||
if ((mCollectFailed) && (markId != mCurMarkId))
|
if ((mCollectFailed) && (markId != mCurMarkId))
|
||||||
{
|
{
|
||||||
|
@ -1468,10 +1474,10 @@ bool BFGC::ScanThreads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr regVals[64];
|
intptr regVals[128];
|
||||||
intptr stackPtr = 0;
|
intptr stackPtr = 0;
|
||||||
BfpThreadResult threadResult;
|
BfpThreadResult threadResult;
|
||||||
int regValCount = 64;
|
int regValCount = 128;
|
||||||
///
|
///
|
||||||
{
|
{
|
||||||
BP_ZONE("BfpThread_GetIntRegisters");
|
BP_ZONE("BfpThread_GetIntRegisters");
|
||||||
|
@ -1485,14 +1491,17 @@ bool BFGC::ScanThreads()
|
||||||
|
|
||||||
BF_ASSERT(threadResult == BfpThreadResult_Ok);
|
BF_ASSERT(threadResult == BfpThreadResult_Ok);
|
||||||
|
|
||||||
void** threadLoadAddressMap = (void**)((_TEB*)thread->mTEB)->ThreadLocalStorage;
|
if (thread->mTEB != NULL)
|
||||||
for (auto& tlsMember : mTLSMembers)
|
|
||||||
{
|
{
|
||||||
void* threadLoadAddress = threadLoadAddressMap[tlsMember.mTLSIndex];
|
void** threadLoadAddressMap = (void**)((_TEB*)thread->mTEB)->ThreadLocalStorage;
|
||||||
|
for (auto& tlsMember : mTLSMembers)
|
||||||
|
{
|
||||||
|
void* threadLoadAddress = threadLoadAddressMap[tlsMember.mTLSIndex];
|
||||||
|
|
||||||
typedef void(*MarkFunc)(void*);
|
typedef void(*MarkFunc)(void*);
|
||||||
MarkFunc markFunc = *(MarkFunc*)&tlsMember.mMarkFunc;
|
MarkFunc markFunc = *(MarkFunc*)&tlsMember.mMarkFunc;
|
||||||
markFunc((uint8*)threadLoadAddress + tlsMember.mTLSOffset);
|
markFunc((uint8*)threadLoadAddress + tlsMember.mTLSOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mQueueMarkObjects = true;
|
mQueueMarkObjects = true;
|
||||||
|
@ -2384,6 +2393,8 @@ void BFGC::PerformCollection()
|
||||||
{
|
{
|
||||||
BP_ZONE("TriggerCollection");
|
BP_ZONE("TriggerCollection");
|
||||||
|
|
||||||
|
int prevMarkId = mCurMarkId;
|
||||||
|
|
||||||
DWORD startTick = BFTickCount();
|
DWORD startTick = BFTickCount();
|
||||||
CollectReport collectReport;
|
CollectReport collectReport;
|
||||||
collectReport.mCollectIdx = mCollectIdx;
|
collectReport.mCollectIdx = mCollectIdx;
|
||||||
|
@ -2446,8 +2457,7 @@ void BFGC::PerformCollection()
|
||||||
//BFGCLogWrite();
|
//BFGCLogWrite();
|
||||||
|
|
||||||
mFinalizeList.Clear();
|
mFinalizeList.Clear();
|
||||||
if (!mHadPendingGCDataOverflow)
|
Sweep();
|
||||||
Sweep();
|
|
||||||
|
|
||||||
#ifdef BF_GC_DEBUGSWEEP
|
#ifdef BF_GC_DEBUGSWEEP
|
||||||
ResumeThreads();
|
ResumeThreads();
|
||||||
|
@ -2458,7 +2468,7 @@ void BFGC::PerformCollection()
|
||||||
ReleasePendingObjects();
|
ReleasePendingObjects();
|
||||||
ProcessSweepInfo();
|
ProcessSweepInfo();
|
||||||
|
|
||||||
BFLOG2(GCLog::EVENT_GC_DONE, sCurMarkId, BfpSystem_TickCount());
|
BFLOG2(GCLog::EVENT_GC_DONE, mCurGCMarkCount, mHadPendingGCDataOverflow ? 1 : 0);
|
||||||
|
|
||||||
collectReport.mTotalMS = BFTickCount() - startTick;
|
collectReport.mTotalMS = BFTickCount() - startTick;
|
||||||
|
|
||||||
|
@ -2686,9 +2696,9 @@ void BFGC::MarkFromGCThread(bf::System::Object* obj)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mHadPendingGCDataOverflow = true;
|
|
||||||
// No more room left -- we can't queue...
|
// No more room left -- we can't queue...
|
||||||
//MarkMembers(obj);
|
mHadPendingGCDataOverflow = true;
|
||||||
|
mCollectFailed = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue