diff options
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | src/asm2wasm.h | 28 |
2 files changed, 14 insertions, 16 deletions
@@ -3,6 +3,6 @@ g++ -O2 -std=c++11 src/binaryen-shell.cpp src/pass.cpp src/passes/*.cpp -o bin/b echo "building asm2wasm" g++ -O2 -std=c++11 src/asm2wasm-main.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp -o bin/asm2wasm echo "building interpreter/js" -em++ -std=c++11 src/wasm-js.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -O3 -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 #-DWASM_JS_DEBUG #-DWASM_INTERPRETER_DEBUG +em++ -std=c++11 src/wasm-js.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -O3 -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 #-DWASM_JS_DEBUG -DWASM_INTERPRETER_DEBUG=2 cat src/js/post.js >> bin/wasm.js diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 35b75a50c..505e3ee87 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -780,23 +780,21 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->type = ret->value.type; return ret; } - AsmType childType = detectAsmType(ast[2], &asmData); - if (childType == ASM_INT) { - auto ret = allocator.alloc<Convert>(); - ret->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32; - ret->value = process(ast[2]); - ret->type = WasmType::f64; - return ret; + auto ret = process(ast[2]); // we are a +() coercion + if (ret->type == i32) { + auto conv = allocator.alloc<Convert>(); + conv->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32; + conv->value = ret; + conv->type = WasmType::f64; + return conv; } - if (childType == ASM_FLOAT) { - auto ret = allocator.alloc<Convert>(); - ret->op = PromoteFloat32; - ret->value = process(ast[2]); - ret->type = WasmType::f64; - return ret; + if (ret->type == f32) { + auto conv = allocator.alloc<Convert>(); + conv->op = PromoteFloat32; + conv->value = ret; + conv->type = WasmType::f64; + return conv; } - assert(childType == ASM_NONE || childType == ASM_DOUBLE); // e.g. a coercion on a call or for a return - auto ret = process(ast[2]); // just look through the +() coercion fixCallType(ret, f64); return ret; } else if (ast[1] == MINUS) { |