From c1823df9feea7ea90e3886cb18fedee56df48156 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 5 Mar 2016 19:06:32 -0800 Subject: cast f32 to f64 before calling f64-to-int in asm2wasm --- src/asm2wasm.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 1aca26e88..06960a114 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1018,7 +1018,15 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { // WebAssembly traps on float-to-int overflows, but asm.js wouldn't, so we must emulate that CallImport *ret = allocator.alloc(); ret->target = F64_TO_INT; - ret->operands.push_back(process(ast[2][2])); + auto input = process(ast[2][2]); + if (input->type == f32) { + auto conv = allocator.alloc(); + conv->op = PromoteFloat32; + conv->value = input; + conv->type = WasmType::f64; + input = conv; + } + ret->operands.push_back(input); ret->type = i32; static bool addedImport = false; if (!addedImport) { -- cgit v1.2.3