diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-05 19:40:30 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-05 19:40:30 -0800 |
commit | 4752e205dc84df8b41cd6dbc7282f85a38a89e8e (patch) | |
tree | 956b8f6628b75cba96747dbe0b622780c81484c9 | |
parent | 2b38d9587a5dff98f918ccf7d1112e8db2b357fe (diff) | |
download | binaryen-4752e205dc84df8b41cd6dbc7282f85a38a89e8e.tar.gz binaryen-4752e205dc84df8b41cd6dbc7282f85a38a89e8e.tar.bz2 binaryen-4752e205dc84df8b41cd6dbc7282f85a38a89e8e.zip |
coerce call arguments in wasm2asm
-rw-r--r-- | src/wasm2asm.h | 6 | ||||
-rw-r--r-- | test/unit.2asm.js | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 606423e8e..f139b58dd 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -570,7 +570,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { temps.emplace_back(operand->type, parent); IString temp = temps.back().temp; ret[1]->push_back(visitAndAssign(operand, temp)); - theCall[2]->push_back(ValueBuilder::makeName(temp)); + theCall[2]->push_back(makeAsmCoercion(ValueBuilder::makeName(temp), wasmToAsmType(operand->type))); } theCall = makeAsmCoercion(theCall, wasmToAsmType(type)); if (result != NO_RESULT) { @@ -585,7 +585,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { if (!isStatement(curr)) { // none of our operands is a statement; go right ahead and create a simple expression for (auto operand : curr->operands) { - theCall[2]->push_back(visit(operand, EXPRESSION_RESULT)); + theCall[2]->push_back(makeAsmCoercion(visit(operand, EXPRESSION_RESULT), wasmToAsmType(operand->type))); } return makeAsmCoercion(theCall, wasmToAsmType(curr->type)); } @@ -600,7 +600,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { // none of our operands is a statement; go right ahead and create a simple expression Ref theCall = ValueBuilder::makeCall(ValueBuilder::makeSub(ValueBuilder::makeName(FUNCTION_TABLE), visit(curr->target, EXPRESSION_RESULT))); for (auto operand : curr->operands) { - theCall[2]->push_back(visit(operand, EXPRESSION_RESULT)); + theCall[2]->push_back(makeAsmCoercion(visit(operand, EXPRESSION_RESULT), wasmToAsmType(operand->type))); } return makeAsmCoercion(theCall, wasmToAsmType(curr->type)); } diff --git a/test/unit.2asm.js b/test/unit.2asm.js index cc69449e7..f85c89f0c 100644 --- a/test/unit.2asm.js +++ b/test/unit.2asm.js @@ -61,7 +61,7 @@ function asmFunc() { function conversions() { var i = 0, d = 0.0; { - i = f64_to_int(d) | 0; + i = f64_to_int(+d) | 0; d = +i; d = +((i >>> 0 | 0) >>> 0); } @@ -100,7 +100,7 @@ function asmFunc() { } function frem() { - return +f64_rem(5.5, 1.2); + return +f64_rem(+(5.5), +(1.2)); } function big_uint_div_u() { @@ -144,7 +144,7 @@ function asmFunc() { var x = Math_fround(0); { x = Math_fround(-x); - FUNCTION_TABLE[(1 & 7 | 0) + 8 | 0](x); + FUNCTION_TABLE[(1 & 7 | 0) + 8 | 0](Math_fround(x)); } } |