summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-29 21:57:03 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-29 21:57:03 -0700
commit915089d275ddf28b4b129de047187474d234f8b7 (patch)
tree05891cddf61c7696f07b64de9d31122ca7a09c5a /src
parent1604b4b7e265095c7d7d22455312684ee8dc0790 (diff)
parentda01ed78f16d6793dfe09f70016efba904bcaf4f (diff)
downloadbinaryen-915089d275ddf28b4b129de047187474d234f8b7.tar.gz
binaryen-915089d275ddf28b4b129de047187474d234f8b7.tar.bz2
binaryen-915089d275ddf28b4b129de047187474d234f8b7.zip
Merge pull request #293 from WebAssembly/fixes
s2wasm function type fixes
Diffstat (limited to 'src')
-rw-r--r--src/s2wasm.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index f4c83fe65..5460bf467 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -752,16 +752,7 @@ class S2WasmBuilder {
indirect->operands.push_back(inputs[i]);
}
setOutput(indirect, assign);
- auto typeName = cashew::IString((std::string("FUNCSIG_") + getSig(indirect)).c_str(), false);
- if (wasm.functionTypesMap.count(typeName) == 0) {
- auto type = allocator.alloc<FunctionType>();
- *type = sigToFunctionType(getSig(indirect));
- type->name = typeName;
- wasm.addFunctionType(type);
- indirect->fullType = type;
- } else {
- indirect->fullType = wasm.functionTypesMap[typeName];
- }
+ indirect->fullType = wasm.functionTypesMap[ensureFunctionType(getSig(indirect), &wasm, allocator)->name];
} else {
// non-indirect call
CallBase* curr;
@@ -1314,6 +1305,12 @@ class S2WasmBuilder {
block->finalize();
}
}
+
+ // ensure an explicit function type for indirect call targets
+ for (auto& name : wasm.table.names) {
+ auto* func = wasm.functionsMap[name];
+ func->type = ensureFunctionType(getSig(func), &wasm, allocator)->name;
+ }
}
template<class C>