Bug 925305 - Use ScratchFloatReg when converting float32->double for callVM. (r=sstangl)
authorShu-yu Guo <shu@rfrn.org>
Thu, 10 Oct 2013 20:02:30 -0700
changeset 150422 f422b59826c1767d44b52f9467c18b5561f8cfe5
parent 150421 d64b073e736edd1a59c96ec096f58f69ae15710b
child 150423 76832c8a9c3730830e57fa439d2f330375bfe779
push id2993
push usercbook@mozilla.com
push dateFri, 11 Oct 2013 09:22:00 +0000
treeherderfx-team@fe160ec1e0ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs925305
milestone27.0a1
Bug 925305 - Use ScratchFloatReg when converting float32->double for callVM. (r=sstangl)
js/src/jit-test/tests/ion/bug925305.js
js/src/jit/IonMacroAssembler.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug925305.js
@@ -0,0 +1,14 @@
+function testFloat32SetElemIC(a) {
+  for (var i = 0; i < a.length; i++) {
+    var r = Math.fround(Math.random());
+    a[i] = r;
+    assertEq(a[i], r);
+  }
+}
+
+testFloat32SetElemIC(new Array(2048));
+testFloat32SetElemIC(new Array(2048));
+
+enableOsiPointRegisterChecks();
+testFloat32SetElemIC(new Array(2048));
+testFloat32SetElemIC(new Float64Array(2048));
--- a/js/src/jit/IonMacroAssembler.h
+++ b/js/src/jit/IonMacroAssembler.h
@@ -402,18 +402,20 @@ class MacroAssembler : public MacroAssem
     }
 
     template <typename T>
     void storeTypedOrValue(TypedOrValueRegister src, const T &dest) {
         if (src.hasValue()) {
             storeValue(src.valueReg(), dest);
         } else if (IsFloatingPointType(src.type())) {
             FloatRegister reg = src.typedReg().fpu();
-            if (src.type() == MIRType_Float32)
-                convertFloatToDouble(reg, reg);
+            if (src.type() == MIRType_Float32) {
+                convertFloatToDouble(reg, ScratchFloatReg);
+                reg = ScratchFloatReg;
+            }
             storeDouble(reg, dest);
         } else {
             storeValue(ValueTypeFromMIRType(src.type()), src.typedReg().gpr(), dest);
         }
     }
 
     template <typename T>
     void storeConstantOrRegister(ConstantOrRegister src, const T &dest) {
@@ -548,18 +550,20 @@ class MacroAssembler : public MacroAssem
         }
     }
 
     void Push(TypedOrValueRegister v) {
         if (v.hasValue()) {
             Push(v.valueReg());
         } else if (IsFloatingPointType(v.type())) {
             FloatRegister reg = v.typedReg().fpu();
-            if (v.type() == MIRType_Float32)
-                convertFloatToDouble(reg, reg);
+            if (v.type() == MIRType_Float32) {
+                convertFloatToDouble(reg, ScratchFloatReg);
+                reg = ScratchFloatReg;
+            }
             Push(reg);
         } else {
             Push(ValueTypeFromMIRType(v.type()), v.typedReg().gpr());
         }
     }
 
     void Push(ConstantOrRegister v) {
         if (v.constant())