FTL ArithMod Int32Use doesn't check for negative zero correctly
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 23:05:00 +0000 (23:05 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 23:05:00 +0000 (23:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120905

Reviewed by Mark Hahnenberg.

* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileArithMod):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155222 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

index 1928c9c..ce074e4 100644 (file)
@@ -1,5 +1,15 @@
 2013-09-06  Filip Pizlo  <fpizlo@apple.com>
 
 2013-09-06  Filip Pizlo  <fpizlo@apple.com>
 
+        FTL ArithMod Int32Use doesn't check for negative zero correctly
+        https://bugs.webkit.org/show_bug.cgi?id=120905
+
+        Reviewed by Mark Hahnenberg.
+
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileArithMod):
+
+2013-09-06  Filip Pizlo  <fpizlo@apple.com>
+
         FTL ArithNeg Int32Use doesn't check negative zero
         https://bugs.webkit.org/show_bug.cgi?id=120900
 
         FTL ArithNeg Int32Use doesn't check negative zero
         https://bugs.webkit.org/show_bug.cgi?id=120900
 
index eef51f2..7398764 100644 (file)
@@ -855,23 +855,26 @@ private:
             
             m_out.appendTo(continuation, done);
             
             
             m_out.appendTo(continuation, done);
             
+            LValue remainder = m_out.rem(numerator, denominator);
+            
             if (!nodeCanIgnoreNegativeZero(m_node->arithNodeFlags())) {
             if (!nodeCanIgnoreNegativeZero(m_node->arithNodeFlags())) {
-                LBasicBlock zeroNumerator = FTL_NEW_BLOCK(m_out, ("ArithMod zero numerator"));
+                LBasicBlock negativeNumerator = FTL_NEW_BLOCK(m_out, ("ArithMod negative numerator"));
                 LBasicBlock numeratorContinuation = FTL_NEW_BLOCK(m_out, ("ArithMod numerator continuation"));
                 
                 LBasicBlock numeratorContinuation = FTL_NEW_BLOCK(m_out, ("ArithMod numerator continuation"));
                 
-                m_out.branch(m_out.isZero32(numerator), zeroNumerator, numeratorContinuation);
+                m_out.branch(
+                    m_out.lessThan(numerator, m_out.int32Zero),
+                    negativeNumerator, numeratorContinuation);
                 
                 
-                LBasicBlock innerLastNext = m_out.appendTo(zeroNumerator, numeratorContinuation);
+                LBasicBlock innerLastNext = m_out.appendTo(negativeNumerator, numeratorContinuation);
                 
                 
-                speculate(
-                    NegativeZero, noValue(), 0, m_out.lessThan(denominator, m_out.int32Zero));
+                speculate(NegativeZero, noValue(), 0, m_out.isZero32(remainder));
                 
                 m_out.jump(numeratorContinuation);
                 
                 m_out.appendTo(numeratorContinuation, innerLastNext);
             }
             
                 
                 m_out.jump(numeratorContinuation);
                 
                 m_out.appendTo(numeratorContinuation, innerLastNext);
             }
             
-            results.append(m_out.anchor(m_out.rem(numerator, denominator)));
+            results.append(m_out.anchor(remainder));
             m_out.jump(done);
             
             m_out.appendTo(done, lastNext);
             m_out.jump(done);
             
             m_out.appendTo(done, lastNext);