| 5807 | ////////////////////////////////////////////////////////////////////////// |
| 5808 | |
| 5809 | void BfCompiler::PopulateReified() |
| 5810 | { |
| 5811 | BfLogSysM("BfCompiler::PopulateReified\n"); |
| 5812 | BP_ZONE("PopulateReified"); |
| 5813 | |
| 5814 | BfContext* context = mContext; |
| 5815 | bool hasTests = mSystem->HasTestProjects(); |
| 5816 | |
| 5817 | Array<BfMethodInstance*> impChainHeadMethods; |
| 5818 | |
| 5819 | // Types can pull in new dependencies, so fully populate types until they stop |
| 5820 | bool reifiedOnly = mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude; |
| 5821 | while (true) |
| 5822 | { |
| 5823 | BP_ZONE("Compile_PopulateTypes"); |
| 5824 | |
| 5825 | int startTypeInitCount = mTypeInitCount; |
| 5826 | |
| 5827 | bool didWork = false; |
| 5828 | |
| 5829 | BfLogSysM("PopulateReified iteration start\n"); |
| 5830 | |
| 5831 | Array<BfType*> typeList; |
| 5832 | typeList.Reserve(context->mResolvedTypes.GetCount()); |
| 5833 | for (auto type : context->mResolvedTypes) |
| 5834 | typeList.Add(type); |
| 5835 | |
| 5836 | int typeCount = 0; |
| 5837 | for (auto type : typeList) |
| 5838 | { |
| 5839 | auto module = type->GetModule(); |
| 5840 | typeCount++; |
| 5841 | |
| 5842 | if (module == NULL) |
| 5843 | continue; |
| 5844 | |
| 5845 | if (!type->IsReified()) |
| 5846 | { |
| 5847 | // On compiles, only handle reified types in this loop. This fixes cases where our first instance of a dependent type |
| 5848 | // is found to be unreified and then we have to reify it later. It's not an error, just a compile perf issue |
| 5849 | continue; |
| 5850 | } |
| 5851 | |
| 5852 | // We have to not populate generic type instances because that may force us to populate a type that SHOULD be deleted |
| 5853 | if ((type->IsIncomplete()) && (type->IsTypeInstance()) && (!type->IsGenericTypeInstance())) |
| 5854 | { |
| 5855 | mSystem->CheckLockYield(); |
| 5856 | module->PopulateType(type, BfPopulateType_Full); |
| 5857 | } |
| 5858 | |
| 5859 | auto typeInst = type->ToTypeInstance(); |
| 5860 | |
| 5861 | if ((typeInst != NULL) && (typeInst->IsGenericTypeInstance()) && (!typeInst->IsUnspecializedType()) && |
| 5862 | (!typeInst->IsDelegateFromTypeRef()) && (!typeInst->IsFunctionFromTypeRef()) && (!typeInst->IsTuple())) |
| 5863 | { |
| 5864 | auto unspecializedType = module->GetUnspecializedTypeInstance(typeInst); |
| 5865 | if (!unspecializedType->mIsReified) |
| 5866 | unspecializedType->mIsReified = true; |
nothing calls this directly
no test coverage detected