From 5d16d4b3b344aa1dbe07deff0d282adea6f8c369 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 22 May 2016 15:05:02 -0700 Subject: don't depend on asm.js type detection in binary formation in asm2wasm, use the full asm global info we have (#535) --- src/asm2wasm.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index d1959b918..0aa3f91ac 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -306,8 +306,8 @@ private: return detectSign(ast, Math_fround) == ASM_UNSIGNED; } - BinaryOp parseAsmBinaryOp(IString op, Ref left, Ref right, AsmData *asmData) { - WasmType leftType = detectWasmType(left, asmData); + BinaryOp parseAsmBinaryOp(IString op, Ref left, Ref right, Expression* leftWasm, Expression* rightWasm) { + WasmType leftType = leftWasm->type; bool isInteger = leftType == WasmType::i32; if (op == PLUS) return isInteger ? BinaryOp::AddInt32 : (leftType == f32 ? BinaryOp::AddFloat32 : BinaryOp::AddFloat64); @@ -997,13 +997,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { fixCallType(ret, i32); return ret; } - BinaryOp binary = parseAsmBinaryOp(ast[1]->getIString(), ast[2], ast[3], &asmData); auto ret = allocator.alloc(); - ret->op = binary; ret->left = process(ast[2]); ret->right = process(ast[3]); + ret->op = parseAsmBinaryOp(ast[1]->getIString(), ast[2], ast[3], ret->left, ret->right); ret->finalize(); - if (binary == BinaryOp::RemSInt32 && isWasmTypeFloat(ret->type)) { + if (ret->op == BinaryOp::RemSInt32 && isWasmTypeFloat(ret->type)) { // WebAssembly does not have floating-point remainder, we have to emit a call to a special import of ours CallImport *call = allocator.alloc(); call->target = F64_REM; -- cgit v1.2.3