summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index f4c83fe65..1fa624dd0 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -677,13 +677,13 @@ class S2WasmBuilder {
auto makeHost = [&](HostOp op) {
Name assign = getAssign();
auto curr = allocator.alloc<Host>();
- curr->op = MemorySize;
+ curr->op = op;
setOutput(curr, assign);
};
auto makeHost1 = [&](HostOp op) {
Name assign = getAssign();
auto curr = allocator.alloc<Host>();
- curr->op = MemorySize;
+ curr->op = op;
curr->operands.push_back(getInput());
setOutput(curr, assign);
};
@@ -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>