Shortcut tiny jump detours after placement
This commit is contained in:
parent
fc9a8f2a89
commit
880abea32e
|
@ -54908,6 +54908,31 @@ void NativeCodeBasicBlock::BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeCodeBasicBlock::OptimizePlacement(void)
|
||||||
|
{
|
||||||
|
if (!mFalseJump && mTrueJump && !mTrueJump->mFalseJump && mTrueJump->mTrueJump && mTrueJump->mTrueJump->mPlace == mPlace + 1 && mTrueJump->mCode.Size() <= 3)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mTrueJump->mRelocations.Size(); i++)
|
||||||
|
{
|
||||||
|
LinkerReference rl = mTrueJump->mRelocations[i];
|
||||||
|
rl.mOffset += mCode.Size();
|
||||||
|
if (rl.mFlags & LREF_INBLOCK)
|
||||||
|
{
|
||||||
|
rl.mRefOffset += mCode.Size();
|
||||||
|
rl.mFlags &= ~LREF_INBLOCK;
|
||||||
|
}
|
||||||
|
mRelocations.Push(rl);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < mTrueJump->mCode.Size(); i++)
|
||||||
|
mCode.Push(mTrueJump->mCode[i]);
|
||||||
|
mTrueJump->mEntryBlocks.RemoveAll(this);
|
||||||
|
mTrueJump->mNumEntries--;
|
||||||
|
mTrueJump = mTrueJump->mTrueJump;
|
||||||
|
mTrueJump->mEntryBlocks.Push(this);
|
||||||
|
mTrueJump->mNumEntries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NativeCodeBasicBlock::InitialOffset(int& total)
|
void NativeCodeBasicBlock::InitialOffset(int& total)
|
||||||
{
|
{
|
||||||
mAsmFromJump = -1;
|
mAsmFromJump = -1;
|
||||||
|
@ -56064,6 +56089,9 @@ void NativeCodeProcedure::Assemble(void)
|
||||||
|
|
||||||
mEntryBlock->BuildPlacement(placement);
|
mEntryBlock->BuildPlacement(placement);
|
||||||
|
|
||||||
|
for (int i = 0; i < placement.Size(); i++)
|
||||||
|
placement[i]->OptimizePlacement();;
|
||||||
|
|
||||||
for (int i = 0; i < placement.Size(); i++)
|
for (int i = 0; i < placement.Size(); i++)
|
||||||
placement[i]->InitialOffset(total);
|
placement[i]->InitialOffset(total);
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,7 @@ public:
|
||||||
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
||||||
NativeCodeBasicBlock* PlaceSequence(ExpandingArray<NativeCodeBasicBlock*>& placement, NativeCodeBasicBlock* block);
|
NativeCodeBasicBlock* PlaceSequence(ExpandingArray<NativeCodeBasicBlock*>& placement, NativeCodeBasicBlock* block);
|
||||||
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
||||||
|
void OptimizePlacement(void);
|
||||||
void InitialOffset(int& total);
|
void InitialOffset(int& total);
|
||||||
bool CalculateOffset(int& total, bool final);
|
bool CalculateOffset(int& total, bool final);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue