Bug 1256633 - Reject wasm i64 ops on platforms that don't support them yet. r=bbouvier
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 16 Mar 2016 09:32:25 +0100
changeset 288927 0ad528e4b17dfdd13e5b6490be176f7437555705
parent 288926 4a416720bfb3075cb6af708b129bf9eb711a9e12
child 288928 2a6f90eef68eba0ac664628d74115b0c44568804
push id73622
push userjandemooij@gmail.com
push dateWed, 16 Mar 2016 08:43:11 +0000
treeherdermozilla-inbound@2a6f90eef68e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1256633
milestone48.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 1256633 - Reject wasm i64 ops on platforms that don't support them yet. r=bbouvier
js/src/asmjs/Wasm.cpp
js/src/jit-test/tests/wasm/basic.js
--- a/js/src/asmjs/Wasm.cpp
+++ b/js/src/asmjs/Wasm.cpp
@@ -102,16 +102,23 @@ class FunctionDecoder
     FunctionGenerator& fg() const { return fg_; }
     uint32_t funcIndex() const { return funcIndex_; }
     const ValTypeVector& locals() const { return locals_; }
     const DeclaredSig& sig() const { return mg_.funcSig(funcIndex_); }
 
     bool fail(const char* str) {
         return Fail(cx_, d_, str);
     }
