diff --git a/js/src/nanojit/Assembler.cpp b/js/src/nanojit/Assembler.cpp index 1533b371243..75e72e8de32 100644 --- a/js/src/nanojit/Assembler.cpp +++ b/js/src/nanojit/Assembler.cpp @@ -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) diff --git a/js/src/nanojit/LIR.cpp b/js/src/nanojit/LIR.cpp index 0be008a1dfe..94c4bc77ada 100644 --- a/js/src/nanojit/LIR.cpp +++ b/js/src/nanojit/LIR.cpp @@ -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; }