mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed some hot-compile dependency issues
This commit is contained in:
parent
394dec5bae
commit
1624b38958
4 changed files with 63 additions and 69 deletions
|
@ -3327,25 +3327,6 @@ void BfCompiler::UpdateRevisedTypes()
|
||||||
}
|
}
|
||||||
mContext->RemoveInvalidWorkItems();
|
mContext->RemoveInvalidWorkItems();
|
||||||
|
|
||||||
//for (auto typeDef : mSystem->mTypeDefs)
|
|
||||||
//{
|
|
||||||
// auto latestTypeDef = typeDef->GetLatest();
|
|
||||||
// if ((latestTypeDef->mOuterType != NULL) && (latestTypeDef->mOuterType->mIsPartial) && (latestTypeDef->mIsCombinedPartial))
|
|
||||||
// //((!latestTypeDef->mIsPartial) || (latestTypeDef->mIsCombinedPartial)))
|
|
||||||
// latestTypeDef->mOuterType = mSystem->GetOuterTypeNonPartial(latestTypeDef);
|
|
||||||
|
|
||||||
// /*String fullName = typeDef->mFullNameEx.ToString();
|
|
||||||
// if (fullName == "System.Collections.List`1.Enumerator`1")
|
|
||||||
// {
|
|
||||||
// NOP;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if ((typeDef->mOuterType != NULL) && (!typeDef->mIsPartial) && (typeDef->mOuterType->mIsPartial) && (!typeDef->mOuterType->mIsCombinedPartial))
|
|
||||||
// {
|
|
||||||
// NOP;
|
|
||||||
// }*/
|
|
||||||
//}
|
|
||||||
|
|
||||||
mSystem->mNeedsTypesHandledByCompiler = false;
|
mSystem->mNeedsTypesHandledByCompiler = false;
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
|
@ -5163,8 +5144,18 @@ void BfCompiler::HotResolve_Start(HotResolveFlags flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#define HOT_DEBUG_NAME
|
||||||
|
|
||||||
bool BfCompiler::HotResolve_AddReachableMethod(BfHotMethod* hotMethod, HotTypeFlags flags, bool devirtualized, bool forceProcess)
|
bool BfCompiler::HotResolve_AddReachableMethod(BfHotMethod* hotMethod, HotTypeFlags flags, bool devirtualized, bool forceProcess)
|
||||||
{
|
{
|
||||||
|
#ifdef HOT_DEBUG_NAME
|
||||||
|
HotResolve_PopulateMethodNameMap();
|
||||||
|
String* namePtr = NULL;
|
||||||
|
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &namePtr))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
HotReachableData* hotReachableData;
|
HotReachableData* hotReachableData;
|
||||||
if (mHotResolveData->mReachableMethods.TryAdd(hotMethod, NULL, &hotReachableData))
|
if (mHotResolveData->mReachableMethods.TryAdd(hotMethod, NULL, &hotReachableData))
|
||||||
{
|
{
|
||||||
|
@ -5268,6 +5259,14 @@ void BfCompiler::HotResolve_AddReachableMethod(const StringImpl& methodName)
|
||||||
|
|
||||||
void BfCompiler::HotResolve_AddActiveMethod(BfHotMethod* hotMethod)
|
void BfCompiler::HotResolve_AddActiveMethod(BfHotMethod* hotMethod)
|
||||||
{
|
{
|
||||||
|
#ifdef HOT_DEBUG_NAME
|
||||||
|
HotResolve_PopulateMethodNameMap();
|
||||||
|
String* namePtr = NULL;
|
||||||
|
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &namePtr))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mHotResolveData->mActiveMethods.Add(hotMethod))
|
if (mHotResolveData->mActiveMethods.Add(hotMethod))
|
||||||
{
|
{
|
||||||
hotMethod->mRefCount++;
|
hotMethod->mRefCount++;
|
||||||
|
@ -5401,6 +5400,22 @@ void BfCompiler::HotResolve_ReportType(int typeId, HotTypeFlags flags)
|
||||||
mHotResolveData->mHotTypeIdFlags[typeId] = (HotTypeFlags)(flags | mHotResolveData->mHotTypeIdFlags[typeId]);
|
mHotResolveData->mHotTypeIdFlags[typeId] = (HotTypeFlags)(flags | mHotResolveData->mHotTypeIdFlags[typeId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfCompiler::HotResolve_PopulateMethodNameMap()
|
||||||
|
{
|
||||||
|
if (!mHotData->mMethodNameMap.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto& kv : mHotData->mMethodMap)
|
||||||
|
{
|
||||||
|
auto hotMethod = kv.mValue;
|
||||||
|
while (hotMethod != NULL)
|
||||||
|
{
|
||||||
|
mHotData->mMethodNameMap[hotMethod] = &kv.mKey;
|
||||||
|
hotMethod = hotMethod->mPrevVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String BfCompiler::HotResolve_Finish()
|
String BfCompiler::HotResolve_Finish()
|
||||||
{
|
{
|
||||||
BfLogSysM("HotResolve_Finish\n");
|
BfLogSysM("HotResolve_Finish\n");
|
||||||
|
@ -5470,6 +5485,14 @@ String BfCompiler::HotResolve_Finish()
|
||||||
HotReachableData* hotReachableData;
|
HotReachableData* hotReachableData;
|
||||||
if (mHotResolveData->mReachableMethods.TryGetValue(hotVirtualDecl->mMethod, &hotReachableData))
|
if (mHotResolveData->mReachableMethods.TryGetValue(hotVirtualDecl->mMethod, &hotReachableData))
|
||||||
{
|
{
|
||||||
|
#ifdef HOT_DEBUG_NAME
|
||||||
|
HotResolve_PopulateMethodNameMap();
|
||||||
|
String* namePtr = NULL;
|
||||||
|
if (mHotData->mMethodNameMap.TryGetValue(hotVirtualDecl->mMethod, &namePtr))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hotReachableData->mHadNonDevirtualizedCall)
|
if (hotReachableData->mHadNonDevirtualizedCall)
|
||||||
{
|
{
|
||||||
typeFlags = hotReachableData->mTypeFlags;
|
typeFlags = hotReachableData->mTypeFlags;
|
||||||
|
@ -5533,21 +5556,10 @@ String BfCompiler::HotResolve_Finish()
|
||||||
auto hotMethod = (BfHotMethod*)reason;
|
auto hotMethod = (BfHotMethod*)reason;
|
||||||
reasonIsActiveMethod = mHotResolveData->mActiveMethods.Contains(hotMethod);
|
reasonIsActiveMethod = mHotResolveData->mActiveMethods.Contains(hotMethod);
|
||||||
|
|
||||||
if (methodNameMap.IsEmpty())
|
HotResolve_PopulateMethodNameMap();
|
||||||
{
|
|
||||||
for (auto& kv : mHotData->mMethodMap)
|
|
||||||
{
|
|
||||||
auto hotMethod = kv.mValue;
|
|
||||||
while (hotMethod != NULL)
|
|
||||||
{
|
|
||||||
methodNameMap[hotMethod] = &kv.mKey;
|
|
||||||
hotMethod = hotMethod->mPrevVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String** strPtr;
|
String** strPtr;
|
||||||
if (methodNameMap.TryGetValue(hotMethod, &strPtr))
|
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &strPtr))
|
||||||
{
|
{
|
||||||
methodReason += BfDemangler::Demangle((**strPtr), DbgLanguage_Beef, BfDemangler::Flag_BeefFixed);
|
methodReason += BfDemangler::Demangle((**strPtr), DbgLanguage_Beef, BfDemangler::Flag_BeefFixed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,7 @@ public:
|
||||||
public:
|
public:
|
||||||
BfCompiler* mCompiler;
|
BfCompiler* mCompiler;
|
||||||
Dictionary<String, BfHotMethod*> mMethodMap;
|
Dictionary<String, BfHotMethod*> mMethodMap;
|
||||||
|
Dictionary<BfHotMethod*, String*> mMethodNameMap;
|
||||||
Dictionary<BfHotTypeVersion*, BfHotThisType*> mThisType;
|
Dictionary<BfHotTypeVersion*, BfHotThisType*> mThisType;
|
||||||
Dictionary<BfHotTypeVersion*, BfHotAllocation*> mAllocation;
|
Dictionary<BfHotTypeVersion*, BfHotAllocation*> mAllocation;
|
||||||
Dictionary<BfHotMethod*, BfHotDevirtualizedMethod*> mDevirtualizedMethods;
|
Dictionary<BfHotMethod*, BfHotDevirtualizedMethod*> mDevirtualizedMethods;
|
||||||
|
@ -455,6 +456,7 @@ public:
|
||||||
|
|
||||||
void HotCommit();
|
void HotCommit();
|
||||||
void HotResolve_Start(HotResolveFlags flags);
|
void HotResolve_Start(HotResolveFlags flags);
|
||||||
|
void HotResolve_PopulateMethodNameMap();
|
||||||
bool HotResolve_AddReachableMethod(BfHotMethod* hotMethod, HotTypeFlags flags, bool devirtualized, bool forceProcess = false);
|
bool HotResolve_AddReachableMethod(BfHotMethod* hotMethod, HotTypeFlags flags, bool devirtualized, bool forceProcess = false);
|
||||||
void HotResolve_AddReachableMethod(const StringImpl& methodName);
|
void HotResolve_AddReachableMethod(const StringImpl& methodName);
|
||||||
void HotResolve_AddActiveMethod(BfHotMethod* hotMethod);
|
void HotResolve_AddActiveMethod(BfHotMethod* hotMethod);
|
||||||
|
|
|
@ -2989,24 +2989,27 @@ void BfModule::AddDependency(BfType* usedType, BfType* usingType, BfDependencyMa
|
||||||
if (usedType->IsSpecializedByAutoCompleteMethod())
|
if (usedType->IsSpecializedByAutoCompleteMethod())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mHotDataReferenceBuilder != NULL) && (usedType != mCurTypeInstance) &&
|
BfType* origUsedType = usedType;
|
||||||
((flags & (BfDependencyMap::DependencyFlag_ReadFields | BfDependencyMap::DependencyFlag_LocalUsage | BfDependencyMap::DependencyFlag_Allocates)) != 0))
|
bool isDataAccess = ((flags & (BfDependencyMap::DependencyFlag_ReadFields | BfDependencyMap::DependencyFlag_LocalUsage | BfDependencyMap::DependencyFlag_Allocates)) != 0);
|
||||||
|
if (isDataAccess)
|
||||||
{
|
{
|
||||||
bool addType = true;
|
|
||||||
auto checkType = usedType;
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ((checkType->IsPointer()) || (checkType->IsRef()) || (checkType->IsSizedArray()))
|
if ((usedType->IsPointer()) || (usedType->IsRef()) || (usedType->IsSizedArray()))
|
||||||
checkType = checkType->GetUnderlyingType();
|
usedType = usedType->GetUnderlyingType();
|
||||||
else if (checkType->IsArray())
|
else if (usedType->IsArray())
|
||||||
{
|
{
|
||||||
checkType = ((BfGenericTypeInstance*)checkType)->mTypeGenericArguments[0];
|
usedType = ((BfGenericTypeInstance*)usedType)->mTypeGenericArguments[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mCurMethodState != NULL) && (mCurMethodState->mHotDataReferenceBuilder != NULL) && (usedType != mCurTypeInstance) && (isDataAccess))
|
||||||
|
{
|
||||||
|
bool addType = true;
|
||||||
|
auto checkType = usedType;
|
||||||
PopulateType(checkType, BfPopulateType_Data);
|
PopulateType(checkType, BfPopulateType_Data);
|
||||||
if (checkType->IsValuelessType())
|
if (checkType->IsValuelessType())
|
||||||
addType = false;
|
addType = false;
|
||||||
|
@ -3046,22 +3049,6 @@ void BfModule::AddDependency(BfType* usedType, BfType* usingType, BfDependencyMa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//BP_ZONE("BfModule::AddDependency");
|
|
||||||
|
|
||||||
/*if (usedType->IsMethodRef())
|
|
||||||
{
|
|
||||||
auto methodRefType = (BfMethodRefType*)usedType;
|
|
||||||
AddDependency(methodRefType->mMethodRef->GetOwner(), usingType, flags);
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Why in the world were we doing this?
|
|
||||||
// This caused functions to get immediately deleted since they appear to have no references ever....
|
|
||||||
// if (usedType->IsFunction())
|
|
||||||
// {
|
|
||||||
// usedType = ResolveTypeDef(mCompiler->mFunctionTypeDef);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ((!mCompiler->mIsResolveOnly) && (mIsReified))
|
if ((!mCompiler->mIsResolveOnly) && (mIsReified))
|
||||||
{
|
{
|
||||||
auto usingModule = usingType->GetModule();
|
auto usingModule = usingType->GetModule();
|
||||||
|
@ -3091,7 +3078,6 @@ void BfModule::AddDependency(BfType* usedType, BfType* usingType, BfDependencyMa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto underlyingType = usedType->GetUnderlyingType();
|
auto underlyingType = usedType->GetUnderlyingType();
|
||||||
if (underlyingType != NULL) // Not really a "GenericArg", but... same purpose.
|
if (underlyingType != NULL) // Not really a "GenericArg", but... same purpose.
|
||||||
AddDependency(underlyingType, usingType, BfDependencyMap::DependencyFlag_GenericArgRef);
|
AddDependency(underlyingType, usingType, BfDependencyMap::DependencyFlag_GenericArgRef);
|
||||||
|
@ -15375,8 +15361,6 @@ void BfModule::AddHotDataReferences(BfHotDataReferenceBuilder* builder)
|
||||||
BF_ASSERT(depData != NULL);
|
BF_ASSERT(depData != NULL);
|
||||||
depData->mRefCount++;
|
depData->mRefCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//hotMethod->mReferences.Sort([](BfHotDepData* lhs, BfHotDepData* rhs) { return lhs < rhs; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfType* thisType, bool wantsDIData, SizedArrayImpl<BfIRMDNode>* diParams)
|
void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfType* thisType, bool wantsDIData, SizedArrayImpl<BfIRMDNode>* diParams)
|
||||||
|
|
|
@ -62,10 +62,6 @@ BfGenericExtensionEntry* BfModule::BuildGenericExtensionInfo(BfGenericTypeInstan
|
||||||
typeState.mCurTypeDef = partialTypeDef;
|
typeState.mCurTypeDef = partialTypeDef;
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
//auto genericExEntry = new BfGenericExtensionEntry();
|
|
||||||
//auto insertPair = genericExtensionInfo->mExtensionMap.insert(std::make_pair(partialTypeDef, BfGenericExtensionEntry()));
|
|
||||||
//auto genericExEntry = &insertPair.first->second;
|
|
||||||
|
|
||||||
BfGenericExtensionEntry* genericExEntry;
|
BfGenericExtensionEntry* genericExEntry;
|
||||||
genericExtensionInfo->mExtensionMap.TryAdd(partialTypeDef, NULL, &genericExEntry);
|
genericExtensionInfo->mExtensionMap.TryAdd(partialTypeDef, NULL, &genericExEntry);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue