Bug 937697 - Simplify some BoundsCheckRange code. r=bhackett, a=abillings
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 24 Dec 2013 13:51:26 +0100
changeset 175481 fea79cd5d6ee0c86cd42a07fa7b71ab452d94de6
parent 175480 db7f78ab45627d3c27f7acf7a28eee38aa10ad29
child 175482 a42fe878d29bb72a5b1f202fe1b83920f599e976
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett, abillings
bugs937697
milestone28.0a2
Bug 937697 - Simplify some BoundsCheckRange code. r=bhackett, a=abillings
js/src/jit/CodeGenerator.cpp
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -4894,26 +4894,29 @@ CodeGenerator::visitBoundsCheckRange(LBo
     // If the minimum and maximum differ then do an underflow check first.
     // If the two are the same then doing an unsigned comparison on the
     // length will also catch a negative index.
     if (min != max) {
         if (min != 0) {
             masm.add32(Imm32(min), temp);
             if (!bailoutIf(Assembler::Overflow, lir->snapshot()))
                 return false;
+        }
+
+        masm.cmp32(temp, Imm32(0));
+        if (!bailoutIf(Assembler::LessThan, lir->snapshot()))
+            return false;
+
+        if (min != 0) {
             int32_t diff;
             if (SafeSub(max, min, &diff))
                 max = diff;
             else
                 masm.sub32(Imm32(min), temp);
         }
-
-        masm.cmp32(temp, Imm32(0));
-        if (!bailoutIf(Assembler::LessThan, lir->snapshot()))
-            return false;
     }
 
     // Compute the maximum possible index. No overflow check is needed when
     // max > 0. We can only wraparound to a negative number, which will test as
     // larger than all nonnegative numbers in the unsigned comparison, and the
     // length is required to be nonnegative (else testing a negative length
     // would succeed on any nonnegative index).
     if (max != 0) {