Bug 1428971 - Control wasm sign extension opcodes by a dedicated define. r=bbouvier
authorLars T Hansen <lhansen@mozilla.com>
Tue, 09 Jan 2018 10:52:42 +0100
changeset 398380 73a05a0385481c6a69083f0f871625ce6a8712d4
parent 398379 83bfdce958e7de595edd901f1c60686127ca22e9
child 398381 dc271c111e3352f23b424f0a041432dac027ee78
push id98734
push userlhansen@mozilla.com
push dateTue, 09 Jan 2018 15:50:47 +0000
treeherdermozilla-inbound@73a05a038548 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1428971
milestone59.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 1428971 - Control wasm sign extension opcodes by a dedicated define. r=bbouvier These opcodes are useful by themselves and several people have already mooted the possibility of letting them ride the wasm train independently of the thread feature. So do not make them dependent on the threads ifdef, but give them their own.
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/wasm/conversion.js
js/src/moz.build
js/src/wasm/WasmBaselineCompile.cpp
js/src/wasm/WasmBinaryConstants.h
js/src/wasm/WasmBinaryIterator.cpp
js/src/wasm/WasmBinaryToAST.cpp
js/src/wasm/WasmBinaryToText.cpp
js/src/wasm/WasmIonCompile.cpp
js/src/wasm/WasmTextToBinary.cpp
js/src/wasm/WasmValidate.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -549,16 +549,29 @@ WasmThreadsSupported(JSContext* cx, unsi
 #else
     bool isSupported = false;
 #endif
     args.rval().setBoolean(isSupported);
     return true;
 }
 
 static bool
+WasmSignExtensionSupported(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
+    bool isSupported = true;
+#else
+    bool isSupported = false;
+#endif
+    args.rval().setBoolean(isSupported);
+    return true;
+}
+
+static bool
 WasmCompileMode(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // We default to ion if nothing is enabled, as does the Wasm compiler.
     JSString* result;
     if (!wasm::HasSupport(cx))
         result = JS_NewStringCopyZ(cx, "disabled");
@@ -5256,16 +5269,21 @@ gc::ZealModeHelpText),
 "  Returns a boolean indicating whether WebAssembly debugging is supported on the current device;\n"
 "  returns false also if WebAssembly is not supported"),
 
     JS_FN_HELP("wasmThreadsSupported", WasmThreadsSupported, 0, 0,
 "wasmThreadsSupported()",
 "  Returns a boolean indicating whether the WebAssembly threads proposal is\n"
 "  supported on the current device."),
 
+    JS_FN_HELP("wasmSignExtensionSupported", WasmSignExtensionSupported, 0, 0,
+"wasmSignExtensionSupported()",
+"  Returns a boolean indicating whether the WebAssembly sign extension opcodes are\n"
+"  supported on the current device."),
+
     JS_FN_HELP("wasmCompileMode", WasmCompileMode, 0, 0,
 "wasmCompileMode()",
 "  Returns a string indicating the available compile policy: 'baseline', 'ion',\n"
 "  'baseline-or-ion', or 'disabled' (if wasm is not available at all)."),
 
     JS_FN_HELP("wasmTextToBinary", WasmTextToBinary, 1, 0,
 "wasmTextToBinary(str)",
 "  Translates the given text wasm module into its binary encoding."),
