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

Function BFGetObjectSize

BeefRT/dbg/gc.cpp:836–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834int gMarkTargetMutatorCount = 0;
835
836int BFGetObjectSize(bf::System::Object* obj)
837{
838// auto span = TCGetSpanAt(obj);
839// int elementSize = Static::sizemap()->ByteSizeForClass(span->sizeclass);
840// if (elementSize != 0)
841// return elementSize;
842// intptr pageSize = (intptr)1 << kPageShift;
843// int spanSize = pageSize * span->length;
844// return spanSize;
845
846 const PageID p = reinterpret_cast<uintptr_t>(obj) >> kPageShift;
847 size_t cl = Static::pageheap()->GetSizeClassIfCached(p);
848 int allocSize = 0;
849 if (cl == 0)
850 {
851 auto span = Static::pageheap()->GetDescriptor(p);
852 if (span != NULL)
853 {
854 cl = span->sizeclass;
855 if (cl == 0)
856 {
857 allocSize = span->length << kPageShift;
858 }
859 }
860 }
861 if (cl != 0)
862 allocSize = Static::sizemap()->class_to_size(cl);
863 return allocSize;
864}
865
866
867

Callers 4

BFCheckObjectSizeFunction · 0.85
ObjectDeleteRequestedMethod · 0.85
FinishCollectMethod · 0.85
WriteDebugDumpStateMethod · 0.85

Calls 2

GetDescriptorMethod · 0.80
class_to_sizeMethod · 0.45

Tested by

no test coverage detected