summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/asmjs/shared-constants.cpp2
-rw-r--r--src/asmjs/shared-constants.h2
-rw-r--r--src/tools/wasm-ctor-eval.cpp16
3 files changed, 12 insertions, 8 deletions
diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp
index 32ddb6c2c..0cf3668b1 100644
--- a/src/asmjs/shared-constants.cpp
+++ b/src/asmjs/shared-constants.cpp
@@ -67,6 +67,8 @@ cashew::IString GLOBAL("global"),
ALMOST_ASM("almost asm"),
BUFFER("buffer"),
ENV("env"),
+ STACKTOP("STACKTOP"),
+ STACK_MAX("STACK_MAX"),
INSTRUMENT("instrument"),
MATH_IMUL("Math_imul"),
MATH_ABS("Math_abs"),
diff --git a/src/asmjs/shared-constants.h b/src/asmjs/shared-constants.h
index c57b03ea5..b1f93336b 100644
--- a/src/asmjs/shared-constants.h
+++ b/src/asmjs/shared-constants.h
@@ -70,6 +70,8 @@ extern cashew::IString GLOBAL,
ALMOST_ASM,
BUFFER,
ENV,
+ STACKTOP,
+ STACK_MAX,
INSTRUMENT,
MATH_IMUL,
MATH_ABS,
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 38be8b7b4..53f33944e 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -131,9 +131,9 @@ public:
if (auto* get = global->init->dynCast<GetGlobal>()) {
auto name = get->name;
auto* import = wasm.getGlobal(name);
- if (import->module == Name("env") && (
- import->base == Name("STACKTOP") || // stack constants are special, we handle them
- import->base == Name("STACK_MAX")
+ if (import->module == Name(ENV) && (
+ import->base == STACKTOP || // stack constants are special, we handle them
+ import->base == STACK_MAX
)) {
return; // this is fine
}
@@ -175,15 +175,15 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface {
void importGlobals(EvallingGlobalManager& globals, Module& wasm_) override {
// fill usable values for stack imports, and globals initialized to them
ImportInfo imports(wasm_);
- if (auto* stackTop = imports.getImportedGlobal("env", "STACKTOP")) {
+ if (auto* stackTop = imports.getImportedGlobal(ENV, STACKTOP)) {
globals[stackTop->name] = Literal(int32_t(STACK_START));
- if (auto* stackTop = GlobalUtils::getGlobalInitializedToImport(wasm_, "env", "STACKTOP")) {
+ if (auto* stackTop = GlobalUtils::getGlobalInitializedToImport(wasm_, ENV, STACKTOP)) {
globals[stackTop->name] = Literal(int32_t(STACK_START));
}
}
- if (auto* stackMax = imports.getImportedGlobal("env", "STACK_MAX")) {
+ if (auto* stackMax = imports.getImportedGlobal(ENV, STACK_MAX)) {
globals[stackMax->name] = Literal(int32_t(STACK_START));
- if (auto* stackMax = GlobalUtils::getGlobalInitializedToImport(wasm_, "env", "STACK_MAX")) {
+ if (auto* stackMax = GlobalUtils::getGlobalInitializedToImport(wasm_, ENV, STACK_MAX)) {
globals[stackMax->name] = Literal(int32_t(STACK_START));
}
}
@@ -202,7 +202,7 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface {
Literal callImport(Function* import, LiteralList& arguments) override {
std::string extra;
- if (import->module == "env" && import->base == "___cxa_atexit") {
+ if (import->module == ENV && import->base == "___cxa_atexit") {
extra = "\nrecommendation: build with -s NO_EXIT_RUNTIME=1 so that calls to atexit are not emitted";
}
throw FailToEvalException(std::string("call import: ") + import->module.str + "." + import->base.str + extra);