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

Method ObjReportHandleSpan

BeefRT/dbg/gc.cpp:2247–2294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2245}
2246
2247void BFGC::ObjReportHandleSpan(tcmalloc_obj::Span* span, int expectedStartPage, int& objectCount, intptr& freeSize, Beefy::Dictionary<bf::System::Type*, AllocInfo>& sizeMap)
2248{
2249 if (span->location != tcmalloc_obj::Span::IN_USE)
2250 return;
2251
2252 if (span->start != expectedStartPage)
2253 {
2254 return;
2255 }
2256
2257 intptr pageSize = (intptr)1<<kPageShift;
2258 intptr spanSize = pageSize * span->length;
2259 void* spanStart = (void*)((intptr)span->start << kPageShift);
2260 void* spanEnd = (void*)((intptr)spanStart + spanSize);
2261 void* spanPtr = spanStart;
2262
2263 BF_LOGASSERT((spanStart >= tcmalloc_obj::PageHeap::sAddressStart) && (spanEnd <= tcmalloc_obj::PageHeap::sAddressEnd));
2264
2265 intptr elementSize = Static::sizemap()->ByteSizeForClass(span->sizeclass);
2266 if (elementSize == 0)
2267 elementSize = spanSize;
2268 BF_LOGASSERT(elementSize >= sizeof(bf::System::Object));
2269
2270 while (spanPtr <= (uint8*)spanEnd - elementSize)
2271 {
2272 bf::System::Object* obj = (bf::System::Object*)spanPtr;
2273 if (obj->mAllocCheckPtr != 0)
2274 {
2275 int objectFlags = obj->mObjectFlags;
2276 if ((objectFlags & BF_OBJECTFLAG_DELETED) == 0)
2277 {
2278 bf::System::Type* type = obj->_GetType();
2279 //auto pairVal = sizeMap.insert(std::make_pair(type, 0));
2280 //int newSize = pairVal.first->second + elementSize;
2281 //pairVal.first->second = newSize;
2282 AllocInfo* sizePtr = NULL;
2283 sizeMap.TryAdd(type, NULL, &sizePtr);
2284 sizePtr->mObjCount++;
2285 sizePtr->mObjSize += elementSize;
2286
2287 objectCount++;
2288 }
2289 }
2290 else
2291 freeSize += elementSize;
2292 spanPtr = (void*)((intptr)spanPtr + elementSize);
2293 }
2294}
2295
2296void BFGC::ObjReportScan(int& objectCount, intptr& freeSize, Beefy::Dictionary<bf::System::Type*, AllocInfo>& sizeMap)
2297{

Callers

nothing calls this directly

Calls 3

_GetTypeMethod · 0.80
ByteSizeForClassMethod · 0.45
TryAddMethod · 0.45

Tested by

no test coverage detected