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

Method EmitGCMarkMembers

IDEHelper/Compiler/BfModule.cpp:20671–20856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20669}
20670
20671void BfModule::EmitGCMarkMembers()
20672{
20673 auto methodDef = mCurMethodInstance->mMethodDef;
20674
20675 auto gcType = ResolveTypeDef(mCompiler->mGCTypeDef, BfPopulateType_DataAndMethods);
20676 BfModuleMethodInstance markFromGCThreadMethodInstance;
20677 if (gcType != NULL)
20678 markFromGCThreadMethodInstance = GetMethodByName(gcType->ToTypeInstance(), "Mark", 1);
20679
20680 if ((markFromGCThreadMethodInstance.mMethodInstance != NULL) && (!mCurMethodInstance->mIsUnspecialized))
20681 {
20682 if (mCurTypeInstance->IsBoxed())
20683 {
20684 // This already gets filled in by the normal boxed forwarding
20685 }
20686 else
20687 {
20688 auto thisValue = GetThis();
20689 if (thisValue.IsSplat())
20690 {
20691 BfIRFunction func = mCurMethodInstance->mIRFunction;
20692 int argIdx = 0;
20693
20694 std::function<void(BfType*)> checkTypeLambda = [&](BfType* checkType)
20695 {
20696 if (checkType->IsStruct())
20697 {
20698 auto checkTypeInstance = checkType->ToTypeInstance();
20699 if (checkTypeInstance->mBaseType != NULL)
20700 checkTypeLambda(checkTypeInstance->mBaseType);
20701 for (int fieldIdx = 0; fieldIdx < (int)checkTypeInstance->mFieldInstances.size(); fieldIdx++)
20702 {
20703 auto fieldInstance = (BfFieldInstance*)&checkTypeInstance->mFieldInstances[fieldIdx];
20704 if (fieldInstance->mDataIdx >= 0)
20705 checkTypeLambda(fieldInstance->GetResolvedType());
20706 }
20707 }
20708 else if (checkType->IsMethodRef())
20709 {
20710 BFMODULE_FATAL(this, "Not handled");
20711 }
20712 else if (checkType->WantsGCMarking())
20713 {
20714 BfTypedValue markValue(mBfIRBuilder->GetArgument(argIdx), checkType);
20715 EmitGCMarkValue(markValue, markFromGCThreadMethodInstance);
20716 argIdx++;
20717 }
20718 };
20719
20720 checkTypeLambda(thisValue.mType);
20721 }
20722 else if (!methodDef->mIsStatic)
20723 {
20724 if ((mCurTypeInstance->mBaseType != NULL) && (!mCurTypeInstance->IsTypedPrimitive()) && (mCurTypeInstance->mBaseType->WantsGCMarking()))
20725 {
20726 BfModuleMethodInstance moduleMethodInst = GetMethodByName(mCurTypeInstance->mBaseType, BF_METHODNAME_MARKMEMBERS, 0, true);
20727 if (moduleMethodInst)
20728 {

Callers

nothing calls this directly

Calls 15

BfTypedValueClass · 0.85
IsSplatMethod · 0.80
GetResolvedTypeMethod · 0.80
IsExtensionMethod · 0.80
GetFieldDefMethod · 0.80
GetParamIsSplatMethod · 0.80
SplatArgsMethod · 0.80
GetMangleKindMethod · 0.80
IsAppendedObjectMethod · 0.80
CreateInBoundsGEPMethod · 0.80
MapTypeMethod · 0.80
HasAppendCtorMethod · 0.80

Tested by

no test coverage detected