From 6fdd9dd2137a563bc41a85cf45178cc734e499a2 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Tue, 14 Jun 2016 15:46:30 -0700 Subject: Do not create dyncall thunks for functions with i64 results or params (#586) Dyncall thunks are meant to be used with emscripten on the web; however on the web, functions with i64 results or params are not allowed to be exported. --- src/wasm-linker.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 1ec2defc9..e6a0a0514 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -357,12 +357,21 @@ void Linker::emscriptenGlue(std::ostream& o) { o << " }\n"; } +bool hasI64ResultOrParam(FunctionType* ft) { + if (ft->result == i64) return true; + for (auto ty : ft->params) { + if (ty == i64) return true; + } + return false; +} + void Linker::makeDynCallThunks() { std::unordered_set sigs; wasm::Builder wasmBuilder(out.wasm); for (const auto& indirectFunc : out.wasm.table.names) { std::string sig(getSig(out.wasm.getFunction(indirectFunc))); auto* funcType = ensureFunctionType(sig, &out.wasm); + if (hasI64ResultOrParam(funcType)) continue; // Can't export i64s on the web. if (!sigs.insert(sig).second) continue; // Sig is already in the set std::vector params; params.emplace_back("fptr", i32); // function pointer param -- cgit v1.2.3