Bug 450000 - Back out nanojit jump-patching machinery, r=danderson.

This commit is contained in:
Graydon Hoare 2008-12-10 17:31:17 -08:00
parent ba3dc13800
commit 3cbd1cd998
7 changed files with 12 additions and 74 deletions

View File

@ -664,9 +664,9 @@ namespace nanojit
{
Fragment *frag = lr->exit->target;
NanoAssert(frag->fragEntry != 0);
NIns* was = nPatchBranch((NIns*)lr->jmpToTarget, frag->fragEntry);
NIns* was = nPatchBranch((NIns*)lr->jmp, frag->fragEntry);
verbose_only(verbose_outputf("patching jump at %p to target %p (was %p)\n",
lr->jmpToTarget, frag->fragEntry, was);)
lr->jmp, frag->fragEntry, was);)
(void)was;
}
@ -680,24 +680,6 @@ namespace nanojit
}
}
void Assembler::disconnectLoop(GuardRecord *lr)
{
NanoAssert(lr->stubEntry);
NIns* was = nPatchBranch((NIns*)lr->jmpToStub, (NIns*)lr->stubEntry);
verbose_only(verbose_outputf("disconnected loop-jump at %p: exiting to %p (was looping to %p)\n",
lr->jmpToStub, lr->stubEntry, was);)
NanoAssert(lr->exit->from->loopEntry == was);
}
void Assembler::reconnectLoop(GuardRecord *lr)
{
NanoAssert(lr->exit->from->loopEntry);
NIns* was = nPatchBranch((NIns*)lr->jmpToStub, lr->exit->from->loopEntry);
verbose_only(verbose_outputf("reconnected loop-jump at %p: looping to %p (was exiting to %p)\n",
lr->jmpToStub, lr->exit->from->loopEntry, was);)
NanoAssert(lr->stubEntry == was);
}
NIns* Assembler::asm_exit(LInsp guard)
{
SideExit *exit = guard->record()->exit;
@ -755,14 +737,14 @@ namespace nanojit
//NOP();
// we are done producing the exit logic for the guard so demark where our exit block code begins
guard->record()->stubEntry = _nIns; // target in exit path for our mainline conditional jump
NIns* jmpTarget = _nIns; // target in exit path for our mainline conditional jump
// swap back pointers, effectively storing the last location used in the exit path
swapptrs();
_inExit = false;
//verbose_only( verbose_outputf(" LIR_xt/xf swapptrs, _nIns is now %08X(%08X), _nExitIns is now %08X(%08X)",_nIns, *_nIns,_nExitIns,*_nExitIns) );
verbose_only( verbose_outputf(" %p:",guard->record()->stubEntry);)
verbose_only( verbose_outputf(" %p:",jmpTarget);)
verbose_only( verbose_outputf("--------------------------------------- exit block (LIR_xt|LIR_xf)") );
#ifdef NANOJIT_IA32
@ -773,7 +755,7 @@ namespace nanojit
verbose_only( _verbose = priorVerbose; )
verbose_only(_stats.exitnative += (_stats.native-nativeSave));
return (NIns*) guard->record()->stubEntry;
return jmpTarget;
}
void Assembler::beginAssembly(Fragment *frag, RegAllocMap* branchStateMap)

View File

@ -191,8 +191,6 @@ namespace nanojit
void releaseRegisters();
void patch(GuardRecord *lr);
void patch(SideExit *exit);
void disconnectLoop(GuardRecord *lr);
void reconnectLoop(GuardRecord *lr);
AssmError error() { return _err; }
void setError(AssmError e) { _err = e; }
void setCallTable(const CallInfo *functions);

View File

@ -566,24 +566,6 @@ namespace nanojit
return f;
}
void Fragmento::disconnectLoops()
{
for (int i = 0; i < _frags.size(); ++i) {
Fragment* frag = _frags.at(i);
if (frag->lastIns->isop(LIR_loop))
_assm->disconnectLoop(frag->lastIns->record());
}
}
void Fragmento::reconnectLoops()
{
for (int i = 0; i < _frags.size(); ++i) {
Fragment* frag = _frags.at(i);
if (frag->lastIns->isop(LIR_loop))
_assm->reconnectLoop(frag->lastIns->record());
}
}
void Fragment::releaseLirBuffer()
{
lastIns = 0;

View File

@ -113,8 +113,6 @@ namespace nanojit
Fragment* createBranch(SideExit *exit, const void* ip);
Fragment* newFrag(const void* ip);
Fragment* newBranch(Fragment *from, const void* ip);
void disconnectLoops();
void reconnectLoops();
verbose_only ( uint32_t pageCount(); )
verbose_only ( void dumpStats(); )

View File

@ -65,9 +65,7 @@ namespace nanojit {
struct GuardRecord
{
void* jmpToStub;
void* stubEntry;
void* jmpToTarget;
void* jmp;
GuardRecord* next;
SideExit* exit;
};

View File

@ -128,7 +128,7 @@ Assembler::nFragExit(LInsp guard)
JMP_far(_epilogue);
// stick the jmp pointer to the start of the sequence
lr->jmpToTarget = _nIns;
lr->jmp = _nIns;
}
// pop the stack frame first
@ -1223,24 +1223,14 @@ Assembler::asm_cmp(LIns *cond)
void
Assembler::asm_loop(LInsp ins, NInsList& loopJumps)
{
GuardRecord* guard = ins->record();
SideExit* exit = guard->exit;
// XXX asm_loop should be in Assembler.cpp!
// Emit an exit stub that the loop may be patched to jump to (for example if we
// want to terminate the loop because a timeout fires).
asm_exit(ins);
// Emit the patchable jump itself.
JMP_far(0);
loopJumps.add(_nIns);
guard->jmpToStub = _nIns;
// If the target we are looping to is in a different fragment, we have to restore
// SP since we will target fragEntry and not loopEntry.
if (exit->target != _thisfrag)
if (ins->record()->exit->target != _thisfrag)
MR(SP,FP);
}

View File

@ -170,7 +170,7 @@ namespace nanojit
Fragment *frag = exit->target;
GuardRecord *lr = 0;
bool destKnown = (frag && frag->fragEntry);
if (destKnown && !trees && !guard->isop(LIR_loop))
if (destKnown && !trees)
{
// already exists, emit jump now. no patching required.
JMP(frag->fragEntry);
@ -185,11 +185,11 @@ namespace nanojit
underrunProtect(14);
_nIns -= 8;
*(intptr_t *)_nIns = intptr_t(_epilogue);
lr->jmpToTarget = _nIns;
lr->jmp = _nIns;
JMPm_nochk(0);
#else
JMP_long(_epilogue);
lr->jmpToTarget = _nIns;
lr->jmp = _nIns;
#endif
}
// first restore ESP from EBP, undoing SUBi(SP,amt) from genPrologue
@ -963,22 +963,12 @@ namespace nanojit
void Assembler::asm_loop(LInsp ins, NInsList& loopJumps)
{
GuardRecord* guard = ins->record();
SideExit* exit = guard->exit;
// Emit an exit stub that the loop may be patched to jump to (for example if we
// want to terminate the loop because a timeout fires).
asm_exit(ins);
// Emit the patchable jump itself.
JMP_long(0);
loopJumps.add(_nIns);
guard->jmpToStub = _nIns;
// If the target we are looping to is in a different fragment, we have to restore
// SP since we will target fragEntry and not loopEntry.
if (exit->target != _thisfrag)
if (ins->record()->exit->target != _thisfrag)
MR(SP,FP);
}