mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +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();
|
||||
|
||||
//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;
|
||||
|
||||
//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)
|
||||
{
|
||||
#ifdef HOT_DEBUG_NAME
|
||||
HotResolve_PopulateMethodNameMap();
|
||||
String* namePtr = NULL;
|
||||
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &namePtr))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
HotReachableData* 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)
|
||||
{
|
||||
#ifdef HOT_DEBUG_NAME
|
||||
HotResolve_PopulateMethodNameMap();
|
||||
String* namePtr = NULL;
|
||||
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &namePtr))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mHotResolveData->mActiveMethods.Add(hotMethod))
|
||||
{
|
||||
hotMethod->mRefCount++;
|
||||
|
@ -5401,6 +5400,22 @@ void BfCompiler::HotResolve_ReportType(int typeId, HotTypeFlags flags)
|
|||
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()
|
||||
{
|
||||
BfLogSysM("HotResolve_Finish\n");
|
||||
|
@ -5470,6 +5485,14 @@ String BfCompiler::HotResolve_Finish()
|
|||
HotReachableData* 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)
|
||||
{
|
||||
typeFlags = hotReachableData->mTypeFlags;
|
||||
|
@ -5533,21 +5556,10 @@ String BfCompiler::HotResolve_Finish()
|
|||
auto hotMethod = (BfHotMethod*)reason;
|
||||
reasonIsActiveMethod = mHotResolveData->mActiveMethods.Contains(hotMethod);
|
||||
|
||||
if (methodNameMap.IsEmpty())
|
||||
{
|
||||
for (auto& kv : mHotData->mMethodMap)
|
||||
{
|
||||
auto hotMethod = kv.mValue;
|
||||
while (hotMethod != NULL)
|
||||
{
|
||||
methodNameMap[hotMethod] = &kv.mKey;
|
||||
hotMethod = hotMethod->mPrevVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
HotResolve_PopulateMethodNameMap();
|
||||
|
||||
String** strPtr;
|
||||
if (methodNameMap.TryGetValue(hotMethod, &strPtr))
|
||||
if (mHotData->mMethodNameMap.TryGetValue(hotMethod, &strPtr))
|
||||
{
|
||||
methodReason += BfDemangler::Demangle((**strPtr), DbgLanguage_Beef, BfDemangler::Flag_BeefFixed);
|
||||
}
|
||||
|
|
|
@ -239,6 +239,7 @@ public:
|
|||
public:
|
||||
BfCompiler* mCompiler;
|
||||
Dictionary<String, BfHotMethod*> mMethodMap;
|
||||
Dictionary<BfHotMethod*, String*> mMethodNameMap;
|
||||
Dictionary<BfHotTypeVersion*, BfHotThisType*> mThisType;
|
||||
Dictionary<BfHotTypeVersion*, BfHotAllocation*> mAllocation;
|
||||
Dictionary<BfHotMethod*, BfHotDevirtualizedMethod*> mDevirtualizedMethods;
|
||||
|
@ -455,6 +456,7 @@ public:
|
|||
|
||||
void HotCommit();
|
||||
void HotResolve_Start(HotResolveFlags flags);
|
||||
void HotResolve_PopulateMethodNameMap();
|
||||
bool HotResolve_AddReachableMethod(BfHotMethod* hotMethod, HotTypeFlags flags, bool devirtualized, bool forceProcess = false);
|
||||
void HotResolve_AddReachableMethod(const StringImpl& methodName);
|
||||
void HotResolve_AddActiveMethod(BfHotMethod* hotMethod);
|
||||
|
|
|
@ -2989,24 +2989,27 @@ void BfModule::AddDependency(BfType* usedType, BfType* usingType, BfDependencyMa
|
|||
if (usedType->IsSpecializedByAutoCompleteMethod())
|
||||
return;
|
||||
|
||||
if ((mCurMethodState != NULL) && (mCurMethodState->mHotDataReferenceBuilder != NULL) && (usedType != mCurTypeInstance) &&
|
||||
((flags & (BfDependencyMap::DependencyFlag_ReadFields | BfDependencyMap::DependencyFlag_LocalUsage | BfDependencyMap::DependencyFlag_Allocates)) != 0))
|
||||
BfType* origUsedType = usedType;
|
||||
bool isDataAccess = ((flags & (BfDependencyMap::DependencyFlag_ReadFields | BfDependencyMap::DependencyFlag_LocalUsage | BfDependencyMap::DependencyFlag_Allocates)) != 0);
|
||||
if (isDataAccess)
|
||||
{
|
||||
bool addType = true;
|
||||
auto checkType = usedType;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if ((checkType->IsPointer()) || (checkType->IsRef()) || (checkType->IsSizedArray()))
|
||||
checkType = checkType->GetUnderlyingType();
|
||||
else if (checkType->IsArray())
|
||||
if ((usedType->IsPointer()) || (usedType->IsRef()) || (usedType->IsSizedArray()))
|
||||
usedType = usedType->GetUnderlyingType();
|
||||
else if (usedType->IsArray())
|
||||
{
|
||||
checkType = ((BfGenericTypeInstance*)checkType)->mTypeGenericArguments[0];
|
||||
usedType = ((BfGenericTypeInstance*)usedType)->mTypeGenericArguments[0];
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mCurMethodState != NULL) && (mCurMethodState->mHotDataReferenceBuilder != NULL) && (usedType != mCurTypeInstance) && (isDataAccess))
|
||||
{
|
||||
bool addType = true;
|
||||
auto checkType = usedType;
|
||||
PopulateType(checkType, BfPopulateType_Data);
|
||||
if (checkType->IsValuelessType())
|
||||
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))
|
||||
{
|
||||
auto usingModule = usingType->GetModule();
|
||||
|
@ -3091,7 +3078,6 @@ void BfModule::AddDependency(BfType* usedType, BfType* usingType, BfDependencyMa
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
auto underlyingType = usedType->GetUnderlyingType();
|
||||
if (underlyingType != NULL) // Not really a "GenericArg", but... same purpose.
|
||||
AddDependency(underlyingType, usingType, BfDependencyMap::DependencyFlag_GenericArgRef);
|
||||
|
@ -15375,8 +15361,6 @@ void BfModule::AddHotDataReferences(BfHotDataReferenceBuilder* builder)
|
|||
BF_ASSERT(depData != NULL);
|
||||
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)
|
||||
|
|
|
@ -62,10 +62,6 @@ BfGenericExtensionEntry* BfModule::BuildGenericExtensionInfo(BfGenericTypeInstan
|
|||
typeState.mCurTypeDef = partialTypeDef;
|
||||
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;
|
||||
genericExtensionInfo->mExtensionMap.TryAdd(partialTypeDef, NULL, &genericExEntry);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue