Bug 919118: Convert Float before conversion to Int32; r=sstangl
authorBenjamin Bouvier <bbouvier@mozilla.com>
Tue, 24 Sep 2013 14:08:32 -0700
changeset 162310 94c5919f12c179716f06c2c80f23256118f49347
parent 162309 7588ab535671ada2874b95a3a17a5f6f43579ade
child 162311 9b543adac3cd7980978942a67c0a7d9002d28231
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs919118
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 919118: Convert Float before conversion to Int32; r=sstangl
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
@@ -2844,17 +2844,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);
@@ -2883,16 +2885,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)