diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 16 | ||||
-rw-r--r-- | src/tools/asm2wasm.cpp | 4 | ||||
-rw-r--r-- | src/tools/wasm-merge.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 4 |
4 files changed, 14 insertions, 14 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index c0508f8ae..ebd740841 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -777,9 +777,9 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // Import memory offset, if not already there { auto* import = new Global; - import->name = "memoryBase"; + import->name = MEMORY_BASE; import->module = "env"; - import->base = "memoryBase"; + import->base = MEMORY_BASE; import->type = i32; wasm.addGlobal(import); } @@ -787,9 +787,9 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // Import table offset, if not already there { auto* import = new Global; - import->name = "tableBase"; + import->name = TABLE_BASE; import->module = "env"; - import->base = "tableBase"; + import->base = TABLE_BASE; import->type = i32; wasm.addGlobal(import); } @@ -911,9 +911,9 @@ void Asm2WasmBuilder::processAsm(Ref ast) { import->base = base; import->type = type; mappedGlobals.emplace(name, type); - // tableBase and memoryBase are used as segment/element offsets, and must be constant; + // __table_base and __memory_base are used as segment/element offsets, and must be constant; // otherwise, an asm.js import of a constant is mutable, e.g. STACKTOP - if (name != "tableBase" && name != "memoryBase") { + if (name != TABLE_BASE && name != MEMORY_BASE) { // we need imported globals to be mutable, but wasm doesn't support that yet, so we must // import an immutable and create a mutable global initialized to its value import->name = Name(std::string(import->name.str) + "$asm2wasm$import"); @@ -926,7 +926,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { )); } } - if ((name == "tableBase" || name == "memoryBase") && + if ((name == TABLE_BASE || name == MEMORY_BASE) && wasm.getGlobalOrNull(import->base)) { return; } @@ -1093,7 +1093,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // index 0 in each table is the null func, and each other index should only have one // non-null func. However, that breaks down when function pointer casts are emulated. if (wasm.table.segments.size() == 0) { - wasm.table.segments.emplace_back(builder.makeGetGlobal(Name("tableBase"), i32)); + wasm.table.segments.emplace_back(builder.makeGetGlobal(Name(TABLE_BASE), i32)); } auto& segment = wasm.table.segments[0]; functionTableStarts[name] = segment.data.size(); // this table starts here diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp index cc9464434..d5e5827c5 100644 --- a/src/tools/asm2wasm.cpp +++ b/src/tools/asm2wasm.cpp @@ -60,7 +60,7 @@ int main(int argc, const char *argv[]) { [](Options *o, const std::string& argument) { o->extra["mem init"] = argument; }) - .add("--mem-base", "-mb", "Set the location to write the memory initialization (--mem-init) file (GLOBAL_BASE in emscripten). If not provided, the memoryBase global import is used.", Options::Arguments::One, + .add("--mem-base", "-mb", "Set the location to write the memory initialization (--mem-init) file (GLOBAL_BASE in emscripten). If not provided, the __memory_base global import is used.", Options::Arguments::One, [](Options *o, const std::string& argument) { o->extra["mem base"] = argument; }) @@ -173,7 +173,7 @@ int main(int argc, const char *argv[]) { Expression* init; const auto &memBase = options.extra.find("mem base"); if (memBase == options.extra.end()) { - init = Builder(wasm).makeGetGlobal(Name("memoryBase"), i32); + init = Builder(wasm).makeGetGlobal(MEMORY_BASE, i32); } else { init = Builder(wasm).makeConst(Literal(int32_t(atoi(memBase->second.c_str())))); } diff --git a/src/tools/wasm-merge.cpp b/src/tools/wasm-merge.cpp index 70611e269..52f682e16 100644 --- a/src/tools/wasm-merge.cpp +++ b/src/tools/wasm-merge.cpp @@ -580,12 +580,12 @@ int main(int argc, const char* argv[]) { .add("--emit-text", "-S", "Emit text instead of binary for the output file", Options::Arguments::Zero, [&](Options *o, const std::string& argument) { emitBinary = false; }) - .add("--finalize-memory-base", "-fmb", "Finalize the env.memoryBase import", + .add("--finalize-memory-base", "-fmb", "Finalize the env.__memory_base import", Options::Arguments::One, [&](Options* o, const std::string& argument) { finalizeMemoryBase = atoi(argument.c_str()); }) - .add("--finalize-table-base", "-ftb", "Finalize the env.tableBase import", + .add("--finalize-table-base", "-ftb", "Finalize the env.__table_base import", Options::Arguments::One, [&](Options* o, const std::string& argument) { finalizeTableBase = atoi(argument.c_str()); diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index ad4d6343a..72fc3b202 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -35,8 +35,8 @@ const char* Dylink = "dylink"; } Name GROW_WASM_MEMORY("__growWasmMemory"), - MEMORY_BASE("memoryBase"), - TABLE_BASE("tableBase"), + MEMORY_BASE("__memory_base"), + TABLE_BASE("__table_base"), NEW_SIZE("newSize"), MODULE("module"), START("start"), |