Bug 966926 - Force ToString not to have Float32 inputs. r=h4writer, a=sledru
authorBenjamin Bouvier <benj@benj.me>
Mon, 03 Feb 2014 18:22:40 +0100
changeset 182745 4e675e7857d82e7e2eb03c627dcca5c971426beb
parent 182744 8ed340f0f8cec2c9a9c1e13bf50bf7905d0e6ac4
child 182746 dd51a2464396d1de5c730cb810456d52f5b08c8c
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer, sledru
bugs966926
milestone29.0a2
Bug 966926 - Force ToString not to have Float32 inputs. r=h4writer, a=sledru
js/src/jit-test/tests/ion/bug966926.js
js/src/jit/TypePolicy.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug966926.js
@@ -0,0 +1,12 @@
+var f32 = new Float32Array(32);
+function f(n) {
+    var x;
+    if (n > 10000) {
+        x = (0);
+    } else {
+        x = f32[0];
+    }
+    g('' + (x));
+}
+function g(y){}
+f(0);
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -10,16 +10,27 @@
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 
 using namespace js;
 using namespace js::jit;
 
 using JS::DoubleNaNValue;
 
+static void
+EnsureOperandNotFloat32(TempAllocator &alloc, MInstruction *def, unsigned op)
+{
+    MDefinition *in = def->getOperand(op);
+    if (in->type() == MIRType_Float32) {
+        MToDouble *replace = MToDouble::New(alloc, in);
+        def->block()->insertBefore(def, replace);
+        def->replaceOperand(op, replace);
+    }
+}
+
 MDefinition *
 BoxInputsPolicy::boxAt(TempAllocator &alloc, MInstruction *at, MDefinition *operand)
 {
     if (operand->isUnbox())
         return operand->toUnbox()->input();
     return alwaysBoxAt(alloc, at, operand);
 }
 
@@ -404,16 +415,19 @@ ConvertToStringPolicy<Op>::staticAdjustI
 
     MInstruction *replace;
     if (in->mightBeType(MIRType_Object)) {
         if (in->type() != MIRType_Value)
             in = boxAt(alloc, ins, in);
 
         replace = MUnbox::New(alloc, in, MIRType_String, MUnbox::Fallible);
     } else {
+        // TODO remove these two lines once 966957 has landed
+        EnsureOperandNotFloat32(alloc, ins, Op);
+        in = ins->getOperand(Op);
         replace = MToString::New(alloc, in);
     }
 
     ins->block()->insertBefore(ins, replace);
     ins->replaceOperand(Op, replace);
     return true;
 }
 
@@ -517,27 +531,16 @@ Float32Policy<Op>::staticAdjustInputs(Te
     def->replaceOperand(Op, replace);
     return true;
 }
 
 template bool Float32Policy<0>::staticAdjustInputs(TempAllocator &alloc, MInstruction *def);
 template bool Float32Policy<1>::staticAdjustInputs(TempAllocator &alloc, MInstruction *def);
 template bool Float32Policy<2>::staticAdjustInputs(TempAllocator &alloc, MInstruction *def);
 
-static void
-EnsureOperandNotFloat32(TempAllocator &alloc, MInstruction *def, unsigned op)
-{
-    MDefinition *in = def->getOperand(op);
-    if (in->type() == MIRType_Float32) {
-        MToDouble *replace = MToDouble::New(alloc, in);
-        def->block()->insertBefore(def, replace);
-        def->replaceOperand(op, replace);
-    }
-}
-
 template <unsigned Op>
 bool
 NoFloatPolicy<Op>::staticAdjustInputs(TempAllocator &alloc, MInstruction *def)
 {
     EnsureOperandNotFloat32(alloc, def, Op);
     return true;
 }