mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed inlining issues
This commit is contained in:
parent
6c049988b3
commit
ba9ce75a0b
6 changed files with 66 additions and 26 deletions
|
@ -3325,6 +3325,15 @@ void BfModule::AddDependency(BfType* usedType, BfType* userType, BfDependencyMap
|
|||
if ((usedType->mRebuildFlags & BfTypeRebuildFlag_AwaitingReference) != 0)
|
||||
mContext->MarkAsReferenced(checkDType);
|
||||
|
||||
#ifdef _DEBUG
|
||||
// If a MethodRef depends ON US, that means it's a local method that we own
|
||||
if (userType->IsMethodRef())
|
||||
{
|
||||
auto methodRefType = (BfMethodRefType*)userType;
|
||||
BF_ASSERT(methodRefType->mOwner == checkDType);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!checkDType->mDependencyMap.AddUsedBy(userType, flags))
|
||||
return;
|
||||
if (checkDType->IsGenericTypeInstance())
|
||||
|
@ -4744,6 +4753,9 @@ BfIRValue BfModule::CreateClassVDataGlobal(BfTypeInstance* typeInstance, int* ou
|
|||
classVDataName);
|
||||
|
||||
mClassVDataRefs[typeInstance] = globalVariable;
|
||||
|
||||
if (mCurTypeInstance != NULL)
|
||||
AddDependency(typeInstance, mCurTypeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||
}
|
||||
return globalVariable;
|
||||
}
|
||||
|
@ -5705,7 +5717,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
int idx = interfaceEntry->mStartVirtualIdx;
|
||||
int endVirtualIdx = interfaceEntry->mStartVirtualIdx + interfaceEntry->mInterfaceType->mVirtualMethodTableSize;
|
||||
|
||||
if (endVirtualIdx > ifaceMethodExtStart)
|
||||
if ((endVirtualIdx > ifaceMethodExtStart) && (ifaceMethodExtVar))
|
||||
vtablePtr = mBfIRBuilder->CreateInBoundsGEP(ifaceMethodExtVar, 0, interfaceEntry->mStartVirtualIdx - ifaceMethodExtStart);
|
||||
else
|
||||
vtablePtr = mBfIRBuilder->CreateInBoundsGEP(classVDataVar, 0, iFaceMethodStartIdx + interfaceEntry->mStartVirtualIdx);
|
||||
|
@ -9767,7 +9779,9 @@ BfModule* BfModule::GetSpecializedMethodModule(const SizedArrayImpl<BfProject*>&
|
|||
{
|
||||
String specModuleName = mModuleName;
|
||||
for (auto bfProject : projectList)
|
||||
specModuleName += StrFormat("@%s", bfProject->mName.c_str());
|
||||
{
|
||||
specModuleName += StrFormat("@%s", bfProject->mSafeName.c_str());
|
||||
}
|
||||
specModule = new BfModule(mContext, specModuleName);
|
||||
specModule->mProject = mainModule->mProject;
|
||||
specModule->mParentModule = mainModule;
|
||||
|
@ -12093,11 +12107,6 @@ void BfModule::AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInsta
|
|||
|
||||
BfModuleMethodInstance BfModule::ReferenceExternalMethodInstance(BfMethodInstance* methodInstance, BfGetMethodInstanceFlags flags)
|
||||
{
|
||||
if (mIsConstModule)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if ((flags & BfGetMethodInstanceFlag_ResultNotUsed) != 0)
|
||||
return BfModuleMethodInstance(methodInstance, BfIRValue());
|
||||
|
||||
|
@ -12291,11 +12300,6 @@ BfModule* BfModule::GetOrCreateMethodModule(BfMethodInstance* methodInstance)
|
|||
|
||||
BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfMethodDef* methodDef, const BfTypeVector& methodGenericArguments, BfGetMethodInstanceFlags flags, BfTypeInstance* foreignType)
|
||||
{
|
||||
if (mIsConstModule)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (methodDef->mMethodType == BfMethodType_Init)
|
||||
return BfModuleMethodInstance();
|
||||
|
||||
|
@ -12417,11 +12421,13 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
|
||||
auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
|
||||
|
||||
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoReference);
|
||||
|
||||
if (mIsConstModule)
|
||||
{
|
||||
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoReference);
|
||||
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
||||
if (!mCompiler->mIsResolveOnly)
|
||||
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoForceReification | BfGetMethodInstanceFlag_Unreified | BfGetMethodInstanceFlag_NoReference);
|
||||
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoForceReification | BfGetMethodInstanceFlag_Unreified | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
||||
}
|
||||
|
||||
// Not extern
|
||||
|
@ -12624,7 +12630,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
{
|
||||
methodInstance = methodInstGroup->mDefault;
|
||||
|
||||
if ((methodInstance != NULL) && ((flags & BfGetMethodInstanceFlag_NoReference) != 0))
|
||||
if ((methodInstance != NULL) && ((flags & BfGetMethodInstanceFlag_MethodInstanceOnly) != 0))
|
||||
return methodInstance;
|
||||
|
||||
if ((methodInstance != NULL) && (isReified) && (!methodInstance->mIsReified))
|
||||
|
@ -12735,7 +12741,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
{
|
||||
methodInstance = *methodInstancePtr;
|
||||
|
||||
if ((flags & BfGetMethodInstanceFlag_NoReference) != 0)
|
||||
if ((flags & BfGetMethodInstanceFlag_MethodInstanceOnly) != 0)
|
||||
return methodInstance;
|
||||
|
||||
if ((methodInstance->mRequestedByAutocomplete) && (!mCompiler->IsAutocomplete()))
|
||||
|
@ -12854,6 +12860,9 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
return BfModuleMethodInstance(methodInstance, BfIRFunction());
|
||||
else
|
||||
{
|
||||
if ((flags & (BfGetMethodInstanceFlag_MethodInstanceOnly | BfGetMethodInstanceFlag_NoReference)) != 0)
|
||||
return methodInstance;
|
||||
|
||||
if (methodInstance->mDeclModule != this)
|
||||
return ReferenceExternalMethodInstance(methodInstance, flags);
|
||||
|
||||
|
@ -12887,6 +12896,8 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
auto specMethodInstance = specModule->GetMethodInstance(typeInst, methodDef, methodGenericArguments, (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_ExplicitSpecializedModule));
|
||||
if (mAwaitingInitFinish)
|
||||
return BfModuleMethodInstance(specMethodInstance.mMethodInstance, BfIRFunction());
|
||||
if ((flags & (BfGetMethodInstanceFlag_MethodInstanceOnly | BfGetMethodInstanceFlag_NoReference)) != 0)
|
||||
return specMethodInstance.mMethodInstance;
|
||||
return ReferenceExternalMethodInstance(specMethodInstance.mMethodInstance, flags);
|
||||
}
|
||||
|
||||
|
@ -13247,9 +13258,10 @@ BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
|||
}
|
||||
}
|
||||
|
||||
if (mIsScratchModule)
|
||||
if ((mIsScratchModule) && (mCompiler->mIsResolveOnly))
|
||||
{
|
||||
// Just fake it for the extern and unspecialized modules
|
||||
// We can't do this for compilation because unreified methods with default params need to get acutal global variable refs
|
||||
return BfTypedValue(mBfIRBuilder->CreateConstNull(), fieldInstance->GetResolvedType(), true);
|
||||
}
|
||||
|
||||
|
@ -14935,7 +14947,7 @@ BfTypedValue BfModule::CallBaseCtorCalc(bool constOnly)
|
|||
bindResult.mWantsArgs = true;
|
||||
{
|
||||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgFlag_DeferParamEval);
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgsFlag_DeferParamEval);
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(exprEvaluator.mFunctionBindResult, &bindResult);
|
||||
exprEvaluator.MatchConstructor(targetRefNode, NULL, target, targetType, argValues, true, true);
|
||||
}
|
||||
|
@ -14978,7 +14990,7 @@ BfTypedValue BfModule::CallBaseCtorCalc(bool constOnly)
|
|||
// Do it again, but without mIgnoreWrites set
|
||||
BfResolvedArgs argValues;
|
||||
argValues.Init(&ctorInvocation->mArguments);
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgFlag_DeferParamEval);
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgsFlag_DeferParamEval);
|
||||
|
||||
BfFunctionBindResult bindResult;
|
||||
bindResult.mSkipThis = true;
|
||||
|
@ -16272,7 +16284,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
|||
OutputDebugStrF("Expr: %@ %d\n", argValues.mArguments->mVals, argValues.mArguments->mSize);
|
||||
}
|
||||
}
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgFlag_DeferParamEval);
|
||||
exprEvaluator.ResolveArgValues(argValues, BfResolveArgsFlag_DeferParamEval);
|
||||
|
||||
BfTypedValue appendIdxVal;
|
||||
if (methodDef->mHasAppend)
|
||||
|
|
|
@ -9768,7 +9768,7 @@ BfIRValue BfModule::CastToFunction(BfAstNode* srcNode, const BfTypedValue& targe
|
|||
auto dataType = GetPrimitiveType(BfTypeCode_IntPtr);
|
||||
if (!methodRefMethod.mFunc)
|
||||
{
|
||||
if (HasCompiledOutput())
|
||||
if ((!methodInstance->mIsUnspecialized) && (HasCompiledOutput()))
|
||||
AssertErrorState();
|
||||
return GetDefaultValue(dataType);
|
||||
}
|
||||
|
|
|
@ -593,6 +593,7 @@ void BfMethodInstance::CopyFrom(BfMethodInstance* methodInstance)
|
|||
*mMethodInfoEx->mClosureInstanceInfo = *methodInstance->mMethodInfoEx->mClosureInstanceInfo;
|
||||
}
|
||||
}
|
||||
mHasMethodRefType = false;
|
||||
mHasBeenProcessed = false;
|
||||
mIRFunction = BfIRValue();
|
||||
mMethodProcessRequest = NULL;
|
||||
|
|
|
@ -74,7 +74,8 @@ enum BfGetMethodInstanceFlags : uint16
|
|||
BfGetMethodInstanceFlag_DisableObjectAccessChecks = 0x200,
|
||||
BfGetMethodInstanceFlag_NoInline = 0x400,
|
||||
BfGetMethodInstanceFlag_DepthExceeded = 0x800,
|
||||
BfGetMethodInstanceFlag_NoReference = 0x1000
|
||||
BfGetMethodInstanceFlag_NoReference = 0x1000,
|
||||
BfGetMethodInstanceFlag_MethodInstanceOnly = 0x2000
|
||||
};
|
||||
|
||||
class BfDependencyMap
|
||||
|
|
|
@ -3689,6 +3689,29 @@ BF_EXPORT BfProject* BF_CALLTYPE BfSystem_CreateProject(BfSystem* bfSystem, cons
|
|||
bfProject->mSystem = bfSystem;
|
||||
bfProject->mIdx = (int)bfSystem->mProjects.size();
|
||||
bfSystem->mProjects.push_back(bfProject);
|
||||
|
||||
String safeProjectName = projectName;
|
||||
for (auto& c : safeProjectName)
|
||||
{
|
||||
if (((c >= 'A') && (c <= 'Z')) ||
|
||||
((c >= 'a') && (c <= 'z')) ||
|
||||
((c >= '0') && (c <= '9')))
|
||||
{
|
||||
// Leave
|
||||
}
|
||||
else
|
||||
c = '_';
|
||||
}
|
||||
|
||||
String tryName = safeProjectName;
|
||||
for (int i = 2; true; i++)
|
||||
{
|
||||
if (bfSystem->mUsedSafeProjectNames.Add(ToUpper(tryName)))
|
||||
break;
|
||||
tryName = safeProjectName + StrFormat("_%d", i);
|
||||
}
|
||||
bfProject->mSafeName = tryName;
|
||||
|
||||
BfLogSys(bfSystem, "Creating project %p\n", bfProject);
|
||||
return bfProject;
|
||||
}
|
||||
|
@ -3774,6 +3797,7 @@ BF_EXPORT void BF_CALLTYPE BfProject_Delete(BfProject* bfProject)
|
|||
bfProject->mDeleteStage = BfProject::DeleteStage_Queued;
|
||||
|
||||
bfSystem->mProjectDeleteQueue.push_back(bfProject);
|
||||
bfSystem->mUsedSafeProjectNames.Remove(bfProject->mSafeName);
|
||||
|
||||
BF_ASSERT(bfSystem->mProjects[bfProject->mIdx] == bfProject);
|
||||
bool wasRemoved = bfSystem->mProjects.Remove(bfProject);
|
||||
|
|
|
@ -1079,6 +1079,7 @@ public:
|
|||
public:
|
||||
BfSystem* mSystem;
|
||||
String mName;
|
||||
String mSafeName;
|
||||
Array<BfProject*> mDependencies;
|
||||
BfTargetType mTargetType;
|
||||
BfCodeGenOptions mCodeGenOptions;
|
||||
|
@ -1409,6 +1410,7 @@ public:
|
|||
|
||||
CritSect mDataLock; // short-lived, hold only while active modifying data
|
||||
// The following are protected by mDataLock:
|
||||
HashSet<String> mUsedSafeProjectNames;
|
||||
Array<BfProject*> mProjects;
|
||||
Array<BfProject*> mProjectDeleteQueue;
|
||||
Array<BfParser*> mParsers;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue