[INFER] Fix broken test for loop invariant slots, bug 655854.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 09 May 2011 20:21:34 -0700
changeset 75018 d1724a9944bd0454772837e72ed938fab739195e
parent 75014 32e8c937a40944a7c2666dd07839e304d9075eb2
child 75019 2b272d7fb2e5eacb99e1752ed84743fc6d4c439d
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs655854
milestone6.0a1
[INFER] Fix broken test for loop invariant slots, bug 655854.
js/src/jit-test/tests/jaeger/loops/bug655854.js
js/src/methodjit/LoopState.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/jaeger/loops/bug655854.js
@@ -0,0 +1,8 @@
+
+function foo(a, b, c) {
+  var res = 0;
+  for (var b = 0; b < c; b++)
+    res += a[b];
+  return res;
+}
+assertEq(foo([1,2,3], 0, 10), NaN);
--- a/js/src/methodjit/LoopState.cpp
+++ b/js/src/methodjit/LoopState.cpp
@@ -284,17 +284,17 @@ LoopState::clearLoopRegisters()
 
 bool
 LoopState::loopInvariantEntry(uint32 slot)
 {
     if (slot == UNASSIGNED)
         return true;
 
     /* Watch for loop temporaries. :XXX: this is really gross. */
-    if (slot - analyze::LocalSlot(outerScript, 0) >= outerScript->nslots)
+    if (slot >= analyze::LocalSlot(outerScript, outerScript->nslots))
         return true;
 
     if (slot == analyze::CalleeSlot() || outerAnalysis->slotEscapes(slot))
         return false;
     return outerAnalysis->liveness(slot).firstWrite(lifetime) == uint32(-1);
 }
 
 inline bool