Bug 502788: avoid many redundant NULL comparisons in the LirReader pipeline. r=edwsmith.

This commit is contained in:
Nicholas Nethercote 2009-07-09 08:34:22 +10:00
parent d9e1f3aa40
commit ae95b81b57
2 changed files with 11 additions and 15 deletions

View File

@ -66,6 +66,7 @@ namespace nanojit
op == LIR_loop ||
op == LIR_label ||
op == LIR_live ||
op == LIR_start ||
ins->isRet()) {
return false;
}
@ -77,7 +78,7 @@ namespace nanojit
LInsp read() {
for (;;) {
LInsp i = in->read();
if (!i || i->isGuard() || i->isBranch()
if (i->isGuard() || i->isBranch()
|| (i->isCall() && !i->isCse())
|| !ignoreInstruction(i))
return i;
@ -115,7 +116,7 @@ namespace nanojit
LInsp read() {
LInsp i = in->read();
if (!i) {
if (i->isop(LIR_start)) {
flush();
return i;
}
@ -181,8 +182,6 @@ namespace nanojit
LInsp read()
{
LInsp i = in->read();
if (!i)
return i;
const char* str = _names->formatIns(i);
char* cpy = (char*)_gc->Alloc(strlen(str) + 1, 0/*AllocFlags*/);
strcpy(cpy, str);
@ -1128,7 +1127,7 @@ namespace nanojit
reader->pos()->isop(LIR_ret) ||
reader->pos()->isop(LIR_xtbl));
for (LInsp ins = reader->read(); ins != 0 && !error(); ins = reader->read())
for (LInsp ins = reader->read(); !ins->isop(LIR_start) && !error(); ins = reader->read())
{
LOpcode op = ins->opcode();
switch(op)

View File

@ -349,9 +349,8 @@ namespace nanojit
// Reads the next non-skip instruction.
LInsp LirReader::read()
{
NanoAssert(_i);
LInsp cur = _i;
if (!cur)
return 0;
uintptr_t i = uintptr_t(cur);
LOpcode iop = ((LInsp)i)->opcode();
@ -398,7 +397,9 @@ namespace nanojit
break;
case LIR_start:
_i = 0; // this means the next call to this method will return 0
// Once we hit here, this method shouldn't be called again.
// The assertion at the top of this method checks this.
_i = 0;
return cur;
}
iop = ((LInsp)i)->opcode();
@ -1028,8 +1029,6 @@ namespace nanojit
for (;;)
{
LInsp i = in->read();
if (!i)
return i;
if (i->isStore())
{
LInsp base = i->oprnd2();
@ -1502,7 +1501,7 @@ namespace nanojit
int total = 0;
if (frag->lirbuf->state)
live.add(frag->lirbuf->state, r.pos());
for (LInsp i = r.read(); i != 0; i = r.read())
for (LInsp i = r.read(); !i->isop(LIR_start); i = r.read())
{
total++;
@ -1961,10 +1960,8 @@ namespace nanojit
LInsp CseReader::read()
{
LInsp i = in->read();
if (i) {
if (i->isCse())
exprs->replace(i);
}
if (i->isCse())
exprs->replace(i);
return i;
}