[INFER] Don't mark the entry register allocation for a loop as needing updating until it has actually been computed, bug 680809.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 21 Aug 2011 20:23:30 -0700
changeset 76141 d7217d210771b2095930bb42291d2e4bff7dea89
parent 76140 194a7ad3ecd2e8c6381ad2de511a018210730df4
child 76142 c685e6d1774517f396fe5b35646bddbf7f5815a9
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs680809
milestone9.0a1
[INFER] Don't mark the entry register allocation for a loop as needing updating until it has actually been computed, bug 680809.
js/src/jit-test/tests/jaeger/loops/bug680809.js
js/src/methodjit/Compiler.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/jaeger/loops/bug680809.js
@@ -0,0 +1,8 @@
+function f0(p0) {
+    var v0;
+    v0 = 1.7;
+    loop0: while (v0) {
+        v0 = p0;
+    }
+}
+f0(0);
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -1450,19 +1450,16 @@ mjit::Compiler::generateMethod()
                 break;
             if (js_CodeSpec[op].length != -1)
                 PC += js_CodeSpec[op].length;
             else
                 PC += js_GetVariableBytecodeLength(PC);
             continue;
         }
 
-        if (loop && !a->parent)
-            loop->setOuterPC(PC);
-
         frame.setPC(PC);
         frame.setInTryBlock(opinfo->inTryBlock);
 
         if (fallthrough) {
             /*
              * If there is fallthrough from the previous opcode and we changed
              * any entries into doubles for a branch at that previous op,
              * revert those entries into integers. Maintain an invariant that
@@ -1515,16 +1512,22 @@ mjit::Compiler::generateMethod()
             if (!cx->typeInferenceEnabled()) {
                 /* All join points have synced state if we aren't doing cross-branch regalloc. */
                 opinfo->safePoint = true;
             }
         }
         frame.assertValidRegisterState();
         a->jumpMap[uint32(PC - script->code)] = masm.label();
 
+        // Now that we have the PC's register allocation, make sure it gets
+        // explicitly updated if this is the loop entry and new loop registers
+        // are allocated later on.
+        if (loop && !a->parent)
+            loop->setOuterPC(PC);
+
         SPEW_OPCODE();
         JS_ASSERT(frame.stackDepth() == opinfo->stackDepth);
 
         // If this is an exception entry point, then jsl_InternalThrow has set
         // VMFrame::fp to the correct fp for the entry point. We need to copy
         // that value here to FpReg so that FpReg also has the correct sp.
         // Otherwise, we would simply be using a stale FpReg value.
         if (op == JSOP_ENTERBLOCK && analysis->getCode(PC).exceptionEntry)