diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 433634cdb0c..2ab3ecb93e6 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -2856,6 +2856,11 @@ TraceRecorder::cmp(LOpcode op, int flags) ABORT_TRACE("unsupported operand types for cmp"); } + if (flags & CMP_CASE) { + guard(cond, x, BRANCH_EXIT); + return true; + } + /* The interpreter fuses comparisons and the following branch, so we have to do that here as well. */ if (flags & CMP_TRY_BRANCH_AFTER_COND) @@ -2886,12 +2891,15 @@ TraceRecorder::equal(int flags) if (!negate) x = lir->ins_eq0(x); + if (flags & CMP_CASE) { + guard(cond, x, BRANCH_EXIT); + return true; + } + /* The interpreter fuses comparisons and the following branch, so we have to do that here as well. */ - if (CMP_TRY_BRANCH_AFTER_COND) { - if (cx->fp->regs->pc[1] == JSOP_IFEQ || cx->fp->regs->pc[1] == JSOP_IFNE) - guard(cond, x, BRANCH_EXIT); - } + if (flags & CMP_TRY_BRANCH_AFTER_COND) + fuseIf(cx->fp->regs->pc + 1, cond, x); /* We update the stack after the guard. This is safe since the guard bails out at the comparison and the interpreter @@ -2907,12 +2915,15 @@ TraceRecorder::equal(int flags) if (negate) x = lir->ins_eq0(x); + if (flags & CMP_CASE) { + guard(cond, x, BRANCH_EXIT); + return true; + } + /* The interpreter fuses comparisons and the following branch, so we have to do that here as well. */ - if (CMP_TRY_BRANCH_AFTER_COND) { - if (cx->fp->regs->pc[1] == JSOP_IFEQ || cx->fp->regs->pc[1] == JSOP_IFNE) - guard(cond, x, BRANCH_EXIT); - } + if (flags & CMP_TRY_BRANCH_AFTER_COND) + fuseIf(cx->fp->regs->pc + 1, cond, x); /* We update the stack after the guard. This is safe since the guard bails out at the comparison and the interpreter @@ -5245,11 +5256,7 @@ TraceRecorder::record_JSOP_CONDSWITCH() bool TraceRecorder::record_JSOP_CASE() { -#if 0 - return equal() && ifop(); -#else - return false; -#endif + return equal(CMP_CASE); } bool @@ -5432,7 +5439,7 @@ TraceRecorder::record_JSOP_GOSUBX() bool TraceRecorder::record_JSOP_CASEX() { - return equal() && ifop(); + return equal(CMP_CASE); } bool diff --git a/js/src/jstracer.h b/js/src/jstracer.h index 303ded9817b..3ff4fb5f23a 100644 --- a/js/src/jstracer.h +++ b/js/src/jstracer.h @@ -279,7 +279,7 @@ class TraceRecorder { bool incElem(jsint incr, bool pre = true); bool incName(jsint incr, bool pre = true); - enum { CMP_NEGATE = 1, CMP_TRY_BRANCH_AFTER_COND = 2 }; + enum { CMP_NEGATE = 1, CMP_TRY_BRANCH_AFTER_COND = 2, CMP_CASE = 4 }; bool cmp(nanojit::LOpcode op, int flags = 0); bool equal(int flags = 0);