mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed dependency issues, added some dependency validation
This commit is contained in:
parent
b0f50fbda6
commit
558f8678e1
5 changed files with 76 additions and 19 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
@ -1500,6 +1500,16 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
BF_ASSERT(ptrType->IsPointer());
|
BF_ASSERT(ptrType->IsPointer());
|
||||||
// We call via a function pointer so there's never a reason to allow loading of a funcPtr
|
// We call via a function pointer so there's never a reason to allow loading of a funcPtr
|
||||||
BF_ASSERT(((BePointerType*)ptrType)->mElementType->mTypeCode != BeTypeCode_Function);
|
BF_ASSERT(((BePointerType*)ptrType)->mElementType->mTypeCode != BeTypeCode_Function);
|
||||||
|
|
||||||
|
// Disallow loading from a NULL constant
|
||||||
|
if (val->GetTypeId() == BeConstant::TypeId)
|
||||||
|
{
|
||||||
|
if (auto constant = BeValueDynCast<BeConstant>(val))
|
||||||
|
{
|
||||||
|
BF_ASSERT(constant->mTarget != NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
CMD_PARAM(bool, isVolatile);
|
CMD_PARAM(bool, isVolatile);
|
||||||
SetResult(curId, mBeModule->CreateLoad(val, isVolatile));
|
SetResult(curId, mBeModule->CreateLoad(val, isVolatile));
|
||||||
|
@ -1511,6 +1521,15 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(int, alignment);
|
CMD_PARAM(int, alignment);
|
||||||
CMD_PARAM(bool, isVolatile);
|
CMD_PARAM(bool, isVolatile);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
// Disallow loading from a NULL constant
|
||||||
|
if (val->GetTypeId() == BeConstant::TypeId)
|
||||||
|
{
|
||||||
|
if (auto constant = BeValueDynCast<BeConstant>(val))
|
||||||
|
{
|
||||||
|
BF_ASSERT(constant->mTarget != NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto ptrType = val->GetType();
|
auto ptrType = val->GetType();
|
||||||
BF_ASSERT(ptrType->IsPointer());
|
BF_ASSERT(ptrType->IsPointer());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1115,7 +1115,9 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vdataHashCtx.MixinStr(module->mModuleName);
|
||||||
vdataHashCtx.Mixin(typeInst->mTypeDef->mSignatureHash);
|
vdataHashCtx.Mixin(typeInst->mTypeDef->mSignatureHash);
|
||||||
|
vdataHashCtx.Mixin(module->mHasForceLinkMarker);
|
||||||
|
|
||||||
for (auto iface : typeInst->mInterfaces)
|
for (auto iface : typeInst->mInterfaces)
|
||||||
{
|
{
|
||||||
|
@ -2064,7 +2066,7 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork)
|
||||||
// If we're deleting the type, OR the dependency of the type has been removed.
|
// If we're deleting the type, OR the dependency of the type has been removed.
|
||||||
// We detect a removed dependency by the dependent type changing but the dependency revision
|
// We detect a removed dependency by the dependent type changing but the dependency revision
|
||||||
// is older than the dependent type.
|
// is older than the dependent type.
|
||||||
BfLogSysM("Removing old dependent %p from %p\n", dependentType, typeInst);
|
BfLogSysM("Removing old dependent %p from %p\n", dependentType, depType);
|
||||||
itr = depType->mDependencyMap.erase(itr);
|
itr = depType->mDependencyMap.erase(itr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2171,7 +2173,9 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork)
|
||||||
|
|
||||||
if (deleteQueue.size() != 0)
|
if (deleteQueue.size() != 0)
|
||||||
{
|
{
|
||||||
|
mContext->ValidateDependencies();
|
||||||
mContext->UpdateAfterDeletingTypes();
|
mContext->UpdateAfterDeletingTypes();
|
||||||
|
mContext->ValidateDependencies();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2964,13 +2968,6 @@ void BfCompiler::UpdateRevisedTypes()
|
||||||
compositeTypeDef->mFullNameEx = rootTypeDef->mFullNameEx;
|
compositeTypeDef->mFullNameEx = rootTypeDef->mFullNameEx;
|
||||||
compositeTypeDef->mIsCombinedPartial = true;
|
compositeTypeDef->mIsCombinedPartial = true;
|
||||||
|
|
||||||
// if (rootTypeDef->IsGlobalsContainer())
|
|
||||||
// {
|
|
||||||
// //NOP;
|
|
||||||
// auto didAdd = mSystem->mGlobalsMap.TryAdd(rootTypeDef->mNamespace, compositeTypeDef);
|
|
||||||
// BF_ASSERT(didAdd);
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (auto prevGenericParam : rootTypeDef->mGenericParamDefs)
|
for (auto prevGenericParam : rootTypeDef->mGenericParamDefs)
|
||||||
{
|
{
|
||||||
BfGenericParamDef* copiedGenericParam = new BfGenericParamDef();
|
BfGenericParamDef* copiedGenericParam = new BfGenericParamDef();
|
||||||
|
@ -2979,8 +2976,6 @@ void BfCompiler::UpdateRevisedTypes()
|
||||||
}
|
}
|
||||||
|
|
||||||
mSystem->mTypeDefs.AddAfter(compositeTypeDef, rootTypeDefEntry);
|
mSystem->mTypeDefs.AddAfter(compositeTypeDef, rootTypeDefEntry);
|
||||||
// compositeTypeDef->mNext = rootTypeDef->mNext;
|
|
||||||
// rootTypeDef->mNext = compositeTypeDef;
|
|
||||||
partialsHadChanges = true;
|
partialsHadChanges = true;
|
||||||
hadSignatureChange = true;
|
hadSignatureChange = true;
|
||||||
compositeIsNew = true;
|
compositeIsNew = true;
|
||||||
|
@ -3249,8 +3244,12 @@ void BfCompiler::UpdateRevisedTypes()
|
||||||
mContext->UpdateRevisedTypes();
|
mContext->UpdateRevisedTypes();
|
||||||
mContext->VerifyTypeLookups();
|
mContext->VerifyTypeLookups();
|
||||||
|
|
||||||
|
mContext->ValidateDependencies();
|
||||||
if (mStats.mTypesDeleted != 0)
|
if (mStats.mTypesDeleted != 0)
|
||||||
|
{
|
||||||
mContext->UpdateAfterDeletingTypes();
|
mContext->UpdateAfterDeletingTypes();
|
||||||
|
mContext->ValidateDependencies();
|
||||||
|
}
|
||||||
mContext->RemoveInvalidWorkItems();
|
mContext->RemoveInvalidWorkItems();
|
||||||
|
|
||||||
for (auto typeDef : mSystem->mTypeDefs)
|
for (auto typeDef : mSystem->mTypeDefs)
|
||||||
|
@ -6253,6 +6252,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
if ((!IsHotCompile()) && (!mCanceling))
|
if ((!IsHotCompile()) && (!mCanceling))
|
||||||
ClearUnusedStringPoolEntries();
|
ClearUnusedStringPoolEntries();
|
||||||
|
|
||||||
|
mContext->ValidateDependencies();
|
||||||
mContext->UpdateAfterDeletingTypes();
|
mContext->UpdateAfterDeletingTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6487,6 +6487,8 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
bool didCancel = mCanceling && hasRequiredTypes;
|
bool didCancel = mCanceling && hasRequiredTypes;
|
||||||
mCanceling = false;
|
mCanceling = false;
|
||||||
|
|
||||||
|
mContext->ValidateDependencies();
|
||||||
|
|
||||||
return !didCancel;
|
return !didCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -767,6 +767,36 @@ void BfContext::AddTypeToWorkList(BfType* type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfContext::ValidateDependencies()
|
||||||
|
{
|
||||||
|
#if _DEBUG
|
||||||
|
BP_ZONE("BfContext::ValidateDependencies");
|
||||||
|
BfLogSysM("ValidateDependencies\n");
|
||||||
|
|
||||||
|
bool deletedNewTypes = false;
|
||||||
|
auto itr = mResolvedTypes.begin();
|
||||||
|
while (itr != mResolvedTypes.end())
|
||||||
|
{
|
||||||
|
auto type = itr.mCurEntry->mValue;
|
||||||
|
if (type->IsGenericTypeInstance())
|
||||||
|
{
|
||||||
|
// We can't contain deleted generic arguments without being deleted ourselves
|
||||||
|
BfGenericTypeInstance* genericType = (BfGenericTypeInstance*)type;
|
||||||
|
|
||||||
|
for (auto genericTypeArg : genericType->mTypeGenericArguments)
|
||||||
|
{
|
||||||
|
auto depType = genericTypeArg->ToDependedType();
|
||||||
|
if (depType != NULL)
|
||||||
|
{
|
||||||
|
BF_ASSERT(depType->mDependencyMap.mTypeSet.ContainsKey(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory)
|
void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory)
|
||||||
{
|
{
|
||||||
BfTypeInstance* typeInst = type->ToTypeInstance();
|
BfTypeInstance* typeInst = type->ToTypeInstance();
|
||||||
|
@ -790,6 +820,12 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeInst->mRevision != mCompiler->mRevision)
|
||||||
|
{
|
||||||
|
BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInst, mCompiler->mRevision);
|
||||||
|
typeInst->mRevision = mCompiler->mRevision;
|
||||||
|
}
|
||||||
|
|
||||||
if ((typeInst->IsTypeAlias()) != (typeInst->mTypeDef->mTypeCode == BfTypeCode_TypeAlias))
|
if ((typeInst->IsTypeAlias()) != (typeInst->mTypeDef->mTypeCode == BfTypeCode_TypeAlias))
|
||||||
{
|
{
|
||||||
BfLogSysM("TypeAlias %p status changed - deleting\n", typeInst);
|
BfLogSysM("TypeAlias %p status changed - deleting\n", typeInst);
|
||||||
|
|
|
@ -387,6 +387,7 @@ public:
|
||||||
void RemoveInvalidWorkItems();
|
void RemoveInvalidWorkItems();
|
||||||
BfType* FindTypeById(int typeId);
|
BfType* FindTypeById(int typeId);
|
||||||
void AddTypeToWorkList(BfType* type);
|
void AddTypeToWorkList(BfType* type);
|
||||||
|
void ValidateDependencies();
|
||||||
void RebuildType(BfType* type, bool deleteOnDemandTypes = true, bool rebuildModule = true, bool placeSpecializiedInPurgatory = true);
|
void RebuildType(BfType* type, bool deleteOnDemandTypes = true, bool rebuildModule = true, bool placeSpecializiedInPurgatory = true);
|
||||||
void RebuildDependentTypes(BfDependedType* dType);
|
void RebuildDependentTypes(BfDependedType* dType);
|
||||||
void TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChange);
|
void TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChange);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue