summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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>