summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-emscripten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r--src/wasm/wasm-emscripten.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp
index f7b7213d9..390266d44 100644
--- a/src/wasm/wasm-emscripten.cpp
+++ b/src/wasm/wasm-emscripten.cpp
@@ -182,12 +182,18 @@ void EmscriptenGlueGenerator::generateDynCallThunks() {
for (const auto& indirectFunc : tableSegmentData) {
std::string sig = getSig(wasm.getFunction(indirectFunc));
auto* funcType = ensureFunctionType(sig, &wasm);
- if (!sigs.insert(sig).second) continue; // Sig is already in the set
+ if (!sigs.insert(sig).second) {
+ continue; // sig is already in the set
+ }
+ Name name = std::string("dynCall_") + sig;
+ if (wasm.getFunctionOrNull(name) || wasm.getExportOrNull(name)) {
+ continue; // module already contains this dyncall
+ }
std::vector<NameType> params;
params.emplace_back("fptr", i32); // function pointer param
int p = 0;
for (const auto& ty : funcType->params) params.emplace_back(std::to_string(p++), ty);
- Function* f = builder.makeFunction(std::string("dynCall_") + sig, std::move(params), funcType->result, {});
+ Function* f = builder.makeFunction(name, std::move(params), funcType->result, {});
Expression* fptr = builder.makeGetLocal(0, i32);
std::vector<Expression*> args;
for (unsigned i = 0; i < funcType->params.size(); ++i) {