| 20669 | } |
| 20670 | |
| 20671 | void 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 | { |
nothing calls this directly
no test coverage detected