+    bool checkI64Support() {
+#ifdef JS_CPU_X64
+        return true;
+#else
+        return fail("i64 NYI on this platform");
+#endif
+    }
 
     MOZ_WARN_UNUSED_RESULT bool pushBlock() {
         return blocks_.append(AnyType);
     }
     ExprType popBlock() {
         return blocks_.popCopy();
     }
     MOZ_WARN_UNUSED_RESULT bool branchWithType(uint32_t depth, ExprType type) {
@@ -622,17 +629,17 @@ DecodeExpr(FunctionDecoder& f, ExprType*
         return DecodeCall(f, type);
       case Expr::CallImport:
         return DecodeCallImport(f, type);
       case Expr::CallIndirect:
         return DecodeCallIndirect(f, type);
       case Expr::I32Const:
         return DecodeConstI32(f, type);
       case Expr::I64Const:
-        return DecodeConstI64(f, type);
+        return f.checkI64Support() && DecodeConstI64(f, type);
       case Expr::F32Const:
         return DecodeConstF32(f, type);
       case Expr::F64Const:
         return DecodeConstF64(f, type);
       case Expr::GetLocal:
         return DecodeGetLocal(f, type);
       case Expr::SetLocal:
         return DecodeSetLocal(f, type);
@@ -700,17 +707,17 @@ DecodeExpr(FunctionDecoder& f, ExprType*
       case Expr::I64RemS:
       case Expr::I64RemU:
       case Expr::I64And:
       case Expr::I64Or:
       case Expr::I64Xor:
       case Expr::I64Shl:
       case Expr::I64ShrS:
       case Expr::I64ShrU:
-        return DecodeBinaryOperator(f, ValType::I64, type);
+        return f.checkI64Support() && DecodeBinaryOperator(f, ValType::I64, type);
       case Expr::I64Rotl:
       case Expr::I64Rotr:
         return f.fail("NYI: rotate");
       case Expr::F32Add:
       case Expr::F32Sub:
       case Expr::F32Mul:
       case Expr::F32Div:
       case Expr::F32Min:
@@ -743,68 +750,74 @@ DecodeExpr(FunctionDecoder& f, ExprType*
       case Expr::I64LtS:
       case Expr::I64LtU:
       case Expr::I64LeS:
       case Expr::I64LeU:
       case Expr::I64GtS:
       case Expr::I64GtU:
       case Expr::I64GeS:
       case Expr::I64GeU:
-        return DecodeComparisonOperator(f, ValType::I64, type);
+        return f.checkI64Support() && DecodeComparisonOperator(f, ValType::I64, type);
       case Expr::F32Eq:
       case Expr::F32Ne:
       case Expr::F32Lt:
       case Expr::F32Le:
       case Expr::F32Gt:
       case Expr::F32Ge:
         return DecodeComparisonOperator(f, ValType::F32, type);
       case Expr::F64Eq:
       case Expr::F64Ne:
       case Expr::F64Lt:
       case Expr::F64Le:
       case Expr::F64Gt:
       case Expr::F64Ge:
         return DecodeComparisonOperator(f, ValType::F64, type);
       case Expr::I32WrapI64:
-        return DecodeConversionOperator(f, ValType::I32, ValType::I64, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::I32, ValType::I64, type);
       case Expr::I32TruncSF32:
       case Expr::I32TruncUF32:
         return DecodeConversionOperator(f, ValType::I32, ValType::F32, type);
       case Expr::I32ReinterpretF32:
         return f.fail("NYI: reinterpret");
       case Expr::I32TruncSF64:
       case Expr::I32TruncUF64:
         return DecodeConversionOperator(f, ValType::I32, ValType::F64, type);
       case Expr::I64ExtendSI32:
       case Expr::I64ExtendUI32:
-        return DecodeConversionOperator(f, ValType::I64, ValType::I32, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::I64, ValType::I32, type);
       case Expr::I64TruncSF32:
       case Expr::I64TruncUF32:
-        return DecodeConversionOperator(f, ValType::I64, ValType::F32, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::I64, ValType::F32, type);
       case Expr::I64TruncSF64:
       case Expr::I64TruncUF64:
-        return DecodeConversionOperator(f, ValType::I64, ValType::F64, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::I64, ValType::F64, type);
       case Expr::I64ReinterpretF64:
         return f.fail("NYI: i64");
       case Expr::F32ConvertSI32:
       case Expr::F32ConvertUI32:
         return DecodeConversionOperator(f, ValType::F32, ValType::I32, type);
       case Expr::F32ReinterpretI32:
         return f.fail("NYI: reinterpret");
       case Expr::F32ConvertSI64:
       case Expr::F32ConvertUI64:
-        return DecodeConversionOperator(f, ValType::F32, ValType::I64, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::F32, ValType::I64, type);
       case Expr::F32DemoteF64:
         return DecodeConversionOperator(f, ValType::F32, ValType::F64, type);
       case Expr::F64ConvertSI32:
       case Expr::F64ConvertUI32:
         return DecodeConversionOperator(f, ValType::F64, ValType::I32, type);
       case Expr::F64ConvertSI64:
       case Expr::F64ConvertUI64:
-        return DecodeConversionOperator(f, ValType::F64, ValType::I64, type);
+        return f.checkI64Support() &&
+               DecodeConversionOperator(f, ValType::F64, ValType::I64, type);
       case Expr::F64ReinterpretI64:
         return f.fail("NYI: i64");
       case Expr::F64PromoteF32:
         return DecodeConversionOperator(f, ValType::F64, ValType::F32, type);
       case Expr::I32Load8S:
       case Expr::I32Load8U:
         return DecodeLoad(f, 1, ValType::I32, type);
       case Expr::I32Load16S:
--- a/js/src/jit-test/tests/wasm/basic.js
+++ b/js/src/jit-test/tests/wasm/basic.js
@@ -86,16 +86,17 @@ wasmEvalText('(module (func (param i32) 
 wasmEvalText('(module (func (result i32) (param i32) (i32.const 42)))');
 wasmEvalText('(module (func (param f32)))');
 wasmEvalText('(module (func (param f64)))');
 
 var hasI64 = getBuildConfiguration().x64;
 if (!hasI64) {
     assertErrorMessage(() => wasmEvalText('(module (func (param i64)))'), TypeError, /NYI/);
     assertErrorMessage(() => wasmEvalText('(module (func (result i64)))'), TypeError, /NYI/);
+    assertErrorMessage(() => wasmEvalText('(module (func (result i32) (i32.wrap/i64 (i64.add (i64.const 1) (i64.const 2)))))'), TypeError, /NYI/);
 }
 
 // ----------------------------------------------------------------------------
 // imports
 
 assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', 1), Error, /second argument, if present, must be an object/);
 assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', null), Error, /second argument, if present, must be an object/);