--- a/js/src/jit-test/tests/wasm/conversion.js
+++ b/js/src/jit-test/tests/wasm/conversion.js
@@ -233,17 +233,17 @@ testTrap('i64', 'trunc_u', 'f32', 184467
 testTrap('i64', 'trunc_u', 'f32', -1);
 testTrap('i64', 'trunc_u', 'f32', "nan");
 testTrap('i64', 'trunc_u', 'f32', "infinity");
 testTrap('i64', 'trunc_u', 'f32', "-infinity");
 
 testConversion('i64', 'reinterpret', 'f64', 40.09999999999968, "0x40440ccccccccca0");
 testConversion('f64', 'reinterpret', 'i64', "0x40440ccccccccca0", 40.09999999999968);
 
-if (wasmThreadsSupported()) {
+if (wasmSignExtensionSupported()) {
     testSignExtension('i32', 'extend8_s', 'i32', 0x7F, 0x7F);
     testSignExtension('i32', 'extend8_s', 'i32', 0x80, -0x80);
     testSignExtension('i32', 'extend16_s', 'i32', 0x7FFF, 0x7FFF);
     testSignExtension('i32', 'extend16_s', 'i32', 0x8000, -0x8000);
     testSignExtension('i64', 'extend8_s', 'i64', 0x7F, 0x7F);
     testSignExtension('i64', 'extend8_s', 'i64', 0x80, -0x80);
     testSignExtension('i64', 'extend16_s', 'i64', 0x7FFF, 0x7FFF);
     testSignExtension('i64', 'extend16_s', 'i64', 0x8000, -0x8000);
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -635,16 +635,17 @@ DIRS += [
     'build',
 ]
 
 FINAL_LIBRARY = 'js'
 
 if CONFIG['NIGHTLY_BUILD']:
     DEFINES['ENABLE_BINARYDATA'] = True
     DEFINES['ENABLE_SIMD'] = True
+    DEFINES['ENABLE_WASM_SIGNEXTEND_OPS'] = True
     DEFINES['ENABLE_WASM_THREAD_OPS'] = True
 
 if CONFIG['JS_BUILD_BINAST']:
     # Using SOURCES as UNIFIED_SOURCES causes mysterious bugs on 32-bit platforms.
     # These parts of BinAST are designed only to test evolutions of the
     # specification.
     SOURCES += ['frontend/BinTokenReaderTester.cpp']
     # These parts of BinAST should eventually move to release.
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -8954,17 +8954,17 @@ BaseCompiler::emitBody()
           case uint16_t(Op::F64Le):
             CHECK_NEXT(emitComparison(emitCompareF64, ValType::F64, Assembler::DoubleLessThanOrEqual));
           case uint16_t(Op::F64Gt):
             CHECK_NEXT(emitComparison(emitCompareF64, ValType::F64, Assembler::DoubleGreaterThan));
           case uint16_t(Op::F64Ge):
             CHECK_NEXT(emitComparison(emitCompareF64, ValType::F64, Assembler::DoubleGreaterThanOrEqual));
 
           // Sign extensions
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
           case uint16_t(Op::I32Extend8S):
             CHECK_NEXT(emitConversion(emitExtendI32_8, ValType::I32, ValType::I32));
           case uint16_t(Op::I32Extend16S):
             CHECK_NEXT(emitConversion(emitExtendI32_16, ValType::I32, ValType::I32));
           case uint16_t(Op::I64Extend8S):
             CHECK_NEXT(emitConversion(emitExtendI64_8, ValType::I64, ValType::I64));
           case uint16_t(Op::I64Extend16S):
             CHECK_NEXT(emitConversion(emitExtendI64_16, ValType::I64, ValType::I64));
--- a/js/src/wasm/WasmBinaryConstants.h
+++ b/js/src/wasm/WasmBinaryConstants.h
@@ -309,17 +309,17 @@ enum class Op
     F64PromoteF32                        = 0xbb,
 
     // Reinterpretations
     I32ReinterpretF32                    = 0xbc,
     I64ReinterpretF64                    = 0xbd,
     F32ReinterpretI32                    = 0xbe,
     F64ReinterpretI64                    = 0xbf,
 
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
     // Sign extension
     I32Extend8S                          = 0xc0,
     I32Extend16S                         = 0xc1,
     I64Extend8S                          = 0xc2,
     I64Extend16S                         = 0xc3,
     I64Extend32S                         = 0xc4,
 #endif
 
--- a/js/src/wasm/WasmBinaryIterator.cpp
+++ b/js/src/wasm/WasmBinaryIterator.cpp
@@ -172,17 +172,17 @@ wasm::Classify(OpBytes op)
       case Op::F32ConvertUI64:
       case Op::F32DemoteF64:
       case Op::F64ConvertSI32:
       case Op::F64ConvertUI32:
       case Op::F64ConvertSI64:
       case Op::F64ConvertUI64:
       case Op::F64ReinterpretI64:
       case Op::F64PromoteF32:
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
       case Op::I32Extend8S:
       case Op::I32Extend16S:
       case Op::I64Extend8S:
       case Op::I64Extend16S:
       case Op::I64Extend32S:
 #endif
         return OpKind::Conversion;
       case Op::I32Load8S:
--- a/js/src/wasm/WasmBinaryToAST.cpp
+++ b/js/src/wasm/WasmBinaryToAST.cpp
@@ -1508,17 +1508,17 @@ AstDecodeExpr(AstDecodeContext& c)
       case uint16_t(Op::F64ReinterpretI64):
         if (!AstDecodeConversion(c, ValType::I64, ValType::F64, Op(op.b0)))
             return false;
         break;
       case uint16_t(Op::F64PromoteF32):
         if (!AstDecodeConversion(c, ValType::F32, ValType::F64, Op(op.b0)))
             return false;
         break;
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
       case uint16_t(Op::I32Extend8S):
       case uint16_t(Op::I32Extend16S):
         if (!AstDecodeConversion(c, ValType::I32, ValType::I32, Op(op.b0)))
             return false;
         break;
       case uint16_t(Op::I64Extend8S):
       case uint16_t(Op::I64Extend16S):
       case uint16_t(Op::I64Extend32S):
--- a/js/src/wasm/WasmBinaryToText.cpp
+++ b/js/src/wasm/WasmBinaryToText.cpp
@@ -731,17 +731,17 @@ RenderConversionOperator(WasmRenderConte
       case Op::F32ConvertUI64:    opStr = "f32.convert_u/i64"; break;
       case Op::F32DemoteF64:      opStr = "f32.demote/f64"; break;
       case Op::F64ConvertSI32:    opStr = "f64.convert_s/i32"; break;
       case Op::F64ConvertUI32:    opStr = "f64.convert_u/i32"; break;
       case Op::F64ConvertSI64:    opStr = "f64.convert_s/i64"; break;
       case Op::F64ConvertUI64:    opStr = "f64.convert_u/i64"; break;
       case Op::F64ReinterpretI64: opStr = "f64.reinterpret/i64"; break;
       case Op::F64PromoteF32:     opStr = "f64.promote/f32"; break;
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
       case Op::I32Extend8S:       opStr = "i32.extend8_s"; break;
       case Op::I32Extend16S:      opStr = "i32.extend16_s"; break;
       case Op::I64Extend8S:       opStr = "i64.extend8_s"; break;
       case Op::I64Extend16S:      opStr = "i64.extend16_s"; break;
       case Op::I64Extend32S:      opStr = "i64.extend32_s"; break;
 #endif
       case Op::I32Eqz:            opStr = "i32.eqz"; break;
       case Op::I64Eqz:            opStr = "i64.eqz"; break;
--- a/js/src/wasm/WasmIonCompile.cpp
+++ b/js/src/wasm/WasmIonCompile.cpp
@@ -2425,17 +2425,17 @@ EmitTruncate(FunctionCompiler& f, ValTyp
     } else {
         MOZ_ASSERT(resultType == ValType::I64);
         MOZ_ASSERT(!f.env().isAsmJS());
         f.iter().setResult(f.truncate<MWasmTruncateToInt64>(input, isUnsigned));
     }
     return true;
 }
 
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
 static bool
 EmitSignExtend(FunctionCompiler& f, uint32_t srcSize, uint32_t targetSize)
 {
     MDefinition* input;
     ValType type = targetSize == 4 ? ValType::I32 : ValType::I64;
     if (!f.iter().readConversion(type, type, &input))
         return false;
 
@@ -3960,17 +3960,17 @@ EmitBodyExprs(FunctionCompiler& f)
           case uint16_t(Op::I64ReinterpretF64):
             CHECK(EmitReinterpret(f, ValType::I64, ValType::F64, MIRType::Int64));
           case uint16_t(Op::F32ReinterpretI32):
             CHECK(EmitReinterpret(f, ValType::F32, ValType::I32, MIRType::Float32));
           case uint16_t(Op::F64ReinterpretI64):
             CHECK(EmitReinterpret(f, ValType::F64, ValType::I64, MIRType::Double));
 
           // Sign extensions
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
           case uint16_t(Op::I32Extend8S):
             CHECK(EmitSignExtend(f, 1, 4));
           case uint16_t(Op::I32Extend16S):
             CHECK(EmitSignExtend(f, 2, 4));
           case uint16_t(Op::I64Extend8S):
             CHECK(EmitSignExtend(f, 1, 8));
           case uint16_t(Op::I64Extend16S):
             CHECK(EmitSignExtend(f, 2, 8));
--- a/js/src/wasm/WasmTextToBinary.cpp
+++ b/js/src/wasm/WasmTextToBinary.cpp
@@ -1216,17 +1216,17 @@ WasmTokenStream::next()
                 if (consume(u"div_u"))
                     return WasmToken(WasmToken::BinaryOpcode, Op::I32DivU, begin, cur_);
                 break;
               case 'e':
                 if (consume(u"eqz"))
                     return WasmToken(WasmToken::UnaryOpcode, Op::I32Eqz, begin, cur_);
                 if (consume(u"eq"))
                     return WasmToken(WasmToken::ComparisonOpcode, Op::I32Eq, begin, cur_);
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
                 if (consume(u"extend8_s"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I32Extend8S, begin, cur_);
                 if (consume(u"extend16_s"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I32Extend16S, begin, cur_);
 #endif
                 break;
               case 'g':
                 if (consume(u"ge_s"))
@@ -1444,17 +1444,17 @@ WasmTokenStream::next()
                 if (consume(u"eq"))
                     return WasmToken(WasmToken::ComparisonOpcode, Op::I64Eq, begin, cur_);
                 if (consume(u"extend_s/i32"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I64ExtendSI32,
                                      begin, cur_);
                 if (consume(u"extend_u/i32"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I64ExtendUI32,
                                      begin, cur_);
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
                 if (consume(u"extend8_s"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I64Extend8S, begin, cur_);
                 if (consume(u"extend16_s"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I64Extend16S, begin, cur_);
                 if (consume(u"extend32_s"))
                     return WasmToken(WasmToken::ConversionOpcode, Op::I64Extend32S, begin, cur_);
 #endif
                 break;
--- a/js/src/wasm/WasmValidate.cpp
+++ b/js/src/wasm/WasmValidate.cpp
@@ -602,17 +602,17 @@ DecodeFunctionBodyExprs(const ModuleEnvi
           case uint16_t(Op::F64ConvertUI32):
             CHECK(iter.readConversion(ValType::I32, ValType::F64, &nothing));
           case uint16_t(Op::F64ConvertSI64):
           case uint16_t(Op::F64ConvertUI64):
           case uint16_t(Op::F64ReinterpretI64):
             CHECK(iter.readConversion(ValType::I64, ValType::F64, &nothing));
           case uint16_t(Op::F64PromoteF32):
             CHECK(iter.readConversion(ValType::F32, ValType::F64, &nothing));
-#ifdef ENABLE_WASM_THREAD_OPS
+#ifdef ENABLE_WASM_SIGNEXTEND_OPS
           case uint16_t(Op::I32Extend8S):
           case uint16_t(Op::I32Extend16S):
             CHECK(iter.readConversion(ValType::I32, ValType::I32, &nothing));
           case uint16_t(Op::I64Extend8S):
           case uint16_t(Op::I64Extend16S):
           case uint16_t(Op::I64Extend32S):
             CHECK(iter.readConversion(ValType::I64, ValType::I64, &nothing));
 #endif