diff options
-rw-r--r-- | src/abi/js.h | 35 | ||||
-rw-r--r-- | src/asmjs/shared-constants.cpp | 186 | ||||
-rw-r--r-- | src/passes/PostEmscripten.cpp | 6 | ||||
-rw-r--r-- | src/support/json.h | 2 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 26 |
5 files changed, 128 insertions, 127 deletions
diff --git a/src/abi/js.h b/src/abi/js.h index 96bfc2125..60531803d 100644 --- a/src/abi/js.h +++ b/src/abi/js.h @@ -37,28 +37,29 @@ inline std::string getLegalizationPass(LegalizationLevel level) { namespace wasm2js { -extern cashew::IString SCRATCH_LOAD_I32; -extern cashew::IString SCRATCH_STORE_I32; -extern cashew::IString SCRATCH_LOAD_F32; -extern cashew::IString SCRATCH_STORE_F32; -extern cashew::IString SCRATCH_LOAD_F64; -extern cashew::IString SCRATCH_STORE_F64; -extern cashew::IString MEMORY_INIT; -extern cashew::IString MEMORY_FILL; -extern cashew::IString MEMORY_COPY; -extern cashew::IString DATA_DROP; -extern cashew::IString ATOMIC_WAIT_I32; -extern cashew::IString ATOMIC_RMW_I64; -extern cashew::IString GET_STASHED_BITS; -extern cashew::IString TRAP; +using IString = cashew::IString; + +extern IString SCRATCH_LOAD_I32; +extern IString SCRATCH_STORE_I32; +extern IString SCRATCH_LOAD_F32; +extern IString SCRATCH_STORE_F32; +extern IString SCRATCH_LOAD_F64; +extern IString SCRATCH_STORE_F64; +extern IString MEMORY_INIT; +extern IString MEMORY_FILL; +extern IString MEMORY_COPY; +extern IString DATA_DROP; +extern IString ATOMIC_WAIT_I32; +extern IString ATOMIC_RMW_I64; +extern IString GET_STASHED_BITS; +extern IString TRAP; // The wasm2js helpers let us do things that can't be done without special help, // like 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 ensureHelpers(Module* wasm, - cashew::IString specific = cashew::IString()) { +inline void ensureHelpers(Module* wasm, IString specific = IString()) { auto ensureImport = [&](Name name, Type params, Type results) { if (wasm->getFunctionOrNull(name)) { return; @@ -93,7 +94,7 @@ inline void ensureHelpers(Module* wasm, ensureImport(TRAP, {}, Type::none); } -inline bool isHelper(cashew::IString name) { +inline bool isHelper(IString name) { return name == SCRATCH_LOAD_I32 || name == SCRATCH_STORE_I32 || name == SCRATCH_LOAD_F32 || name == SCRATCH_STORE_F32 || name == SCRATCH_LOAD_F64 || name == SCRATCH_STORE_F64 || diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp index f66b5de18..6cb350f9f 100644 --- a/src/asmjs/shared-constants.cpp +++ b/src/asmjs/shared-constants.cpp @@ -18,104 +18,106 @@ namespace wasm { -cashew::IString TOPMOST("topmost"); -cashew::IString INT8ARRAY("Int8Array"); -cashew::IString INT16ARRAY("Int16Array"); -cashew::IString INT32ARRAY("Int32Array"); -cashew::IString UINT8ARRAY("Uint8Array"); -cashew::IString UINT16ARRAY("Uint16Array"); -cashew::IString UINT32ARRAY("Uint32Array"); -cashew::IString FLOAT32ARRAY("Float32Array"); -cashew::IString FLOAT64ARRAY("Float64Array"); -cashew::IString ARRAY_BUFFER("ArrayBuffer"); -cashew::IString ASM_MODULE("asmModule"); -cashew::IString MATH("Math"); -cashew::IString IMUL("imul"); -cashew::IString CLZ32("clz32"); -cashew::IString FROUND("fround"); -cashew::IString ASM2WASM("asm2wasm"); -cashew::IString MIN("min"); -cashew::IString MAX("max"); -cashew::IString F64_REM("f64-rem"); -cashew::IString F64_TO_INT("f64-to-int"); -cashew::IString F64_TO_UINT("f64-to-uint"); -cashew::IString F64_TO_INT64("f64-to-int64"); -cashew::IString F64_TO_UINT64("f64-to-uint64"); -cashew::IString F32_TO_INT("f32-to-int"); -cashew::IString F32_TO_UINT("f32-to-uint"); -cashew::IString F32_TO_INT64("f32-to-int64"); -cashew::IString F32_TO_UINT64("f32-to-uint64"); -cashew::IString I32S_DIV("i32s-div"); -cashew::IString I32U_DIV("i32u-div"); -cashew::IString I32S_REM("i32s-rem"); -cashew::IString I32U_REM("i32u-rem"); -cashew::IString ABS("abs"); -cashew::IString FLOOR("floor"); -cashew::IString CEIL("ceil"); -cashew::IString TRUNC("trunc"); -cashew::IString SQRT("sqrt"); -cashew::IString POW("pow"); -cashew::IString I32_TEMP("asm2wasm_i32_temp"); -cashew::IString DEBUGGER("debugger"); -cashew::IString BUFFER("buffer"); -cashew::IString ENV("env"); -cashew::IString STACKTOP("STACKTOP"); -cashew::IString STACK_MAX("STACK_MAX"); -cashew::IString INSTRUMENT("instrument"); -cashew::IString MATH_IMUL("Math_imul"); -cashew::IString MATH_ABS("Math_abs"); -cashew::IString MATH_CEIL("Math_ceil"); -cashew::IString MATH_CLZ32("Math_clz32"); -cashew::IString MATH_FLOOR("Math_floor"); -cashew::IString MATH_TRUNC("Math_trunc"); -cashew::IString MATH_SQRT("Math_sqrt"); -cashew::IString MATH_MIN("Math_min"); -cashew::IString MATH_MAX("Math_max"); -cashew::IString WASM_CTZ32("__wasm_ctz_i32"); -cashew::IString WASM_CTZ64("__wasm_ctz_i64"); -cashew::IString WASM_CLZ32("__wasm_clz_i32"); -cashew::IString WASM_CLZ64("__wasm_clz_i64"); -cashew::IString WASM_POPCNT32("__wasm_popcnt_i32"); -cashew::IString WASM_POPCNT64("__wasm_popcnt_i64"); -cashew::IString WASM_ROTL32("__wasm_rotl_i32"); -cashew::IString WASM_ROTL64("__wasm_rotl_i64"); -cashew::IString WASM_ROTR32("__wasm_rotr_i32"); -cashew::IString WASM_ROTR64("__wasm_rotr_i64"); -cashew::IString WASM_MEMORY_GROW("__wasm_memory_grow"); -cashew::IString WASM_MEMORY_SIZE("__wasm_memory_size"); -cashew::IString WASM_FETCH_HIGH_BITS("__wasm_fetch_high_bits"); -cashew::IString INT64_TO_32_HIGH_BITS("i64toi32_i32$HIGH_BITS"); -cashew::IString WASM_NEAREST_F32("__wasm_nearest_f32"); -cashew::IString WASM_NEAREST_F64("__wasm_nearest_f64"); -cashew::IString WASM_I64_MUL("__wasm_i64_mul"); -cashew::IString WASM_I64_SDIV("__wasm_i64_sdiv"); -cashew::IString WASM_I64_UDIV("__wasm_i64_udiv"); -cashew::IString WASM_I64_SREM("__wasm_i64_srem"); -cashew::IString WASM_I64_UREM("__wasm_i64_urem"); +using IString = cashew::IString; -cashew::IString ASM_FUNC("asmFunc"); -cashew::IString FUNCTION_TABLE("FUNCTION_TABLE"); -cashew::IString NO_RESULT("wasm2js$noresult"); // no result at all +IString TOPMOST("topmost"); +IString INT8ARRAY("Int8Array"); +IString INT16ARRAY("Int16Array"); +IString INT32ARRAY("Int32Array"); +IString UINT8ARRAY("Uint8Array"); +IString UINT16ARRAY("Uint16Array"); +IString UINT32ARRAY("Uint32Array"); +IString FLOAT32ARRAY("Float32Array"); +IString FLOAT64ARRAY("Float64Array"); +IString ARRAY_BUFFER("ArrayBuffer"); +IString ASM_MODULE("asmModule"); +IString MATH("Math"); +IString IMUL("imul"); +IString CLZ32("clz32"); +IString FROUND("fround"); +IString ASM2WASM("asm2wasm"); +IString MIN("min"); +IString MAX("max"); +IString F64_REM("f64-rem"); +IString F64_TO_INT("f64-to-int"); +IString F64_TO_UINT("f64-to-uint"); +IString F64_TO_INT64("f64-to-int64"); +IString F64_TO_UINT64("f64-to-uint64"); +IString F32_TO_INT("f32-to-int"); +IString F32_TO_UINT("f32-to-uint"); +IString F32_TO_INT64("f32-to-int64"); +IString F32_TO_UINT64("f32-to-uint64"); +IString I32S_DIV("i32s-div"); +IString I32U_DIV("i32u-div"); +IString I32S_REM("i32s-rem"); +IString I32U_REM("i32u-rem"); +IString ABS("abs"); +IString FLOOR("floor"); +IString CEIL("ceil"); +IString TRUNC("trunc"); +IString SQRT("sqrt"); +IString POW("pow"); +IString I32_TEMP("asm2wasm_i32_temp"); +IString DEBUGGER("debugger"); +IString BUFFER("buffer"); +IString ENV("env"); +IString STACKTOP("STACKTOP"); +IString STACK_MAX("STACK_MAX"); +IString INSTRUMENT("instrument"); +IString MATH_IMUL("Math_imul"); +IString MATH_ABS("Math_abs"); +IString MATH_CEIL("Math_ceil"); +IString MATH_CLZ32("Math_clz32"); +IString MATH_FLOOR("Math_floor"); +IString MATH_TRUNC("Math_trunc"); +IString MATH_SQRT("Math_sqrt"); +IString MATH_MIN("Math_min"); +IString MATH_MAX("Math_max"); +IString WASM_CTZ32("__wasm_ctz_i32"); +IString WASM_CTZ64("__wasm_ctz_i64"); +IString WASM_CLZ32("__wasm_clz_i32"); +IString WASM_CLZ64("__wasm_clz_i64"); +IString WASM_POPCNT32("__wasm_popcnt_i32"); +IString WASM_POPCNT64("__wasm_popcnt_i64"); +IString WASM_ROTL32("__wasm_rotl_i32"); +IString WASM_ROTL64("__wasm_rotl_i64"); +IString WASM_ROTR32("__wasm_rotr_i32"); +IString WASM_ROTR64("__wasm_rotr_i64"); +IString WASM_MEMORY_GROW("__wasm_memory_grow"); +IString WASM_MEMORY_SIZE("__wasm_memory_size"); +IString WASM_FETCH_HIGH_BITS("__wasm_fetch_high_bits"); +IString INT64_TO_32_HIGH_BITS("i64toi32_i32$HIGH_BITS"); +IString WASM_NEAREST_F32("__wasm_nearest_f32"); +IString WASM_NEAREST_F64("__wasm_nearest_f64"); +IString WASM_I64_MUL("__wasm_i64_mul"); +IString WASM_I64_SDIV("__wasm_i64_sdiv"); +IString WASM_I64_UDIV("__wasm_i64_udiv"); +IString WASM_I64_SREM("__wasm_i64_srem"); +IString WASM_I64_UREM("__wasm_i64_urem"); + +IString ASM_FUNC("asmFunc"); +IString FUNCTION_TABLE("FUNCTION_TABLE"); +IString NO_RESULT("wasm2js$noresult"); // no result at all // result in an expression, no temp var -cashew::IString EXPRESSION_RESULT("wasm2js$expresult"); +IString EXPRESSION_RESULT("wasm2js$expresult"); namespace ABI { namespace wasm2js { -cashew::IString SCRATCH_LOAD_I32("wasm2js_scratch_load_i32"); -cashew::IString SCRATCH_STORE_I32("wasm2js_scratch_store_i32"); -cashew::IString SCRATCH_LOAD_F32("wasm2js_scratch_load_f32"); -cashew::IString SCRATCH_STORE_F32("wasm2js_scratch_store_f32"); -cashew::IString SCRATCH_LOAD_F64("wasm2js_scratch_load_f64"); -cashew::IString SCRATCH_STORE_F64("wasm2js_scratch_store_f64"); -cashew::IString MEMORY_INIT("wasm2js_memory_init"); -cashew::IString MEMORY_FILL("wasm2js_memory_fill"); -cashew::IString MEMORY_COPY("wasm2js_memory_copy"); -cashew::IString DATA_DROP("wasm2js_data_drop"); -cashew::IString ATOMIC_WAIT_I32("wasm2js_atomic_wait_i32"); -cashew::IString ATOMIC_RMW_I64("wasm2js_atomic_rmw_i64"); -cashew::IString GET_STASHED_BITS("wasm2js_get_stashed_bits"); -cashew::IString TRAP("wasm2js_trap"); +IString SCRATCH_LOAD_I32("wasm2js_scratch_load_i32"); +IString SCRATCH_STORE_I32("wasm2js_scratch_store_i32"); +IString SCRATCH_LOAD_F32("wasm2js_scratch_load_f32"); +IString SCRATCH_STORE_F32("wasm2js_scratch_store_f32"); +IString SCRATCH_LOAD_F64("wasm2js_scratch_load_f64"); +IString SCRATCH_STORE_F64("wasm2js_scratch_store_f64"); +IString MEMORY_INIT("wasm2js_memory_init"); +IString MEMORY_FILL("wasm2js_memory_fill"); +IString MEMORY_COPY("wasm2js_memory_copy"); +IString DATA_DROP("wasm2js_data_drop"); +IString ATOMIC_WAIT_I32("wasm2js_atomic_wait_i32"); +IString ATOMIC_RMW_I64("wasm2js_atomic_rmw_i64"); +IString GET_STASHED_BITS("wasm2js_get_stashed_bits"); +IString TRAP("wasm2js_trap"); } // namespace wasm2js } // namespace ABI diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index ded949859..c936337f3 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -184,8 +184,10 @@ static void removeData(Module& wasm, << startAddress << ") and " << end_sym << " (" << endAddress << ")"; } -cashew::IString EM_JS_PREFIX("__em_js__"); -cashew::IString EM_JS_DEPS_PREFIX("__em_lib_deps_"); +using IString = cashew::IString; + +IString EM_JS_PREFIX("__em_js__"); +IString EM_JS_DEPS_PREFIX("__em_lib_deps_"); struct EmJsWalker : public PostWalker<EmJsWalker> { std::vector<Export> toRemove; diff --git a/src/support/json.h b/src/support/json.h index be4a6c250..a145e1f6b 100644 --- a/src/support/json.h +++ b/src/support/json.h @@ -42,7 +42,7 @@ namespace json { -typedef cashew::IString IString; +using IString = cashew::IString; // Main value type struct Value { diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index c91c01842..a7baaa54b 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -29,14 +29,14 @@ namespace wasm { +using IString = cashew::IString; + class SourceLocation { public: - cashew::IString filename; + IString filename; uint32_t line; uint32_t column; - SourceLocation(cashew::IString filename_, - uint32_t line_, - uint32_t column_ = 0) + SourceLocation(IString filename_, uint32_t line_, uint32_t column_ = 0) : filename(filename_), line(line_), column(column_) {} }; @@ -48,7 +48,7 @@ class Element { bool isList_ = true; List list_; - cashew::IString str_; + IString str_; bool dollared_; bool quoted_; @@ -74,9 +74,9 @@ public: List::Iterator end() { return list().end(); } // string methods - cashew::IString str() const; + IString str() const; const char* c_str() const; - Element* setString(cashew::IString str__, bool dollared__, bool quoted__); + Element* setString(IString str__, bool dollared__, bool quoted__); Element* setMetadata(size_t line_, size_t col_, SourceLocation* startLoc_); // comparisons @@ -138,7 +138,7 @@ class SExpressionWasmBuilder { int dataCounter = 0; // we need to know function return types before we parse their contents std::map<Name, HeapType> functionTypes; - std::unordered_map<cashew::IString, Index> debugInfoFileIndices; + std::unordered_map<IString, Index> debugInfoFileIndices; // Maps type indexes to a mapping of field index => name. This is not the same // as the field names stored on the wasm object, as that maps types after @@ -183,22 +183,18 @@ private: size_t parseFunctionNames(Element& s, Name& name, Name& exportName); void parseFunction(Element& s, bool preParseImport = false); - Type stringToType(cashew::IString str, - bool allowError = false, - bool prefix = false) { + Type stringToType(IString str, bool allowError = false, bool prefix = false) { return stringToType(str.str, allowError, prefix); } Type stringToType(const char* str, bool allowError = false, bool prefix = false); - HeapType stringToHeapType(cashew::IString str, bool prefix = false) { + HeapType stringToHeapType(IString str, bool prefix = false) { return stringToHeapType(str.str, prefix); } HeapType stringToHeapType(const char* str, bool prefix = false); Type elementToType(Element& s); Type stringToLaneType(const char* str); - bool isType(cashew::IString str) { - return stringToType(str, true) != Type::none; - } + bool isType(IString str) { return stringToType(str, true) != Type::none; } HeapType getFunctionType(Name name, Element& s); public: |