diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-12-11 17:12:37 -0800 |
---|---|---|
committer | Alon Zakai <azakai@google.com> | 2019-12-11 17:12:37 -0800 |
commit | 759c485a9f35bd859d43b86b02e1397a669fa469 (patch) | |
tree | a5c7475002b406e35c6d1e5c2d843000947ef192 /src/abi/js.h | |
parent | acd786dbd1e59f9d105c4ec8603c2ff46f233649 (diff) | |
download | binaryen-759c485a9f35bd859d43b86b02e1397a669fa469.tar.gz binaryen-759c485a9f35bd859d43b86b02e1397a669fa469.tar.bz2 binaryen-759c485a9f35bd859d43b86b02e1397a669fa469.zip |
Remove FunctionType (#2510)
Function signatures were previously redundantly stored on Function
objects as well as on FunctionType objects. These two signature
representations had to always be kept in sync, which was error-prone
and needlessly complex. This PR takes advantage of the new ability of
Type to represent multiple value types by consolidating function
signatures as a pair of Types (params and results) stored on the
Function object.
Since there are no longer module-global named function types,
significant changes had to be made to the printing and emitting of
function types, as well as their parsing and manipulation in various
passes.
The C and JS APIs and their tests also had to be updated to remove
named function types.
Diffstat (limited to 'src/abi/js.h')
-rw-r--r-- | src/abi/js.h | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/abi/js.h b/src/abi/js.h index 52ca5657f..89e3f0087 100644 --- a/src/abi/js.h +++ b/src/abi/js.h @@ -52,22 +52,20 @@ extern cashew::IString SCRATCH_STORE_F64; inline void ensureScratchMemoryHelpers(Module* wasm, cashew::IString specific = cashew::IString()) { - auto ensureImport = - [&](Name name, const std::vector<Type> params, Type result) { - if (wasm->getFunctionOrNull(name)) { - return; - } - if (specific.is() && name != specific) { - return; - } - auto func = make_unique<Function>(); - func->name = name; - func->params = params; - func->result = result; - func->module = ENV; - func->base = name; - wasm->addFunction(std::move(func)); - }; + auto ensureImport = [&](Name name, Type params, Type results) { + if (wasm->getFunctionOrNull(name)) { + return; + } + if (specific.is() && name != specific) { + return; + } + auto func = make_unique<Function>(); + func->name = name; + func->sig = Signature(params, results); + func->module = ENV; + func->base = name; + wasm->addFunction(std::move(func)); + }; ensureImport(SCRATCH_LOAD_I32, {i32}, i32); ensureImport(SCRATCH_STORE_I32, {i32, i32}, none); |