Fix static stack in recursion
Fix static stack allocation and placement for non recursive sub trees in a recursive call tree
This commit is contained in:
parent
e4e997fef2
commit
932c7ec222
|
@ -13663,6 +13663,23 @@ void InterCodeBasicBlock::ApplyStaticStack(InterOperand & iop, const GrowingVari
|
|||
}
|
||||
}
|
||||
|
||||
void InterCodeBasicBlock::CollectStaticStackDependencies(LinkerObject* lobj)
|
||||
{
|
||||
if (!mVisited)
|
||||
{
|
||||
mVisited = true;
|
||||
|
||||
for (int i = 0; i < mInstructions.Size(); i++)
|
||||
{
|
||||
if ((mInstructions[i]->mCode == IC_CALL || mInstructions[i]->mCode == IC_CALL_NATIVE) && mInstructions[i]->mSrc[0].mLinkerObject && mInstructions[i]->mSrc[0].mLinkerObject->mStackSection)
|
||||
lobj->mStackSection->mSections.Push(mInstructions[i]->mSrc[0].mLinkerObject->mStackSection);
|
||||
}
|
||||
|
||||
if (mTrueJump) mTrueJump->CollectStaticStackDependencies(lobj);
|
||||
if (mFalseJump) mFalseJump->CollectStaticStackDependencies(lobj);
|
||||
}
|
||||
}
|
||||
|
||||
void InterCodeBasicBlock::CollectStaticStack(LinkerObject* lobj, const GrowingVariableArray& localVars)
|
||||
{
|
||||
if (!mVisited)
|
||||
|
@ -22498,6 +22515,15 @@ void InterCodeProcedure::Close(void)
|
|||
DisassembleDebug("Rebuilt traces");
|
||||
#endif
|
||||
}
|
||||
else if (!mInterruptCalled && mNativeProcedure)
|
||||
{
|
||||
// mLinkerObject->mFlags |= LOBJF_STATIC_STACK;
|
||||
mLinkerObject->mStackSection = mModule->mLinker->AddSection(mIdent->Mangle("@stack"), LST_STATIC_STACK);
|
||||
mLinkerObject->mStackSection->mSections.Push(mModule->mParamLinkerSection);
|
||||
ResetVisited();
|
||||
mEntryBlock->CollectStaticStackDependencies(mLinkerObject);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DisassembleDebug("PreLoopTemp");
|
||||
|
|
|
@ -637,6 +637,7 @@ public:
|
|||
bool CheckStaticStack(void);
|
||||
void ApplyStaticStack(InterOperand& iop, const GrowingVariableArray& localVars);
|
||||
void CollectStaticStack(LinkerObject * lobj, const GrowingVariableArray& localVars);
|
||||
void CollectStaticStackDependencies(LinkerObject* lobj);
|
||||
void PromoteStaticStackParams(LinkerObject* paramlobj);
|
||||
|
||||
bool SameExitCode(const InterCodeBasicBlock* block) const;
|
||||
|
|
|
@ -731,15 +731,20 @@ bool LinkerRegion::Allocate(Linker * linker, LinkerObject* lobj, bool merge, boo
|
|||
|
||||
void LinkerRegion::PlaceStackSection(LinkerSection* stackSection, LinkerSection* section)
|
||||
{
|
||||
if (!section->mEnd)
|
||||
if (!section->mEnd && !(section->mFlags & LSECF_PLACED))
|
||||
{
|
||||
section->mFlags |= LSECF_PLACED;
|
||||
|
||||
int start = stackSection->mEnd;
|
||||
|
||||
for (int i = 0; i < section->mSections.Size(); i++)
|
||||
{
|
||||
PlaceStackSection(stackSection, section->mSections[i]);
|
||||
if (section->mSections[i]->mStart < start)
|
||||
{
|
||||
start = section->mSections[i]->mStart;
|
||||
section->mStart = start;
|
||||
}
|
||||
}
|
||||
|
||||
section->mStart = start;
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
};
|
||||
|
||||
static const uint32 LSECF_PACKED = 0x00000001;
|
||||
static const uint32 LSECF_PLACED = 0x00000002;
|
||||
|
||||
class LinkerSection
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue