Bug 919118 - Convert Float before conversion to Int32. r=sstangl, a=lsblakk
authorBenjamin Bouvier <bbouvier@mozilla.com>
Tue, 24 Sep 2013 14:08:32 -0700
changeset 160494 3234e28582d36846cdd312e31d988160afd2b7c0
parent 160493 afd59cdec0d13eb03f2b8359e38855dff2f22c9f
child 160495 9a3d4289913d96b10201f634f7054c441dac91f0
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl, lsblakk
bugs919118
milestone26.0a2
Bug 919118 - Convert Float before conversion to Int32. r=sstangl, a=lsblakk
js/src/jit-test/tests/ion/bug919118.js
js/src/jit/MIR.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug919118.js
@@ -0,0 +1,13 @@
+setJitCompilerOption("ion.usecount.trigger", 50);
+
+var f32 = new Float32Array(1);
+f32[0] = 13;
+var str = "CAN HAS cheezburger? OKTHXBYE";
+var c;
+
+function f() {
+    c = str[ f32[0] ];
+}
+
+for(var n = 100; n; --n) f();
+print (c);
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -2776,17 +2776,19 @@ class MAsmJSUnsignedToDouble
     AliasSet getAliasSet() const {
         return AliasSet::None();
     }
 };
 
 // Converts a primitive (either typed or untyped) to an int32. If the input is
 // not primitive at runtime, a bailout occurs. If the input cannot be converted
 // to an int32 without loss (i.e. "5.5" or undefined) then a bailout occurs.
-class MToInt32 : public MUnaryInstruction
+class MToInt32
+  : public MUnaryInstruction,
+    public NoFloatPolicy<0>
 {
     bool canBeNegativeZero_;
 
     MToInt32(MDefinition *def)
       : MUnaryInstruction(def),
         canBeNegativeZero_(true)
     {
         setResultType(MIRType_Int32);
@@ -2815,16 +2817,20 @@ class MToInt32 : public MUnaryInstructio
     bool congruentTo(MDefinition *ins) const {
         return congruentIfOperandsEqual(ins);
     }
 
     AliasSet getAliasSet() const {
         return AliasSet::None();
     }
     void computeRange();
+
+    TypePolicy *typePolicy() {
+        return this;
+    }
 };
 
 // Converts a value or typed input to a truncated int32, for use with bitwise
 // operations. This is an infallible ValueToECMAInt32.
 class MTruncateToInt32 : public MUnaryInstruction
 {
     MTruncateToInt32(MDefinition *def)
       : MUnaryInstruction(def)