summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm_v_wasm.h17
-rw-r--r--src/asmjs/asm_v_wasm.cpp38
-rw-r--r--src/asmjs/shared-constants.cpp2
-rw-r--r--src/asmjs/shared-constants.h2
-rw-r--r--src/parsing.h1
-rw-r--r--src/passes/Directize.cpp1
-rw-r--r--src/passes/DuplicateImportElimination.cpp1
-rw-r--r--src/passes/FuncCastEmulation.cpp1
-rw-r--r--src/passes/I64ToI32Lowering.cpp1
-rw-r--r--src/passes/InstrumentLocals.cpp1
-rw-r--r--src/passes/InstrumentMemory.cpp1
-rw-r--r--src/passes/LegalizeJSInterface.cpp1
-rw-r--r--src/passes/LogExecution.cpp1
-rw-r--r--src/passes/RemoveUnusedModuleElements.cpp1
-rw-r--r--src/passes/SafeHeap.cpp1
-rw-r--r--src/passes/TrapMode.cpp13
-rw-r--r--src/shared-constants.h1
-rw-r--r--src/shell-interface.h2
-rw-r--r--src/tools/wasm-ctor-eval.cpp1
-rw-r--r--src/wasm-binary.h2
-rw-r--r--src/wasm/wasm-emscripten.cpp16
-rw-r--r--src/wasm/wasm-s-parser.cpp2
-rw-r--r--src/wasm/wasm-stack.cpp2
-rw-r--r--src/wasm/wasm.cpp1
24 files changed, 18 insertions, 92 deletions
diff --git a/src/asm_v_wasm.h b/src/asm_v_wasm.h
index d7e2e5b24..9b2ee7695 100644
--- a/src/asm_v_wasm.h
+++ b/src/asm_v_wasm.h
@@ -23,26 +23,12 @@
namespace wasm {
-Type asmToWasmType(AsmType asmType);
-
AsmType wasmToAsmType(Type type);
char getSig(Type type);
std::string getSig(Function* func);
std::string getSig(Type results, Type params);
-template<typename T,
- typename std::enable_if<std::is_base_of<Expression, T>::value>::type* =
- nullptr>
-std::string getSig(T* call) {
- std::string ret;
- ret += getSig(call->type);
- for (auto operand : call->operands) {
- ret += getSig(operand->type);
- }
- return ret;
-}
-
template<typename ListType>
std::string getSig(Type result, const ListType& operands) {
std::string ret;
@@ -63,9 +49,6 @@ std::string getSigFromStructs(Type result, const ListType& operands) {
return ret;
}
-// converts an f32 to an f64 if necessary
-Expression* ensureDouble(Expression* expr, MixedArena& allocator);
-
} // namespace wasm
#endif // wasm_asm_v_wasm_h
diff --git a/src/asmjs/asm_v_wasm.cpp b/src/asmjs/asm_v_wasm.cpp
index e7b4d6edd..84c738060 100644
--- a/src/asmjs/asm_v_wasm.cpp
+++ b/src/asmjs/asm_v_wasm.cpp
@@ -19,28 +19,6 @@
namespace wasm {
-Type asmToWasmType(AsmType asmType) {
- switch (asmType) {
- case ASM_INT:
- return Type::i32;
- case ASM_DOUBLE:
- return Type::f64;
- case ASM_FLOAT:
- return Type::f32;
- case ASM_INT64:
- return Type::i64;
- case ASM_NONE:
- return Type::none;
- case ASM_FLOAT32X4:
- case ASM_FLOAT64X2:
- case ASM_INT8X16:
- case ASM_INT16X8:
- case ASM_INT32X4:
- return Type::v128;
- }
- WASM_UNREACHABLE("invalid type");
-}
-
AsmType wasmToAsmType(Type type) {
TODO_SINGLE_COMPOUND(type);
switch (type.getBasic()) {
@@ -102,10 +80,6 @@ char getSig(Type type) {
WASM_UNREACHABLE("invalid type");
}
-std::string getSig(Function* func) {
- return getSig(func->sig.results, func->sig.params);
-}
-
std::string getSig(Type results, Type params) {
assert(!results.isTuple());
std::string sig;
@@ -116,16 +90,4 @@ std::string getSig(Type results, Type params) {
return sig;
}
-Expression* ensureDouble(Expression* expr, MixedArena& allocator) {
- if (expr->type == Type::f32) {
- auto conv = allocator.alloc<Unary>();
- conv->op = PromoteFloat32;
- conv->value = expr;
- conv->type = Type::f64;
- return conv;
- }
- assert(expr->type == Type::f64);
- return expr;
-}
-
} // namespace wasm
diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp
index 1f2190e57..2cb7d901c 100644
--- a/src/asmjs/shared-constants.cpp
+++ b/src/asmjs/shared-constants.cpp
@@ -18,7 +18,6 @@
namespace wasm {
-cashew::IString GLOBAL("global");
cashew::IString TOPMOST("topmost");
cashew::IString INT8ARRAY("Int8Array");
cashew::IString INT16ARRAY("Int16Array");
@@ -30,7 +29,6 @@ cashew::IString FLOAT32ARRAY("Float32Array");
cashew::IString FLOAT64ARRAY("Float64Array");
cashew::IString ARRAY_BUFFER("ArrayBuffer");
cashew::IString ASM_MODULE("asmModule");
-cashew::IString IMPOSSIBLE_CONTINUE("impossible-continue");
cashew::IString MATH("Math");
cashew::IString IMUL("imul");
cashew::IString CLZ32("clz32");
diff --git a/src/asmjs/shared-constants.h b/src/asmjs/shared-constants.h
index ecdf2d284..d458db684 100644
--- a/src/asmjs/shared-constants.h
+++ b/src/asmjs/shared-constants.h
@@ -21,7 +21,6 @@
namespace wasm {
-extern cashew::IString GLOBAL;
extern cashew::IString TOPMOST;
extern cashew::IString INT8ARRAY;
extern cashew::IString INT16ARRAY;
@@ -33,7 +32,6 @@ extern cashew::IString FLOAT32ARRAY;
extern cashew::IString FLOAT64ARRAY;
extern cashew::IString ARRAY_BUFFER;
extern cashew::IString ASM_MODULE;
-extern cashew::IString IMPOSSIBLE_CONTINUE;
extern cashew::IString MATH;
extern cashew::IString IMUL;
extern cashew::IString CLZ32;
diff --git a/src/parsing.h b/src/parsing.h
index bdc3e63b7..680f2f5cc 100644
--- a/src/parsing.h
+++ b/src/parsing.h
@@ -22,7 +22,6 @@
#include <sstream>
#include <string>
-#include "asmjs/shared-constants.h"
#include "mixed_arena.h"
#include "shared-constants.h"
#include "support/colors.h"
diff --git a/src/passes/Directize.cpp b/src/passes/Directize.cpp
index 037eca0da..0c1132b04 100644
--- a/src/passes/Directize.cpp
+++ b/src/passes/Directize.cpp
@@ -22,7 +22,6 @@
#include <unordered_map>
-#include "asm_v_wasm.h"
#include "ir/table-utils.h"
#include "ir/utils.h"
#include "pass.h"
diff --git a/src/passes/DuplicateImportElimination.cpp b/src/passes/DuplicateImportElimination.cpp
index 87126b139..b917c5fe8 100644
--- a/src/passes/DuplicateImportElimination.cpp
+++ b/src/passes/DuplicateImportElimination.cpp
@@ -20,7 +20,6 @@
// TODO: non-function imports too
//
-#include "asm_v_wasm.h"
#include "ir/import-utils.h"
#include "opt-utils.h"
#include "pass.h"
diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp
index 6f5e9d611..a164b4264 100644
--- a/src/passes/FuncCastEmulation.cpp
+++ b/src/passes/FuncCastEmulation.cpp
@@ -28,7 +28,6 @@
// params must be identical, i.e., the "ABI" must match.
//
-#include <asm_v_wasm.h>
#include <ir/literal-utils.h>
#include <pass.h>
#include <wasm-builder.h>
diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp
index c06176e53..a24d78213 100644
--- a/src/passes/I64ToI32Lowering.cpp
+++ b/src/passes/I64ToI32Lowering.cpp
@@ -22,7 +22,6 @@
//
#include "abi/js.h"
-#include "asmjs/shared-constants.h"
#include "emscripten-optimizer/istring.h"
#include "ir/flat.h"
#include "ir/iteration.h"
diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp
index 8803a7811..4b0db87ed 100644
--- a/src/passes/InstrumentLocals.cpp
+++ b/src/passes/InstrumentLocals.cpp
@@ -43,7 +43,6 @@
// )
// )
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "shared-constants.h"
#include <pass.h>
diff --git a/src/passes/InstrumentMemory.cpp b/src/passes/InstrumentMemory.cpp
index 9e4788456..6c81f8588 100644
--- a/src/passes/InstrumentMemory.cpp
+++ b/src/passes/InstrumentMemory.cpp
@@ -52,7 +52,6 @@
// )
// )
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "shared-constants.h"
#include <pass.h>
diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp
index 2f3e484ad..b000b0c38 100644
--- a/src/passes/LegalizeJSInterface.cpp
+++ b/src/passes/LegalizeJSInterface.cpp
@@ -30,7 +30,6 @@
// table even to a signature that is not legal.
//
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "ir/import-utils.h"
#include "ir/literal-utils.h"
diff --git a/src/passes/LogExecution.cpp b/src/passes/LogExecution.cpp
index ebc1c5636..b9b203d0b 100644
--- a/src/passes/LogExecution.cpp
+++ b/src/passes/LogExecution.cpp
@@ -28,7 +28,6 @@
// value.
//
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "shared-constants.h"
#include <pass.h>
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp
index 3795022c2..8c4523724 100644
--- a/src/passes/RemoveUnusedModuleElements.cpp
+++ b/src/passes/RemoveUnusedModuleElements.cpp
@@ -22,7 +22,6 @@
#include <memory>
-#include "asm_v_wasm.h"
#include "ir/module-utils.h"
#include "ir/utils.h"
#include "pass.h"
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp
index 0335c174e..ccfbfbf14 100644
--- a/src/passes/SafeHeap.cpp
+++ b/src/passes/SafeHeap.cpp
@@ -20,7 +20,6 @@
// top of sbrk()-addressible memory, and incorrect alignment notation.
//
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "ir/bits.h"
#include "ir/import-utils.h"
diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp
index f3cf3c63c..528357d4a 100644
--- a/src/passes/TrapMode.cpp
+++ b/src/passes/TrapMode.cpp
@@ -20,7 +20,6 @@
// generates a check and replaces the result with zero in that case.
//
-#include "asm_v_wasm.h"
#include "asmjs/shared-constants.h"
#include "ir/trapping.h"
#include "mixed_arena.h"
@@ -38,6 +37,18 @@ Name I64U_REM("i64u-rem");
Name I64S_DIV("i64s-div");
Name I64U_DIV("i64u-div");
+static Expression* ensureDouble(Expression* expr, MixedArena& allocator) {
+ if (expr->type == Type::f32) {
+ auto conv = allocator.alloc<Unary>();
+ conv->op = PromoteFloat32;
+ conv->value = expr;
+ conv->type = Type::f64;
+ return conv;
+ }
+ assert(expr->type == Type::f64);
+ return expr;
+}
+
Name getBinaryFuncName(Binary* curr) {
switch (curr->op) {
case RemSInt32:
diff --git a/src/shared-constants.h b/src/shared-constants.h
index 797f60227..e3c34e62f 100644
--- a/src/shared-constants.h
+++ b/src/shared-constants.h
@@ -39,6 +39,7 @@ extern Name PASSIVE;
extern Name EXPORT;
extern Name IMPORT;
extern Name TABLE;
+extern Name GLOBAL;
extern Name ELEM;
extern Name LOCAL;
extern Name TYPE;
diff --git a/src/shell-interface.h b/src/shell-interface.h
index 8fc1c362d..d82885ced 100644
--- a/src/shell-interface.h
+++ b/src/shell-interface.h
@@ -98,7 +98,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface {
void importGlobals(std::map<Name, Literals>& globals, Module& wasm) override {
// add spectest globals
ModuleUtils::iterImportedGlobals(wasm, [&](Global* import) {
- if (import->module == SPECTEST && import->base.startsWith(GLOBAL)) {
+ if (import->module == SPECTEST && import->base.startsWith("global_")) {
TODO_SINGLE_COMPOUND(import->type);
switch (import->type.getBasic()) {
case Type::i32:
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 50ba4404e..941e7961d 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -24,6 +24,7 @@
#include <memory>
+#include "asmjs/shared-constants.h"
#include "ir/global-utils.h"
#include "ir/import-utils.h"
#include "ir/literal-utils.h"
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 4f10ccfa1..1dba8573a 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -25,8 +25,6 @@
#include <ostream>
#include <type_traits>
-#include "asm_v_wasm.h"
-#include "asmjs/shared-constants.h"
#include "ir/import-utils.h"
#include "ir/module-utils.h"
#include "parsing.h"
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp
index 9f63d32dd..19498300f 100644
--- a/src/wasm/wasm-emscripten.cpp
+++ b/src/wasm/wasm-emscripten.cpp
@@ -227,7 +227,6 @@ private:
void createAsmConst(uint32_t id, std::string code, Signature sig, Name name);
Signature asmConstSig(Signature baseSig);
Name nameForImportWithSig(Signature sig, Proxying proxy);
- void queueImport(Name importName, Signature baseSig);
void addImports();
Proxying proxyType(Name name);
@@ -342,21 +341,6 @@ Signature AsmConstWalker::asmConstSig(Signature baseSig) {
baseSig.results);
}
-Name AsmConstWalker::nameForImportWithSig(Signature sig, Proxying proxy) {
- std::string fixedTarget = EM_ASM_PREFIX.str + std::string("_") +
- proxyingSuffix(proxy) +
- getSig(sig.results, sig.params);
- return Name(fixedTarget.c_str());
-}
-
-void AsmConstWalker::queueImport(Name importName, Signature baseSig) {
- auto import = new Function;
- import->name = import->base = importName;
- import->module = ENV;
- import->sig = baseSig;
- queuedImports.push_back(std::unique_ptr<Function>(import));
-}
-
void AsmConstWalker::addImports() {
for (auto& import : queuedImports) {
wasm.addFunction(import.release());
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index f28ea9f18..6c552781b 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -20,8 +20,6 @@
#include <cmath>
#include <limits>
-#include "asm_v_wasm.h"
-#include "asmjs/shared-constants.h"
#include "ir/branch-utils.h"
#include "shared-constants.h"
#include "wasm-binary.h"
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 7139eb502..c8a4f7a90 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -20,6 +20,8 @@
namespace wasm {
+static Name IMPOSSIBLE_CONTINUE("impossible-continue");
+
void BinaryInstWriter::emitResultType(Type type) {
if (type == Type::unreachable) {
o << binaryType(Type::none);
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 215928793..bb578819b 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -59,6 +59,7 @@ Name SET_TEMP_RET0("setTempRet0");
Name NEW_SIZE("newSize");
Name MODULE("module");
Name START("start");
+Name GLOBAL("global");
Name FUNC("func");
Name PARAM("param");
Name RESULT("result");