diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-29 21:57:03 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-29 21:57:03 -0700 |
commit | 915089d275ddf28b4b129de047187474d234f8b7 (patch) | |
tree | 05891cddf61c7696f07b64de9d31122ca7a09c5a /src | |
parent | 1604b4b7e265095c7d7d22455312684ee8dc0790 (diff) | |
parent | da01ed78f16d6793dfe09f70016efba904bcaf4f (diff) | |
download | binaryen-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.h | 17 |
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> |