Bug 478314 - Eagerly call f2i to root out constant values. r=gal
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 13 Feb 2009 13:44:12 -0800
changeset 25107 ac35c12230fa3a662d3d13df2b16898819d4b0ea
parent 25106 b4ececb1c146198c415f30331febf05e04d6c6da
child 25108 11d992eeca40012363cd8c352c5668ffef187a80
push idunknown
push userunknown
push dateunknown
reviewersgal
bugs478314
milestone1.9.2a1pre
Bug 478314 - Eagerly call f2i to root out constant values. r=gal
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -5019,24 +5019,24 @@ TraceRecorder::ifop()
 #ifdef NANOJIT_IA32
 /* Record LIR for a tableswitch or tableswitchx op. We record LIR only
  * the "first" time we hit the op. Later, when we start traces after
  * exiting that trace, we just patch. */
 JS_REQUIRES_STACK LIns*
 TraceRecorder::tableswitch()
 {
     jsval& v = stackval(-1);
-    LIns* v_ins = get(&v);
+    if (!isNumber(v))
+        return NULL;
+
     /* no need to guard if condition is constant */
+    LIns* v_ins = f2i(get(&v));
     if (v_ins->isconst() || v_ins->isconstq())
         return NULL;
 
-    if (!isNumber(v))
-        return NULL;
-
     jsbytecode* pc = cx->fp->regs->pc;
     /* Starting a new trace after exiting a trace via switch. */
     if (anchor && (anchor->exitType == CASE_EXIT ||
                    anchor->exitType == DEFAULT_EXIT) && fragment->ip == pc)
         return NULL;
 
     /* Decode jsop. */
     jsint low, high;
@@ -5062,17 +5062,17 @@ TraceRecorder::tableswitch()
     }
 
     /* Generate switch LIR. */
     LIns* si_ins = lir_buf_writer->skip(sizeof(SwitchInfo));
     SwitchInfo* si = (SwitchInfo*) si_ins->payload();
     si->count = high + 1 - low;
     si->table = 0;
     si->index = (uint32) -1;
-    LIns* diff = lir->ins2(LIR_sub, f2i(v_ins), lir->insImm(low));
+    LIns* diff = lir->ins2(LIR_sub, v_ins, lir->insImm(low));
     LIns* cmp = lir->ins2(LIR_ult, diff, lir->insImm(si->count));
     lir->insGuard(LIR_xf, cmp, snapshot(DEFAULT_EXIT));
     lir->insStore(diff, lir->insImmPtr(&si->index), lir->insImm(0));
     LIns* exit = snapshot(CASE_EXIT);
     ((GuardRecord*) exit->payload())->exit->switchInfo = si;
     return lir->insGuard(LIR_xtbl, diff, exit);
 }
 #endif