mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Improvements to emit markers on emits only in specialized types
This commit is contained in:
parent
01112c54fe
commit
5271f5e2fd
14 changed files with 342 additions and 68 deletions
|
@ -7199,16 +7199,13 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
|
||||
bool didWork = false;
|
||||
UpdateDependencyMap(mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_ResolveUnused, didWork);
|
||||
|
||||
if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude)
|
||||
|
||||
// If UpdateDependencyMap caused methods to be reified, then we need to run PopulateReified again-
|
||||
// because those methods may be virtual and we need to reify overrides (for example).
|
||||
// We use the DoWorkLoop result to determine if there were actually any changes from UpdateDependencyMap
|
||||
if (didWork)
|
||||
{
|
||||
// If UpdateDependencyMap caused methods to be reified, then we need to run PopulateReified again-
|
||||
// because those methods may be virtual and we need to reify overrides (for example).
|
||||
// We use the DoWorkLoop result to determine if there were actually any changes from UpdateDependencyMap
|
||||
if (didWork)
|
||||
{
|
||||
PopulateReified();
|
||||
}
|
||||
PopulateReified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9814,6 +9811,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
};
|
||||
Dictionary<BfTypeDef*, Dictionary<int, _EmitSource>> emitLocMap;
|
||||
|
||||
bool mayHaveMissedEmits = false;
|
||||
|
||||
for (auto type : bfCompiler->mContext->mResolvedTypes)
|
||||
{
|
||||
auto typeInst = type->ToTypeInstance();
|
||||
|
@ -9825,6 +9824,12 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
|||
if (typeInst->mCeTypeInfo == NULL)
|
||||
continue;
|
||||
|
||||
if ((typeInst->mCeTypeInfo->mMayHaveUniqueEmitLocations) && (!mayHaveMissedEmits))
|
||||
{
|
||||
outString += "~\n";
|
||||
mayHaveMissedEmits = true;
|
||||
}
|
||||
|
||||
for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap)
|
||||
{
|
||||
int partialIdx = (int)(kv.mKey >> 32);
|
||||
|
|
|
@ -2091,6 +2091,9 @@ void BfModule::SetTypeOptions(BfTypeInstance* typeInstance)
|
|||
|
||||
BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef* declaringType, const StringImpl& src, BfAstNode* refNode, BfCeTypeEmitSourceKind emitSourceKind)
|
||||
{
|
||||
if (mCompiler->mResolvePassData != NULL)
|
||||
mCompiler->mResolvePassData->mHadEmits = true;
|
||||
|
||||
BfCEParseContext ceParseContext;
|
||||
ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx;
|
||||
ceParseContext.mWarnIdx = mCompiler->mPassInstance->mWarnIdx;
|
||||
|
@ -2114,10 +2117,20 @@ BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef*
|
|||
}
|
||||
else
|
||||
{
|
||||
ceTypeInfo->mEmitSourceMap.TryAdd(emitSourceMapKey, NULL, &ceEmitSource);
|
||||
if (ceTypeInfo->mEmitSourceMap.TryAdd(emitSourceMapKey, NULL, &ceEmitSource))
|
||||
{
|
||||
if (typeInstance->IsSpecializedType())
|
||||
{
|
||||
auto unspecializedType = GetUnspecializedTypeInstance(typeInstance);
|
||||
if ((unspecializedType->mCeTypeInfo == NULL) || (!unspecializedType->mCeTypeInfo->mEmitSourceMap.ContainsKey(emitSourceMapKey)))
|
||||
ceTypeInfo->mMayHaveUniqueEmitLocations = true;
|
||||
}
|
||||
}
|
||||
ceEmitSource->mKind = emitSourceKind;
|
||||
}
|
||||
|
||||
BfLogSysM("CEEmitParse type %p ceTypeInfo %p\n", typeInstance, ceTypeInfo);
|
||||
|
||||
int emitSrcStart = 0;
|
||||
|
||||
BfEmitEmbedEntry* emitEmbedEntry = NULL;
|
||||
|
@ -4748,6 +4761,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
{
|
||||
if (typeInstance->mCeTypeInfo->mNext != NULL)
|
||||
{
|
||||
BfLogSysM("Type %p injecting next ceTypeInfo %p into ceTypeInfo %p\n", typeInstance, typeInstance->mCeTypeInfo->mNext, typeInstance->mCeTypeInfo);
|
||||
|
||||
auto ceInfo = typeInstance->mCeTypeInfo->mNext;
|
||||
|
||||
HashContext hashCtx;
|
||||
|
@ -5799,7 +5814,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|||
ambiguityContext.mTypeInstance = typeInstance;
|
||||
ambiguityContext.mModule = this;
|
||||
ambiguityContext.mIsProjectSpecific = false;
|
||||
|
||||
|
||||
bool wantsOnDemandMethods = false;
|
||||
//TODO: Testing having interface methods be "on demand"...
|
||||
//if (!typeInstance->IsInterface())
|
||||
|
@ -5825,6 +5840,36 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
|||
if (TypeIsSubTypeOf(typeInstance, mCompiler->mAttributeTypeDef))
|
||||
wantsOnDemandMethods = false;
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (!mCompiler->mResolvePassData->mEmitEmbedEntries.IsEmpty()) && (typeInstance->IsSpecializedType()))
|
||||
{
|
||||
bool isCurrentEntry = false;
|
||||
|
||||
auto _CheckEntry = [&](BfTypeDef* typeDef)
|
||||
{
|
||||
auto parser = typeDef->mTypeDeclaration->GetParser();
|
||||
if (parser != NULL)
|
||||
if (mCompiler->mResolvePassData->GetSourceClassifier(parser) != NULL)
|
||||
isCurrentEntry = true;
|
||||
};
|
||||
|
||||
_CheckEntry(typeInstance->mTypeDef);
|
||||
for (auto& partial : typeInstance->mTypeDef->mPartials)
|
||||
_CheckEntry(partial);
|
||||
|
||||
if (isCurrentEntry)
|
||||
{
|
||||
String typeName;
|
||||
typeName += typeInstance->mTypeDef->mProject->mName;
|
||||
typeName += ":";
|
||||
typeName += TypeToString(typeInstance, BfTypeNameFlags_None);
|
||||
|
||||
if (mCompiler->mResolvePassData->mEmitEmbedEntries.ContainsKey(typeName))
|
||||
{
|
||||
wantsOnDemandMethods = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bool allDeclsRequired = (mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && ();
|
||||
bool allDeclsRequired = false;
|
||||
//if ((mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && (!mCompiler->mWantsDeferMethodDecls))
|
||||
|
@ -10210,9 +10255,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|||
auto directStrTypeRef = BfNodeDynCastExact<BfDirectStrTypeReference>(typeRef);
|
||||
if (((namedTypeRef != NULL) && (namedTypeRef->mNameNode != NULL)) || (directStrTypeRef != NULL))
|
||||
{
|
||||
StringT<128> findName;
|
||||
StringView findName;
|
||||
if (namedTypeRef != NULL)
|
||||
namedTypeRef->mNameNode->ToString(findName);
|
||||
findName = namedTypeRef->mNameNode->ToStringView();
|
||||
else
|
||||
findName = directStrTypeRef->mTypeName;
|
||||
if (findName == "Self")
|
||||
|
|
|
@ -21,6 +21,7 @@ BfResolvePassData::BfResolvePassData()
|
|||
mResolveType = BfResolveType_None;
|
||||
mIsClassifying = false;
|
||||
mHasCursorIdx = false;
|
||||
mHadEmits = false;
|
||||
}
|
||||
|
||||
BfResolvePassData::~BfResolvePassData()
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
int mSymbolTypeGenericParamIdx;
|
||||
bool mIsClassifying;
|
||||
bool mHasCursorIdx;
|
||||
bool mHadEmits;
|
||||
|
||||
typedef Dictionary<BfParserData*, String> FoundSymbolReferencesParserDataMap;
|
||||
FoundSymbolReferencesParserDataMap mFoundSymbolReferencesParserData;
|
||||
|
|
|
@ -1766,11 +1766,6 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
|||
|
||||
_CheckConst();
|
||||
|
||||
if (isStatic)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if ((initValue.mKind == BfTypedValueKind_TempAddr) && (!initHandled))
|
||||
{
|
||||
BF_ASSERT(initValue.IsAddr());
|
||||
|
|
|
@ -4013,6 +4013,11 @@ BF_EXPORT void* BfResolvePassData_GetEmitEmbedData(BfResolvePassData* resolvePas
|
|||
return emitEmbedEntry->mParser->mSourceClassifier->mCharData;
|
||||
}
|
||||
|
||||
BF_EXPORT bool BfResolvePassData_GetHadEmits(BfResolvePassData* resolvePassData)
|
||||
{
|
||||
return resolvePassData->mHadEmits;
|
||||
}
|
||||
|
||||
BF_EXPORT BfParser* BF_CALLTYPE BfSystem_CreateParser(BfSystem* bfSystem, BfProject* bfProject)
|
||||
{
|
||||
return bfSystem->CreateParser(bfProject);
|
||||
|
|
|
@ -3286,11 +3286,7 @@ void CeBuilder::Build()
|
|||
}
|
||||
|
||||
if (mCeFunction->mGenError.IsEmpty())
|
||||
mCeFunction->mFailed = false;
|
||||
else
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
mCeFunction->mFailed = false;
|
||||
|
||||
mCeFunction->mFrameSize = mFrameSize;
|
||||
}
|
||||
|
|
|
@ -1012,12 +1012,14 @@ public:
|
|||
Dictionary<CeRebuildKey, CeRebuildValue> mRebuildMap;
|
||||
Val128 mHash;
|
||||
bool mFailed;
|
||||
bool mMayHaveUniqueEmitLocations;
|
||||
BfCeTypeInfo* mNext;
|
||||
|
||||
public:
|
||||
BfCeTypeInfo()
|
||||
{
|
||||
mFailed = false;
|
||||
mMayHaveUniqueEmitLocations = false;
|
||||
mNext = NULL;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue