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.

--HG--
extra : rebase_source : 58c4638b85cb03c8ecb4af61b11fcb6f388fa9fa
This commit is contained in:
Lars T Hansen 2018-01-09 10:52:42 +01:00
Родитель 5080014924
Коммит 6844905ced
11 изменённых файлов: 30 добавлений и 11 удалений

Просмотреть файл

@ -553,6 +553,19 @@ WasmThreadsSupported(JSContext* cx, unsigned argc, Value* vp)
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)
{
@ -5259,6 +5272,11 @@ gc::ZealModeHelpText),
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,

Просмотреть файл

@ -238,7 +238,7 @@ 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);

Просмотреть файл

@ -640,6 +640,7 @@ 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']:

Просмотреть файл

@ -8959,7 +8959,7 @@ BaseCompiler::emitBody()
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):

Просмотреть файл

@ -314,7 +314,7 @@ enum class Op
F32ReinterpretI32 = 0xbe,
F64ReinterpretI64 = 0xbf,
#ifdef ENABLE_WASM_THREAD_OPS
#ifdef ENABLE_WASM_SIGNEXTEND_OPS
// Sign extension
I32Extend8S = 0xc0,
I32Extend16S = 0xc1,

Просмотреть файл

@ -177,7 +177,7 @@ wasm::Classify(OpBytes op)
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:

Просмотреть файл

@ -1513,7 +1513,7 @@ AstDecodeExpr(AstDecodeContext& c)
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)))

Просмотреть файл

@ -736,7 +736,7 @@ RenderConversionOperator(WasmRenderContext& c, AstConversionOperator& conv)
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;

Просмотреть файл

@ -2430,7 +2430,7 @@ EmitTruncate(FunctionCompiler& f, ValType operandType, ValType resultType,
return true;
}
#ifdef ENABLE_WASM_THREAD_OPS
#ifdef ENABLE_WASM_SIGNEXTEND_OPS
static bool
EmitSignExtend(FunctionCompiler& f, uint32_t srcSize, uint32_t targetSize)
{
@ -3965,7 +3965,7 @@ EmitBodyExprs(FunctionCompiler& f)
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):

Просмотреть файл

@ -1221,7 +1221,7 @@ WasmTokenStream::next()
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"))
@ -1449,7 +1449,7 @@ WasmTokenStream::next()
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"))

Просмотреть файл

@ -607,7 +607,7 @@ DecodeFunctionBodyExprs(const ModuleEnvironment& env, const Sig& sig, const ValT
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));