diff options
Diffstat (limited to 'src/abi/js.h')
-rw-r--r-- | src/abi/js.h | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/src/abi/js.h b/src/abi/js.h index 6994a4291..8391346c8 100644 --- a/src/abi/js.h +++ b/src/abi/js.h @@ -17,17 +17,14 @@ #ifndef wasm_abi_abi_h #define wasm_abi_abi_h -#include "wasm.h" #include "asmjs/shared-constants.h" +#include "wasm.h" namespace wasm { namespace ABI { -enum class LegalizationLevel { - Full = 0, - Minimal = 1 -}; +enum class LegalizationLevel { Full = 0, Minimal = 1 }; inline std::string getLegalizationPass(LegalizationLevel level) { if (level == LegalizationLevel::Full) { @@ -39,51 +36,52 @@ inline std::string getLegalizationPass(LegalizationLevel level) { namespace wasm2js { -extern cashew::IString SCRATCH_LOAD_I32, - SCRATCH_STORE_I32, - SCRATCH_LOAD_I64, - SCRATCH_STORE_I64, - SCRATCH_LOAD_F32, - SCRATCH_STORE_F32, - SCRATCH_LOAD_F64, - SCRATCH_STORE_F64; +extern cashew::IString SCRATCH_LOAD_I32; +extern cashew::IString SCRATCH_STORE_I32; +extern cashew::IString SCRATCH_LOAD_I64; +extern cashew::IString SCRATCH_STORE_I64; +extern cashew::IString SCRATCH_LOAD_F32; +extern cashew::IString SCRATCH_STORE_F32; +extern cashew::IString SCRATCH_LOAD_F64; +extern cashew::IString SCRATCH_STORE_F64; // The wasm2js scratch memory helpers let us read and write to scratch memory // for purposes of implementing things like reinterpret, etc. // The optional "specific" parameter is a specific function we want. If not // provided, we create them all. -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)); - }; +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)); + }; - ensureImport(SCRATCH_LOAD_I32, { i32 }, i32); - ensureImport(SCRATCH_STORE_I32, { i32, i32 }, none); + ensureImport(SCRATCH_LOAD_I32, {i32}, i32); + ensureImport(SCRATCH_STORE_I32, {i32, i32}, none); ensureImport(SCRATCH_LOAD_I64, {}, i64); - ensureImport(SCRATCH_STORE_I64, { i64 }, none); + ensureImport(SCRATCH_STORE_I64, {i64}, none); ensureImport(SCRATCH_LOAD_F32, {}, f32); - ensureImport(SCRATCH_STORE_F32, { f32 }, none); + ensureImport(SCRATCH_STORE_F32, {f32}, none); ensureImport(SCRATCH_LOAD_F64, {}, f64); - ensureImport(SCRATCH_STORE_F64, { f64 }, none); + ensureImport(SCRATCH_STORE_F64, {f64}, none); } inline bool isScratchMemoryHelper(cashew::IString name) { - return name == SCRATCH_LOAD_I32 || - name == SCRATCH_STORE_I32 || - name == SCRATCH_LOAD_I64 || - name == SCRATCH_STORE_I64 || - name == SCRATCH_LOAD_F32 || - name == SCRATCH_STORE_F32 || - name == SCRATCH_LOAD_F64 || - name == SCRATCH_STORE_F64; + return name == SCRATCH_LOAD_I32 || name == SCRATCH_STORE_I32 || + name == SCRATCH_LOAD_I64 || name == SCRATCH_STORE_I64 || + name == SCRATCH_LOAD_F32 || name == SCRATCH_STORE_F32 || + name == SCRATCH_LOAD_F64 || name == SCRATCH_STORE_F64; } } // namespace wasm2js |