MCPcopy Create free account
hub / github.com/beefytech/Beef / PerformCollection

Method PerformCollection

BeefRT/dbg/gc.cpp:2509–2611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2507}
2508
2509void BFGC::PerformCollection()
2510{
2511 BP_ZONE("TriggerCollection");
2512
2513 if (mCollectIdx == 0)
2514 {
2515 // 'Prime' register capture
2516 intptr regVals[128];
2517 intptr stackPtr = 0;
2518 BfpThreadResult threadResult;
2519 int regValCount = 128;
2520 BfpThread_GetIntRegisters(BfpThread_GetCurrent(), &stackPtr, regVals, &regValCount, &threadResult);
2521 }
2522
2523 int prevMarkId = mCurMarkId;
2524
2525 DWORD startTick = BFTickCount();
2526 CollectReport collectReport;
2527 collectReport.mCollectIdx = mCollectIdx;
2528 collectReport.mStartTick = startTick;
2529
2530#ifndef BF_MINGW
2531 //_CrtCheckMemory();
2532#endif
2533
2534#ifdef BF_GC_INCREMENTAL
2535 mFullGCTriggered = true;
2536 mForceDecommit |= forceDecommit;
2537 gBFGC.mCollectEvent.Set();
2538#else
2539 Beefy::AutoCrit autoCrit(mCritSect);
2540 mAllocSinceLastGC = 0;
2541 mCollectFailed = false;
2542
2543 // This was old "emergency" debugging code to make sure we weren't doing a malloc in the GC code,
2544 // but it's a multi-threaded race condition
2545 /*uint8* mallocAddr = (uint8*)&malloc;
2546 DWORD oldProtect = 0;
2547 BOOL worked = ::VirtualProtect(mallocAddr, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
2548 uint8 oldCode = *mallocAddr;
2549 *mallocAddr = 0xCC;*/
2550
2551 mOrderedPendingGCData.Reserve(BF_GC_MAX_PENDING_OBJECT_COUNT);
2552
2553 uint32 suspendStartTick = BFTickCount();
2554 SuspendThreads();
2555
2556#ifndef BF_MINGW
2557 //_CrtCheckMemory();
2558#endif
2559 DoCollect(true);
2560#ifndef BF_MINGW
2561 //_CrtCheckMemory();
2562#endif
2563
2564 //*mallocAddr = oldCode;
2565
2566#ifdef BF_GC_EMPTYSCAN

Callers

nothing calls this directly

Calls 8

BfpSystem_TickCountFunction · 0.50
SetMethod · 0.45
ReserveMethod · 0.45
ClearMethod · 0.45
sizeMethod · 0.45
RemoveAtMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected