summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-07-27 16:29:12 -0700
committerGitHub <noreply@github.com>2017-07-27 16:29:12 -0700
commit4d46a7e2c37299d5a9b9d9d6323ce9fca3a1cf3a (patch)
tree278f1da3868901fa8282651ac589c6acc534d535 /src
parent203b7f758c34bf38357ec770659713647585538e (diff)
downloadbinaryen-4d46a7e2c37299d5a9b9d9d6323ce9fca3a1cf3a.tar.gz
binaryen-4d46a7e2c37299d5a9b9d9d6323ce9fca3a1cf3a.tar.bz2
binaryen-4d46a7e2c37299d5a9b9d9d6323ce9fca3a1cf3a.zip
fix import type detection of calls in comma operators; when the parent is a comma, it can't be a coersion (or that would have been the parent), so there is no coercion, so the result type is none (#1115)
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 153839065..e8349627f 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -476,15 +476,20 @@ private:
}
}
- FunctionType* getFunctionType(Ref parent, ExpressionList& operands) {
- WasmType result = none;
+ WasmType getResultTypeOfCallUsingParent(Ref parent, AsmData* data) {
+ auto result = none;
if (!!parent) {
// if the parent is a seq, we cannot be the last element in it (we would have a coercion, which would be
// the parent), so we must be (us, somethingElse), and so our return is void
if (parent[0] != SEQ) {
- result = detectWasmType(parent, nullptr);
+ result = detectWasmType(parent, data);
}
}
+ return result;
+ }
+
+ FunctionType* getFunctionType(Ref parent, ExpressionList& operands, AsmData* data) {
+ WasmType result = getResultTypeOfCallUsingParent(parent, data);
return ensureFunctionType(getSig(result, operands), &wasm);
}
@@ -2189,7 +2194,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
if (tableCall) {
auto specific = ret->dynCast<CallIndirect>();
// note that we could also get the type from the suffix of the name, e.g., mftCall_vi
- auto* fullType = getFunctionType(astStackHelper.getParent(), specific->operands);
+ auto* fullType = getFunctionType(astStackHelper.getParent(), specific->operands, &asmData);
specific->fullType = fullType->name;
specific->type = fullType->result;
}
@@ -2202,8 +2207,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
// this is important as we run the optimizer on functions before we get
// to finalizeCalls (which we can only do once we've read all the functions,
// and we optimize in parallel starting earlier).
- Ref parent = astStackHelper.getParent();
- callImport->type = !!parent ? detectWasmType(parent, &asmData) : none;
+ callImport->type = getResultTypeOfCallUsingParent(astStackHelper.getParent(), &asmData);
noteImportedFunctionCall(ast, callImport->type, callImport);
}
return ret;
@@ -2217,7 +2221,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
for (unsigned i = 0; i < args->size(); i++) {
ret->operands.push_back(process(args[i]));
}
- auto* fullType = getFunctionType(astStackHelper.getParent(), ret->operands);
+ auto* fullType = getFunctionType(astStackHelper.getParent(), ret->operands, &asmData);
ret->fullType = fullType->name;
ret->type = fullType->result;
// we don't know the table offset yet. emit target = target + callImport(tableName), which we fix up later when we know how asm function tables are layed out inside the wasm table.