diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-09-19 15:50:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 15:50:30 -0700 |
commit | fe88b47749115009da0447e340cbdc86edf30984 (patch) | |
tree | 7dfd9aba7086c8aa6dff4877ac1ee3b9d78bc5ce /src/passes/TrapMode.cpp | |
parent | a53356ab155a7d8c2f334dc9a3c1432bacbc78fe (diff) | |
download | binaryen-fe88b47749115009da0447e340cbdc86edf30984.tar.gz binaryen-fe88b47749115009da0447e340cbdc86edf30984.tar.bz2 binaryen-fe88b47749115009da0447e340cbdc86edf30984.zip |
Unify imported and non-imported things (#1678)
Fixes #1649
This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import.
For convenient iteration, there are a few helpers like
ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) {
.. use global ..
});
as often iteration only cares about imported or defined (non-imported) things.
Diffstat (limited to 'src/passes/TrapMode.cpp')
-rw-r--r-- | src/passes/TrapMode.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp index 68d6aad4b..19301ee3a 100644 --- a/src/passes/TrapMode.cpp +++ b/src/passes/TrapMode.cpp @@ -22,6 +22,7 @@ #include "asm_v_wasm.h" #include "asmjs/shared-constants.h" +#include "ir/function-type-utils.h" #include "ir/trapping.h" #include "mixed_arena.h" #include "pass.h" @@ -222,12 +223,13 @@ void ensureF64ToI64JSImport(TrappingFunctionContainer &trappingFunctions) { } Module& wasm = trappingFunctions.getModule(); - auto import = new Import; // f64-to-int = asm2wasm.f64-to-int; + auto import = new Function; // f64-to-int = asm2wasm.f64-to-int; import->name = F64_TO_INT; import->module = ASM2WASM; import->base = F64_TO_INT; - import->functionType = ensureFunctionType("id", &wasm)->name; - import->kind = ExternalKind::Function; + auto* functionType = ensureFunctionType("id", &wasm); + import->type = functionType->name; + FunctionTypeUtils::fillFunction(import, functionType); trappingFunctions.addImport(import); } @@ -263,7 +265,7 @@ Expression* makeTrappingUnary(Unary* curr, TrappingFunctionContainer &trappingFu // WebAssembly traps on float-to-int overflows, but asm.js wouldn't, so we must emulate that ensureF64ToI64JSImport(trappingFunctions); Expression* f64Value = ensureDouble(curr->value, wasm.allocator); - return builder.makeCallImport(F64_TO_INT, {f64Value}, i32); + return builder.makeCall(F64_TO_INT, {f64Value}, i32); } ensureUnaryFunc(curr, wasm, trappingFunctions); |