Fastcall for virtual functions

This commit is contained in:
drmortalwombat 2023-07-23 13:51:24 +02:00
parent 9b2d90ec58
commit 33b7bee047

View File

@ -323,6 +323,50 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
nbase = n; nbase = n;
} }
if (procDec->mValue && procDec->mValue->mType == EX_DISPATCH)
{
Declaration* maxf = nullptr;
for (int i = 0; i < procDec->mCalled.Size(); i++)
{
Declaration* cf = procDec->mCalled[i];
if (!maxf)
maxf = cf;
else if (!(maxf->mBase->mFlags & DTF_STACKCALL))
{
if (cf->mBase->mFlags & DTF_STACKCALL)
maxf = cf;
else if (cf->mBase->mFastCallBase > maxf->mBase->mFastCallBase)
maxf = cf;
}
}
for (int i = 0; i < procDec->mCalled.Size(); i++)
{
Declaration* cf = procDec->mCalled[i];
if (cf != maxf)
{
if (maxf->mBase->mFlags & DTF_STACKCALL)
{
cf->mBase->mFlags &= ~DTF_FASTCALL;
cf->mBase->mFlags |= DTF_STACKCALL;
}
cf->mParams = maxf->mParams;
cf->mBase->mFastCallBase = cf->mFastCallBase = maxf->mBase->mFastCallBase;
cf->mBase->mFastCallSize = cf->mFastCallSize = maxf->mBase->mFastCallSize;
}
}
procDec->mFastCallBase = procDec->mBase->mFastCallBase;
procDec->mFastCallSize = procDec->mBase->mFastCallSize;
procDec->mFlags &= ~DTF_FUNC_ANALYZING;
return;
}
procDec->mFastCallBase = nbase; procDec->mFastCallBase = nbase;
procDec->mFastCallSize = 0; procDec->mFastCallSize = 0;
procDec->mBase->mFastCallBase = nbase; procDec->mBase->mFastCallBase = nbase;
@ -336,7 +380,7 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head)
} }
else if (procDec->mFlags & DTF_FUNC_RECURSIVE) else if (procDec->mFlags & DTF_FUNC_RECURSIVE)
{ {
if (head) // if (head)
procDec->mBase->mFlags |= DTF_STACKCALL; procDec->mBase->mFlags |= DTF_STACKCALL;
} }
else if (!(procDec->mBase->mFlags & DTF_VARIADIC) && !(procDec->mFlags & DTF_FUNC_VARIABLE) && !(procDec->mFlags & DTF_DYNSTACK)) else if (!(procDec->mBase->mFlags & DTF_VARIADIC) && !(procDec->mFlags & DTF_FUNC_VARIABLE) && !(procDec->mFlags & DTF_DYNSTACK))
@ -675,7 +719,7 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo
return exp->mDecValue->mBase; return exp->mDecValue->mBase;
case EX_DISPATCH: case EX_DISPATCH:
Analyze(exp->mLeft, procDec, lhs); Analyze(exp->mLeft, procDec, lhs);
RegisterCall(procDec, exp->mLeft->mDecType); // RegisterCall(procDec, exp->mLeft->mDecType);
break; break;
case EX_VCALL: case EX_VCALL:
exp->mType = EX_CALL; exp->mType = EX_CALL;
@ -950,7 +994,7 @@ void GlobalAnalyzer::RegisterProc(Declaration* to)
{ {
if (to->mType == DT_CONST_FUNCTION) if (to->mType == DT_CONST_FUNCTION)
{ {
#if 0 #if 1
if (to->mBase->mFlags & DTF_VIRTUAL) if (to->mBase->mFlags & DTF_VIRTUAL)
{ {