Bug 878505 - OdinMonkey: store to float array should accept doublish (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Mon, 10 Jun 2013 16:37:18 -0700
changeset 134583 1eff67ffe6b978c59bed371c0e3df7eb81bf8560
parent 134582 841ffd181e14667ea9a272ba169429db688caa8e
child 134584 5eb3a09775c956901898600fd5c3ebba9b68ce86
push id29283
push userlwagner@mozilla.com
push dateMon, 10 Jun 2013 23:42:33 +0000
treeherdermozilla-inbound@1eff67ffe6b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs878505
milestone24.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 878505 - OdinMonkey: store to float array should accept doublish (r=bbouvier)
js/src/ion/AsmJS.cpp
js/src/jit-test/tests/asm.js/testHeapAccess.js
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -833,37 +833,37 @@ TypedArrayLoadType(ArrayBufferView::View
       default:;
     }
     JS_NOT_REACHED("Unexpected array type");
     return Type();
 }
 
 enum ArrayStoreEnum {
     ArrayStore_Intish,
-    ArrayStore_Double
+    ArrayStore_Doublish
 };
 
 static ArrayStoreEnum
 TypedArrayStoreType(ArrayBufferView::ViewType viewType)
 {
     switch (viewType) {
       case ArrayBufferView::TYPE_INT8:
       case ArrayBufferView::TYPE_INT16:
       case ArrayBufferView::TYPE_INT32:
       case ArrayBufferView::TYPE_UINT8:
       case ArrayBufferView::TYPE_UINT16:
       case ArrayBufferView::TYPE_UINT32:
         return ArrayStore_Intish;
       case ArrayBufferView::TYPE_FLOAT32:
       case ArrayBufferView::TYPE_FLOAT64:
-        return ArrayStore_Double;
+        return ArrayStore_Doublish;
       default:;
     }
     JS_NOT_REACHED("Unexpected array type");
-    return ArrayStore_Double;
+    return ArrayStore_Doublish;
 }
 
 /*****************************************************************************/
 
 typedef Vector<PropertyName*,1> LabelVector;
 typedef Vector<MBasicBlock*,8> BlockVector;
 
 // ModuleCompiler encapsulates the compilation of an entire asm.js module. Over
@@ -3244,19 +3244,19 @@ CheckStoreArray(FunctionCompiler &f, Par
     if (!CheckExpr(f, rhs, Use::NoCoercion, &rhsDef, &rhsType))
         return false;
 
     switch (TypedArrayStoreType(viewType)) {
       case ArrayStore_Intish:
         if (!rhsType.isIntish())
             return f.failf(lhs, "%s is not a subtype of intish", rhsType.toChars());
         break;
-      case ArrayStore_Double:
-        if (rhsType != Type::Double)
-            return f.failf(lhs, "%s is not double", rhsType.toChars());
+      case ArrayStore_Doublish:
+        if (!rhsType.isDoublish())
+            return f.failf(lhs, "%s is not a subtype of doublish", rhsType.toChars());
         break;
     }
 
     f.storeHeap(viewType, pointerDef, rhsDef);
 
     *def = rhsDef;
     *type = rhsType;
     return true;
--- a/js/src/jit-test/tests/asm.js/testHeapAccess.js
+++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js
@@ -89,16 +89,26 @@ assertEq(f(4088, 2.5), 2);
 assertEq(f(4096, 3.8), 0);
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return +f64[i>>3]}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0, 1.3), 1.3);
 assertEq(f(4088, 2.5), 2.5);
 assertEq(f(4096, 3.8), NaN);
 
+var i32 = new Int32Array(4096);
+i32[0] = 42;
+asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = i32[0] }; return f'), this, null, i32.buffer)();
+assertEq(i32[1], 42);
+
+var f64 = new Float64Array(4096);
+f64[0] = 42;
+asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = f64[0] }; return f'), this, null, f64.buffer)();
+assertEq(f64[1], 42);
+
 var i32 = new Int32Array(4096/4);
 i32[0] = 13;
 i32[1] = 0xfffeeee;
 var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+1)>>2]|0 }; return f'), this, null, i32.buffer);
 assertEq(f(0), 13);
 assertEq(f(1), 0xfffeeee);
 var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+2)>>2]|0 }; return f'), this, null, i32.buffer);
 assertEq(f(0), 13);