diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-19 09:49:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:03 -0700 |
commit | 266e922cddf0a5c78ed22f046eeebc053a9305c0 (patch) | |
tree | 2dec707b00304b1a6c888efb8f2c1b9a19ce38f3 | |
parent | 9660c200eff60c10266a85aae0637b495c4cba39 (diff) | |
download | binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.tar.gz binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.tar.bz2 binaryen-266e922cddf0a5c78ed22f046eeebc053a9305c0.zip |
use globals in asm2wasm
31 files changed, 1582 insertions, 2906 deletions
@@ -701,7 +701,7 @@ if has_emcc: elif method == 'interpret-s-expr': os.unlink('a.wasm.asm.js') # we should not need the .asm.js if not success: - os.unlink('a.wasm.wast.mappedGlobals') + os.unlink('a.wasm.wast') elif method == 'asmjs': os.unlink('a.wasm.wast') # we should not need the .wast break_cashew() # we don't use cashew, so ok to break it diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 48c52080d..a85fd4676 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -143,15 +143,13 @@ class Asm2WasmBuilder { // globals - unsigned nextGlobal; // next place to put a global - unsigned maxGlobal; // highest address we can put a global struct MappedGlobal { - unsigned address; WasmType type; bool import; // if true, this is an import - we should read the value, not just set a zero IString module, base; - MappedGlobal() : address(0), type(none), import(false) {} - MappedGlobal(unsigned address, WasmType type, bool import, IString module, IString base) : address(address), type(type), import(import), module(module), base(base) {} + MappedGlobal() : type(none), import(false) {} + MappedGlobal(WasmType type) : type(type), import(false) {} + MappedGlobal(WasmType type, bool import, IString module, IString base) : type(type), import(import), module(module), base(base) {} }; // function table @@ -165,31 +163,20 @@ class Asm2WasmBuilder { public: std::map<IString, MappedGlobal> mappedGlobals; - // the global mapping info is not present in the output wasm. We need to save it on the side - // if we intend to load and run this module's wasm. - void serializeMappedGlobals(const char *filename) { - FILE *f = fopen(filename, "w"); - assert(f); - fprintf(f, "{\n"); - bool first = true; - for (auto& pair : mappedGlobals) { - auto name = pair.first; - auto& global = pair.second; - if (first) first = false; - else fprintf(f, ","); - fprintf(f, "\"%s\": { \"address\": %d, \"type\": %d, \"import\": %d, \"module\": \"%s\", \"base\": \"%s\" }\n", - name.str, global.address, global.type, global.import, global.module.str, global.base.str); - } - fprintf(f, "}"); - fclose(f); - } - private: - void allocateGlobal(IString name, WasmType type, bool import, IString module = IString(), IString base = IString()) { + void allocateGlobal(IString name, WasmType type) { assert(mappedGlobals.find(name) == mappedGlobals.end()); - mappedGlobals.emplace(name, MappedGlobal(nextGlobal, type, import, module, base)); - nextGlobal += 8; - assert(nextGlobal < maxGlobal); + mappedGlobals.emplace(name, MappedGlobal(type)); + auto global = new Global(); + global->name = name; + global->type = type; + Literal value; + if (type == i32) value = Literal(uint32_t(0)); + else if (type == f32) value = Literal(float(0)); + else if (type == f64) value = Literal(double(0)); + else WASM_UNREACHABLE(); + global->init = wasm.allocator.alloc<Const>()->set(value); + wasm.addGlobal(global); } struct View { @@ -278,8 +265,6 @@ public: : wasm(wasm), allocator(wasm.allocator), builder(wasm), - nextGlobal(8), - maxGlobal(1000), memoryGrowth(memoryGrowth), debug(debug), imprecise(imprecise), @@ -520,13 +505,13 @@ void Asm2WasmBuilder::processAsm(Ref ast) { type = WasmType::f64; } if (type != WasmType::none) { - // wasm has no imported constants, so allocate a global, and we need to write the value into that - allocateGlobal(name, type, true, import->module, import->base); - delete import; + import->kind = Import::Global; + import->globalType = type; + mappedGlobals.emplace(name, type); } else { import->kind = Import::Function; - wasm.addImport(import); } + wasm.addImport(import); }; IString Int8Array, Int16Array, Int32Array, UInt8Array, UInt16Array, UInt32Array, Float32Array, Float64Array; @@ -554,7 +539,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { if (value[0] == NUM) { // global int assert(value[1]->getNumber() == 0); - allocateGlobal(name, WasmType::i32, false); + allocateGlobal(name, WasmType::i32); } else if (value[0] == BINARY) { // int import assert(value[1] == OR && value[3][0] == NUM && value[3][1]->getNumber() == 0); @@ -567,14 +552,14 @@ void Asm2WasmBuilder::processAsm(Ref ast) { if (import[0] == NUM) { // global assert(import[1]->getNumber() == 0); - allocateGlobal(name, WasmType::f64, false); + allocateGlobal(name, WasmType::f64); } else { // import addImport(name, import, WasmType::f64); } } else if (value[0] == CALL) { assert(value[1][0] == NAME && value[1][1] == Math_fround && value[2][0][0] == NUM && value[2][0][1]->getNumber() == 0); - allocateGlobal(name, WasmType::f32, false); + allocateGlobal(name, WasmType::f32); } else if (value[0] == DOT) { // simple module.base import. can be a view, or a function. if (value[1][0] == NAME) { @@ -721,11 +706,9 @@ void Asm2WasmBuilder::processAsm(Ref ast) { if (optimize) { optimizingBuilder->finish(); - if (maxGlobal < 1024) { - PassRunner passRunner(&wasm); - passRunner.add("post-emscripten"); - passRunner.run(); - } + PassRunner passRunner(&wasm); + passRunner.add("post-emscripten"); + passRunner.run(); } // second pass. first, function imports @@ -733,6 +716,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { std::vector<IString> toErase; for (auto& import : wasm.imports) { + if (import->kind != Import::Function) continue; IString name = import->name; if (importedFunctionTypes.find(name) != importedFunctionTypes.end()) { // special math builtins @@ -1021,18 +1005,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->finalize(); return ret; } - // global var, do a store to memory + // global var assert(mappedGlobals.find(name) != mappedGlobals.end()); - MappedGlobal global = mappedGlobals[name]; - auto ret = allocator.alloc<Store>(); - ret->bytes = getWasmTypeSize(global.type); - ret->offset = 0; - ret->align = ret->bytes; - ret->ptr = builder.makeConst(Literal(int32_t(global.address))); - ret->value = process(ast[3]); - ret->valueType = global.type; - ret->finalize(); - return ret; + return builder.makeSetGlobal(name, process(ast[3])); } else if (ast[2][0] == SUB) { Ref target = ast[2]; assert(target[1][0] == NAME); @@ -1158,17 +1133,10 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } return call; } - // global var, do a load from memory + // global var assert(mappedGlobals.find(name) != mappedGlobals.end()); - MappedGlobal global = mappedGlobals[name]; - auto ret = allocator.alloc<Load>(); - ret->bytes = getWasmTypeSize(global.type); - ret->signed_ = true; // but doesn't matter - ret->offset = 0; - ret->align = ret->bytes; - ret->ptr = builder.makeConst(Literal(int32_t(global.address))); - ret->type = global.type; - return ret; + MappedGlobal& global = mappedGlobals[name]; + return builder.makeGetGlobal(name, global.type); } else if (what == SUB) { Ref target = ast[1]; assert(target[0] == NAME); diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index ae42ef175..1c207b3f3 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -123,26 +123,6 @@ function integrateWasmJS(Module) { f64: 4 }; - // wasm lacks globals, so asm2wasm maps them into locations in memory. that information cannot - // be present in the wasm output of asm2wasm, so we store it in a side file. If we load asm2wasm - // output, either generated ahead of time or on the client, we need to apply those mapped - // globals after loading the module. - function applyMappedGlobals(globalsFileBase) { - var mappedGlobals = JSON.parse(Module['read'](globalsFileBase + '.mappedGlobals')); - for (var name in mappedGlobals) { - var global = mappedGlobals[name]; - if (!global.import) continue; // non-imports are initialized to zero in the typed array anyhow, so nothing to do here - var value = lookupImport(global.module, global.base); - var address = global.address; - switch (global.type) { - case WasmTypes.i32: Module['HEAP32'][address >> 2] = value; break; - case WasmTypes.f32: Module['HEAPF32'][address >> 2] = value; break; - case WasmTypes.f64: Module['HEAPF64'][address >> 3] = value; break; - default: abort(); - } - } - } - function fixImports(imports) { if (!{{{ WASM_BACKEND }}}) return imports; var ret = {}; @@ -208,8 +188,6 @@ function integrateWasmJS(Module) { exports = instance.exports; mergeMemory(exports.memory); - applyMappedGlobals(wasmBinaryFile); - Module["usingWasm"] = true; return exports; @@ -271,12 +249,6 @@ function integrateWasmJS(Module) { Module['newBuffer'] = null; } - if (method == 'interpret-s-expr') { - applyMappedGlobals(wasmTextFile); - } else if (method == 'interpret-binary') { - applyMappedGlobals(wasmBinaryFile); - } - exports = wasmJS['asmExports']; return exports; diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index fcd155650..fe125234d 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -531,6 +531,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitImport(Import *curr) { printOpening(o, "import "); + printName(curr->name) << ' '; switch (curr->kind) { case Export::Function: break; case Export::Table: o << "table "; break; @@ -538,14 +539,13 @@ struct PrintSExpression : public Visitor<PrintSExpression> { case Export::Global: o << "global "; break; default: WASM_UNREACHABLE(); } - printName(curr->name) << ' '; printText(o, curr->module.str) << ' '; printText(o, curr->base.str); switch (curr->kind) { case Export::Function: if (curr->functionType) visitFunctionType(curr->functionType); break; case Export::Table: break; case Export::Memory: break; - case Export::Global: o << printWasmType(curr->globalType); break; + case Export::Global: o << ' ' << printWasmType(curr->globalType); break; default: WASM_UNREACHABLE(); } o << ')'; @@ -564,7 +564,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } void visitGlobal(Global *curr) { printOpening(o, "global "); - printName(curr->name) << ' ' << printWasmType(curr->type); + printName(curr->name) << ' ' << printWasmType(curr->type) << ' '; visit(curr->init); o << ')'; } diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index bb005e36c..150593713 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -50,6 +50,8 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum, Visitor<Vacuum>> case Expression::Id::LoadId: case Expression::Id::StoreId: case Expression::Id::ReturnId: + case Expression::Id::GetGlobalId: + case Expression::Id::SetGlobalId: case Expression::Id::HostId: case Expression::Id::UnreachableId: return curr; // always needed diff --git a/src/shell-interface.h b/src/shell-interface.h index f9afe21fb..ee9ff166a 100644 --- a/src/shell-interface.h +++ b/src/shell-interface.h @@ -90,11 +90,11 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { ShellExternalInterface() : memory() {} - void init(Module& wasm) override { + void init(Module& wasm, ModuleInstance& instance) override { memory.resize(wasm.memory.initial * wasm::Memory::kPageSize); // apply memory segments for (auto& segment : wasm.memory.segments) { - Address offset = ConstantExpressionRunner().visit(segment.offset).value.geti32(); + Address offset = ConstantExpressionRunner(instance.globals).visit(segment.offset).value.geti32(); assert(offset + segment.data.size() <= wasm.memory.initial * wasm::Memory::kPageSize); for (size_t i = 0; i != segment.data.size(); ++i) { memory.set(offset + i, segment.data[i]); @@ -103,7 +103,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { table.resize(wasm.table.initial); for (auto& segment : wasm.table.segments) { - Address offset = ConstantExpressionRunner().visit(segment.offset).value.geti32(); + Address offset = ConstantExpressionRunner(instance.globals).visit(segment.offset).value.geti32(); assert(offset + segment.data.size() <= wasm.table.initial); for (size_t i = 0; i != segment.data.size(); ++i) { table[offset + i] = segment.data[i]; @@ -111,6 +111,8 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { } } + void importGlobals(std::map<Name, Literal>& globals, Module& wasm) override {} + Literal callImport(Import *import, LiteralList& arguments) override { if (import->module == SPECTEST && import->base == PRINT) { for (auto argument : arguments) { diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp index 7f1a07d1d..beacc884c 100644 --- a/src/tools/asm2wasm.cpp +++ b/src/tools/asm2wasm.cpp @@ -42,7 +42,7 @@ int main(int argc, const char *argv[]) { }) .add("--mapped-globals", "-m", "Mapped globals", Options::Arguments::One, [](Options *o, const std::string &argument) { - o->extra["mapped globals"] = argument; + std::cerr << "warning: the --mapped-globals/-m option is deprecated (a mapped globals file is no longer needed as we use wasm globals)" << std::endl; }) .add("--total-memory", "-m", "Total memory size", Options::Arguments::One, [](Options *o, const std::string &argument) { @@ -62,10 +62,6 @@ int main(int argc, const char *argv[]) { }); options.parse(argc, argv); - const auto &mg_it = options.extra.find("mapped globals"); - const char *mappedGlobals = - mg_it == options.extra.end() ? nullptr : mg_it->second.c_str(); - const auto &tm_it = options.extra.find("total memory"); size_t totalMemory = tm_it == options.extra.end() ? 16 * 1024 * 1024 : atoi(tm_it->second.c_str()); @@ -99,11 +95,5 @@ int main(int argc, const char *argv[]) { Output output(options.extra["output"], Flags::Text, options.debug ? Flags::Debug : Flags::Release); WasmPrinter::printModule(&wasm, output.getStream()); - if (mappedGlobals) { - if (options.debug) - std::cerr << "serializing mapped globals..." << std::endl; - asm2wasm.serializeMappedGlobals(mappedGlobals); - } - if (options.debug) std::cerr << "done." << std::endl; } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index d6671be01..40671b082 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -741,7 +741,7 @@ public: return mappedImports[name]; } - std::map<Name, uint32_t> mappedFunctions; // name of the Function => index + std::map<Name, uint32_t> mappedFunctions; // name of the Function => index uint32_t getFunctionIndex(Name name) { if (!mappedFunctions.size()) { // Create name => index mapping. @@ -754,13 +754,20 @@ public: return mappedFunctions[name]; } - std::map<Name, uint32_t> mappedGlobals; // name of the Global => index + std::map<Name, uint32_t> mappedGlobals; // name of the Global => index. first imported globals, then internal globals uint32_t getGlobalIndex(Name name) { if (!mappedGlobals.size()) { // Create name => index mapping. + for (auto& import : wasm->imports) { + if (import->kind != Import::Global) continue; + assert(mappedGlobals.count(import->name) == 0); + auto index = mappedGlobals.size(); + mappedGlobals[import->name] = index; + } for (size_t i = 0; i < wasm->globals.size(); i++) { assert(mappedGlobals.count(wasm->globals[i]->name) == 0); - mappedGlobals[wasm->globals[i]->name] = i; + auto index = mappedGlobals.size(); + mappedGlobals[wasm->globals[i]->name] = index; } } assert(mappedGlobals.count(name)); @@ -1664,6 +1671,24 @@ public: return ret; } + std::map<Index, Name> mappedGlobals; // index of the Global => name. first imported globals, then internal globals + Name getGlobalName(Index index) { + if (!mappedGlobals.size()) { + // Create name => index mapping. + for (auto& import : wasm.imports) { + if (import->kind != Import::Global) continue; + auto index = mappedGlobals.size(); + mappedGlobals[index] = import->name; + } + for (size_t i = 0; i < wasm.globals.size(); i++) { + auto index = mappedGlobals.size(); + mappedGlobals[index] = wasm.globals[i]->name; + } + } + assert(mappedGlobals.count(index)); + return mappedGlobals[index]; + } + void processFunctions() { for (auto& func : functions) { wasm.addFunction(func); @@ -1680,7 +1705,7 @@ public: case Export::Function: curr->value = wasm.functions[iter.second]->name; break; case Export::Table: curr->value = Name::fromInt(0); break; case Export::Memory: curr->value = Name::fromInt(0); break; - case Export::Global: curr->value = wasm.globals[iter.second]->name; break; + case Export::Global: curr->value = getGlobalName(iter.second); break; default: WASM_UNREACHABLE(); } wasm.addExport(curr); @@ -1975,13 +2000,23 @@ public: void visitGetGlobal(GetGlobal *curr) { if (debug) std::cerr << "zz node: GetGlobal " << pos << std::endl; auto index = getU32LEB(); - curr->name = wasm.getGlobal(index)->name; - curr->type = wasm.getGlobal(index)->type; + curr->name = getGlobalName(index); + auto* global = wasm.checkGlobal(curr->name); + if (global) { + curr->type = global->type; + return; + } + auto* import = wasm.checkImport(curr->name); + if (import && import->kind == Import::Global) { + curr->type = import->globalType; + return; + } + throw ParseException("bad get_global"); } void visitSetGlobal(SetGlobal *curr) { if (debug) std::cerr << "zz node: SetGlobal" << std::endl; auto index = getU32LEB(); - curr->name = wasm.getGlobal(index)->name; + curr->name = getGlobalName(index); curr->value = popExpression(); } diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index db55cd143..292d6a521 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -485,14 +485,17 @@ public: // Execute an constant expression in a global init or memory offset class ConstantExpressionRunner : public ExpressionRunner<ConstantExpressionRunner> { + std::map<Name, Literal>& globals; public: + ConstantExpressionRunner(std::map<Name, Literal>& globals) : globals(globals) {} + Flow visitLoop(Loop* curr) { WASM_UNREACHABLE(); } Flow visitCall(Call* curr) { WASM_UNREACHABLE(); } Flow visitCallImport(CallImport* curr) { WASM_UNREACHABLE(); } Flow visitCallIndirect(CallIndirect* curr) { WASM_UNREACHABLE(); } Flow visitGetLocal(GetLocal *curr) { WASM_UNREACHABLE(); } Flow visitSetLocal(SetLocal *curr) { WASM_UNREACHABLE(); } - Flow visitGetGlobal(GetGlobal *curr) { WASM_UNREACHABLE(); } + Flow visitGetGlobal(GetGlobal *curr) { return Flow(globals[curr->name]); } Flow visitSetGlobal(SetGlobal *curr) { WASM_UNREACHABLE(); } Flow visitLoad(Load *curr) { WASM_UNREACHABLE(); } Flow visitStore(Store *curr) { WASM_UNREACHABLE(); } @@ -517,7 +520,8 @@ public: // an imported function or accessing memory. // struct ExternalInterface { - virtual void init(Module& wasm) {} + virtual void init(Module& wasm, ModuleInstance& instance) {} + virtual void importGlobals(std::map<Name, Literal>& globals, Module& wasm) = 0; virtual Literal callImport(Import* import, LiteralList& arguments) = 0; virtual Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) = 0; virtual Literal load(Load* load, Address addr) = 0; @@ -532,11 +536,17 @@ public: std::map<Name, Literal> globals; ModuleInstance(Module& wasm, ExternalInterface* externalInterface) : wasm(wasm), externalInterface(externalInterface) { + // import globals from the outside + externalInterface->importGlobals(globals, wasm); + // prepare memory memorySize = wasm.memory.initial; + // generate internal (non-imported) globals for (auto& global : wasm.globals) { - globals[global->name] = ConstantExpressionRunner().visit(global->init).value; + globals[global->name] = ConstantExpressionRunner(globals).visit(global->init).value; } - externalInterface->init(wasm); + // initialize the rest of the external interface + externalInterface->init(wasm, *this); + // run start, if present if (wasm.start.is()) { LiteralList arguments; callFunction(wasm.start, arguments); diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index 3c3c4eec7..fc27bc37a 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -81,21 +81,6 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) { if (wasmJSDebug) std::cerr << "wasming...\n"; asm2wasm = new Asm2WasmBuilder(*module, pre.memoryGrowth, debug, false /* TODO: support imprecise? */, false /* TODO: support optimizing? */); asm2wasm->processAsm(asmjs); - - if (wasmJSDebug) std::cerr << "mapping globals...\n"; - for (auto& pair : asm2wasm->mappedGlobals) { - auto name = pair.first; - auto& global = pair.second; - if (!global.import) continue; // non-imports are initialized to zero in the typed array anyhow, so nothing to do here - double value = EM_ASM_DOUBLE({ return Module['lookupImport'](Pointer_stringify($0), Pointer_stringify($1)) }, global.module.str, global.base.str); - uint32_t address = global.address; - switch (global.type) { - case i32: EM_ASM_({ Module['info'].parent['HEAP32'][$0 >> 2] = $1 }, address, value); break; - case f32: EM_ASM_({ Module['info'].parent['HEAPF32'][$0 >> 2] = $1 }, address, value); break; - case f64: EM_ASM_({ Module['info'].parent['HEAPF64'][$0 >> 3] = $1 }, address, value); break; - default: abort(); - } - } } void finalizeModule() { @@ -176,14 +161,14 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { var mod = Pointer_stringify($0); var base = Pointer_stringify($1); var name = Pointer_stringify($2); - assert(Module['lookupImport'](mod, base), 'checking import ' + name + ' = ' + mod + '.' + base); + assert(Module['lookupImport'](mod, base) !== undefined, 'checking import ' + name + ' = ' + mod + '.' + base); }, import->module.str, import->base.str, import->name.str); } if (wasmJSDebug) std::cerr << "creating instance...\n"; struct JSExternalInterface : ModuleInstance::ExternalInterface { - void init(Module& wasm) override { + void init(Module& wasm, ModuleInstance& instance) override { // create a new buffer here, just like native wasm support would. EM_ASM_({ Module['outside']['newBuffer'] = new ArrayBuffer($0); @@ -193,7 +178,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { var source = Module['HEAP8'].subarray($1, $1 + $2); var target = new Int8Array(Module['outside']['newBuffer']); target.set(source, $0); - }, ConstantExpressionRunner().visit(segment.offset).value.geti32(), &segment.data[0], segment.data.size()); + }, ConstantExpressionRunner(instance.globals).visit(segment.offset).value.geti32(), &segment.data[0], segment.data.size()); } // Table support is in a JS array. If the entry is a number, it's a function pointer. If not, it's a JS method to be called directly // TODO: make them all JS methods, wrapping a dynCall where necessary? @@ -201,7 +186,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { Module['outside']['wasmTable'] = new Array($0); }, wasm.table.initial); for (auto segment : wasm.table.segments) { - Address offset = ConstantExpressionRunner().visit(segment.offset).value.geti32(); + Address offset = ConstantExpressionRunner(instance.globals).visit(segment.offset).value.geti32(); assert(offset + segment.data.size() <= wasm.table.initial); for (size_t i = 0; i != segment.data.size(); ++i) { EM_ASM_({ @@ -238,6 +223,23 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { } } + void importGlobals(std::map<Name, Literal>& globals, Module& wasm) override { + for (auto& import : wasm.imports) { + if (import->kind == Import::Global) { + double ret = EM_ASM_DOUBLE({ + var mod = Pointer_stringify($0); + var base = Pointer_stringify($1); + var lookup = Module['lookupImport'](mod, base); + return lookup; + }, import->module.str, import->base.str); + + if (wasmJSDebug) std::cout << "calling importGlobal for " << import->name << " returning " << ret << '\n'; + + globals[import->name] = getResultFromJS(ret, import->globalType); + } + } + } + Literal callImport(Import *import, LiteralList& arguments) override { if (wasmJSDebug) std::cout << "calling import " << import->name.str << '\n'; prepareTempArgments(arguments); @@ -252,7 +254,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { if (wasmJSDebug) std::cout << "calling import returning " << ret << '\n'; - return getResultFromJS(ret, import->type->result); + return getResultFromJS(ret, import->functionType->result); } Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) override { diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 60cc21e26..65335c1be 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -949,9 +949,16 @@ private: auto ret = allocator.alloc<GetGlobal>(); ret->name = s[1]->str(); auto* global = wasm.checkGlobal(ret->name); - if (!global) throw ParseException("bad get_global name", s.line, s.col); - ret->type = global->type; - return ret; + if (global) { + ret->type = global->type; + return ret; + } + auto* import = wasm.checkImport(ret->name); + if (import && import->kind == Import::Global) { + ret->type = import->globalType; + return ret; + } + throw ParseException("bad get_global name", s.line, s.col); } Expression* makeSetGlobal(Element& s) { @@ -1434,7 +1441,7 @@ private: } else if (s[2]->str() == TABLE) { im->kind = Import::Table; } else if (s[2]->str() == GLOBAL) { - im->kind = Import::Table; + im->kind = Import::Global; } else { WASM_UNREACHABLE(); } diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index 1414e1782..695602121 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -7,6 +7,12 @@ (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort" (param i32)) (import $_pthread_cleanup_pop "env" "_pthread_cleanup_pop" (param i32)) (import $_pthread_self "env" "_pthread_self" (result i32)) @@ -42,6 +48,30 @@ (export "dynCall_iiii" $dynCall_iiii) (export "dynCall_vi" $dynCall_vi) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2) (func $_malloc (param $0 i32) (result i32) @@ -7841,16 +7871,11 @@ (local $17 i32) (local $18 i32) (set_local $11 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) @@ -8213,8 +8238,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $11) ) (get_local $16) @@ -8758,16 +8782,11 @@ (local $9 i32) (local $10 i32) (set_local $5 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -8901,8 +8920,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $5) ) (get_local $4) @@ -9423,16 +9441,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) @@ -9488,8 +9501,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -9636,16 +9648,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) @@ -9707,73 +9714,56 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $3) ) (func $copyTempDouble (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=7 (get_local $0) ) @@ -9783,16 +9773,11 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -9812,41 +9797,32 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $1) ) (get_local $0) ) (func $copyTempFloat (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) @@ -9888,26 +9864,18 @@ (func $stackAlloc (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -9929,17 +9897,13 @@ (func $setThrew (param $0 i32) (param $1 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $__THREW__) ) (block - (i32.store - (i32.const 40) + (set_global $__THREW__ (get_local $0) ) - (i32.store - (i32.const 48) + (set_global $threwValue (get_local $1) ) ) @@ -9983,12 +9947,10 @@ ) ) (func $establishStackSpace (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $1) ) ) @@ -10011,14 +9973,12 @@ (i32.const 0) ) (func $stackRestore (param $0 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) ) (func $setTempRet0 (param $0 i32) - (i32.store - (i32.const 160) + (set_global $tempRet0 (get_local $0) ) ) @@ -10035,9 +9995,7 @@ (i32.const 0) ) (func $getTempRet0 (result i32) - (i32.load - (i32.const 160) - ) + (get_global $tempRet0) ) (func $_main (result i32) (drop @@ -10048,9 +10006,7 @@ (i32.const 0) ) (func $stackSave (result i32) - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (func $b2 (param $0 i32) (call_import $abort diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise index 769fc3dd6..509e77491 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise +++ b/test/emcc_O2_hello_world.fromasm.imprecise @@ -7,6 +7,12 @@ (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort" (param i32)) (import $_pthread_cleanup_pop "env" "_pthread_cleanup_pop" (param i32)) (import $_pthread_self "env" "_pthread_self" (result i32)) @@ -41,6 +47,30 @@ (export "dynCall_iiii" $dynCall_iiii) (export "dynCall_vi" $dynCall_vi) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2) (func $_malloc (param $0 i32) (result i32) @@ -7840,16 +7870,11 @@ (local $17 i32) (local $18 i32) (set_local $11 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) @@ -8212,8 +8237,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $11) ) (get_local $16) @@ -8757,16 +8781,11 @@ (local $9 i32) (local $10 i32) (set_local $5 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -8900,8 +8919,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $5) ) (get_local $4) @@ -9422,16 +9440,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) @@ -9487,8 +9500,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -9635,16 +9647,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) @@ -9706,73 +9713,56 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $3) ) (func $copyTempDouble (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=7 (get_local $0) ) @@ -9782,16 +9772,11 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -9811,41 +9796,32 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $1) ) (get_local $0) ) (func $copyTempFloat (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) @@ -9887,26 +9863,18 @@ (func $stackAlloc (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -9928,17 +9896,13 @@ (func $setThrew (param $0 i32) (param $1 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $__THREW__) ) (block - (i32.store - (i32.const 40) + (set_global $__THREW__ (get_local $0) ) - (i32.store - (i32.const 48) + (set_global $threwValue (get_local $1) ) ) @@ -9982,12 +9946,10 @@ ) ) (func $establishStackSpace (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $1) ) ) @@ -10010,14 +9972,12 @@ (i32.const 0) ) (func $stackRestore (param $0 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) ) (func $setTempRet0 (param $0 i32) - (i32.store - (i32.const 160) + (set_global $tempRet0 (get_local $0) ) ) @@ -10034,9 +9994,7 @@ (i32.const 0) ) (func $getTempRet0 (result i32) - (i32.load - (i32.const 160) - ) + (get_global $tempRet0) ) (func $_main (result i32) (drop @@ -10047,9 +10005,7 @@ (i32.const 0) ) (func $stackSave (result i32) - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (func $b2 (param $0 i32) (call_import $abort diff --git a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts index 79748fc64..d9be3c6ae 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts +++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts @@ -7,6 +7,12 @@ (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort" (param i32)) (import $_pthread_cleanup_pop "env" "_pthread_cleanup_pop" (param i32)) (import $_pthread_self "env" "_pthread_self" (result i32)) @@ -41,6 +47,30 @@ (export "dynCall_iiii" $dynCall_iiii) (export "dynCall_vi" $dynCall_vi) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2) (func $_malloc (param $i1 i32) (result i32) @@ -9229,16 +9259,11 @@ (local $i23 i32) (local $i24 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) @@ -9669,8 +9694,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -10349,16 +10373,11 @@ (local $i10 i32) (local $i11 i32) (set_local $i3 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -10513,8 +10532,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i3) ) (return @@ -11123,16 +11141,11 @@ (local $i6 i32) (local $i7 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) @@ -11207,8 +11220,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -11409,16 +11421,11 @@ (local $i4 i32) (local $i5 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) @@ -11499,8 +11506,7 @@ (get_local $i3) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -11509,18 +11515,14 @@ ) (func $copyTempDouble (param $i1 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $i1) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -11532,9 +11534,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -11546,9 +11546,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -11560,9 +11558,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (i32.load8_s @@ -11574,9 +11570,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 5) ) (i32.load8_s @@ -11588,9 +11582,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 6) ) (i32.load8_s @@ -11602,9 +11594,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 7) ) (i32.load8_s @@ -11619,16 +11609,11 @@ (local $i2 i32) (local $i3 i32) (set_local $i2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -11652,8 +11637,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i2) ) (return @@ -11662,18 +11646,14 @@ ) (func $copyTempFloat (param $i1 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $i1) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -11685,9 +11665,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -11699,9 +11677,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -11758,26 +11734,18 @@ (func $stackAlloc (param $i1 i32) (result i32) (local $i2 i32) (set_local $i2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $i1) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -11814,17 +11782,13 @@ (func $setThrew (param $i1 i32) (param $i2 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $__THREW__) ) (block - (i32.store - (i32.const 40) + (set_global $__THREW__ (get_local $i1) ) - (i32.store - (i32.const 48) + (set_global $threwValue (get_local $i2) ) ) @@ -11876,12 +11840,10 @@ (return) ) (func $establishStackSpace (param $i1 i32) (param $i2 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i1) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $i2) ) ) @@ -11906,14 +11868,12 @@ ) ) (func $stackRestore (param $i1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i1) ) ) (func $setTempRet0 (param $i1 i32) - (i32.store - (i32.const 160) + (set_global $tempRet0 (get_local $i1) ) ) @@ -11935,9 +11895,7 @@ ) (func $getTempRet0 (result i32) (return - (i32.load - (i32.const 160) - ) + (get_global $tempRet0) ) ) (func $_main (result i32) @@ -11952,9 +11910,7 @@ ) (func $stackSave (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) ) (func $b2 (param $i1 i32) diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts index 907460e39..37e32d83b 100644 --- a/test/emcc_O2_hello_world.fromasm.no-opts +++ b/test/emcc_O2_hello_world.fromasm.no-opts @@ -7,6 +7,12 @@ (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort" (param i32)) (import $_pthread_cleanup_pop "env" "_pthread_cleanup_pop" (param i32)) (import $_pthread_self "env" "_pthread_self" (result i32)) @@ -42,6 +48,30 @@ (export "dynCall_iiii" $dynCall_iiii) (export "dynCall_vi" $dynCall_vi) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2) (func $_malloc (param $i1 i32) (result i32) @@ -9230,16 +9260,11 @@ (local $i23 i32) (local $i24 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) @@ -9670,8 +9695,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -10350,16 +10374,11 @@ (local $i10 i32) (local $i11 i32) (set_local $i3 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -10514,8 +10533,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i3) ) (return @@ -11124,16 +11142,11 @@ (local $i6 i32) (local $i7 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) @@ -11208,8 +11221,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -11410,16 +11422,11 @@ (local $i4 i32) (local $i5 i32) (set_local $i4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) @@ -11500,8 +11507,7 @@ (get_local $i3) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i4) ) (return @@ -11510,18 +11516,14 @@ ) (func $copyTempDouble (param $i1 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $i1) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -11533,9 +11535,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -11547,9 +11547,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -11561,9 +11559,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (i32.load8_s @@ -11575,9 +11571,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 5) ) (i32.load8_s @@ -11589,9 +11583,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 6) ) (i32.load8_s @@ -11603,9 +11595,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 7) ) (i32.load8_s @@ -11620,16 +11610,11 @@ (local $i2 i32) (local $i3 i32) (set_local $i2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -11653,8 +11638,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i2) ) (return @@ -11663,18 +11647,14 @@ ) (func $copyTempFloat (param $i1 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $i1) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -11686,9 +11666,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -11700,9 +11678,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -11759,26 +11735,18 @@ (func $stackAlloc (param $i1 i32) (result i32) (local $i2 i32) (set_local $i2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $i1) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -11815,17 +11783,13 @@ (func $setThrew (param $i1 i32) (param $i2 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $__THREW__) ) (block - (i32.store - (i32.const 40) + (set_global $__THREW__ (get_local $i1) ) - (i32.store - (i32.const 48) + (set_global $threwValue (get_local $i2) ) ) @@ -11877,12 +11841,10 @@ (return) ) (func $establishStackSpace (param $i1 i32) (param $i2 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i1) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $i2) ) ) @@ -11907,14 +11869,12 @@ ) ) (func $stackRestore (param $i1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $i1) ) ) (func $setTempRet0 (param $i1 i32) - (i32.store - (i32.const 160) + (set_global $tempRet0 (get_local $i1) ) ) @@ -11936,9 +11896,7 @@ ) (func $getTempRet0 (result i32) (return - (i32.load - (i32.const 160) - ) + (get_global $tempRet0) ) ) (func $_main (result i32) @@ -11953,9 +11911,7 @@ ) (func $stackSave (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) ) (func $b2 (param $i1 i32) diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 6154be66d..c0b245dd9 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -8,6 +8,13 @@ (type $FUNCSIG$v (func)) (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $cttz_i8 global "env" "cttz_i8" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort") (import $nullFunc_ii "env" "nullFunc_ii" (param i32)) (import $nullFunc_iiii "env" "nullFunc_iiii" (param i32)) @@ -55,31 +62,47 @@ (export "dynCall_vi" $dynCall_vi) (export "___udivmoddi4" $___udivmoddi4) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2) (func $stackAlloc (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -87,53 +110,40 @@ ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) (get_local $1) ) (func $stackSave (result i32) - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (func $stackRestore (param $0 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) ) (func $establishStackSpace (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $1) ) ) (func $setThrew (param $0 i32) (param $1 i32) (if (i32.eq - (i32.load - (i32.const 48) - ) + (get_global $__THREW__) (i32.const 0) ) (block - (i32.store - (i32.const 48) + (set_global $__THREW__ (get_local $0) ) - (i32.store - (i32.const 56) + (set_global $threwValue (get_local $1) ) ) @@ -141,33 +151,25 @@ ) (func $copyTempFloat (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) @@ -175,105 +177,77 @@ ) (func $copyTempDouble (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=7 (get_local $0) ) ) ) (func $setTempRet0 (param $0 i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $0) ) ) (func $getTempRet0 (result i32) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (func $_main (result i32) (local $0 i32) (set_local $0 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -283,8 +257,7 @@ (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) (i32.const 0) @@ -294,25 +267,19 @@ (local $3 i32) (local $4 i32) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $0) ) (set_local $2 (call $_bitshift64Lshr (tee_local $3 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (tee_local $4 (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (i32.const 52) @@ -377,15 +344,11 @@ ) ) (i32.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $3) ) (i32.store offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.or (i32.and (get_local $4) @@ -395,9 +358,7 @@ ) ) (f64.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) ) @@ -580,27 +541,18 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -620,8 +572,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $1) ) (get_local $0) @@ -631,27 +582,18 @@ (local $4 i32) (local $5 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -715,8 +657,7 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -725,27 +666,18 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -801,8 +733,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -967,27 +898,18 @@ (local $2 i32) (local $3 i32) (set_local $2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1006,8 +928,7 @@ (get_local $3) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $2) ) (get_local $0) @@ -1035,27 +956,18 @@ (local $16 i32) (local $17 i32) (set_local $8 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1410,8 +1322,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $8) ) (get_local $14) @@ -1430,27 +1341,18 @@ (local $13 i32) (local $14 i32) (set_local $3 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 224) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1737,8 +1639,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $3) ) (get_local $0) @@ -2967,27 +2868,18 @@ (local $82 i32) (local $83 i32) (set_local $31 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 624) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -4681,9 +4573,7 @@ ) (i32.eq (tee_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 0) ) @@ -4788,9 +4678,7 @@ ) ) (set_local $5 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.store (tee_local $33 @@ -5031,18 +4919,14 @@ (i32.const 0) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $14) ) (set_local $51 (if (i32.lt_s (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) (i32.const 0) ) @@ -5093,9 +4977,7 @@ ) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $14) ) (set_local $20 @@ -5109,9 +4991,7 @@ (tee_local $1 (i32.and (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) (i32.const 2146435072) ) @@ -5764,17 +5644,13 @@ (i32.const 0) (get_local $11) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $5) (i32.const 0) ) ) (tee_local $7 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 1000000000) (i32.const 0) @@ -7919,9 +7795,7 @@ ) (i32.eq (tee_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 0) ) @@ -8706,8 +8580,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $31) ) (get_local $24) @@ -9180,9 +9053,7 @@ ) ) (set_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (if (i32.or @@ -9295,27 +9166,18 @@ (local $6 i32) (local $7 i32) (set_local $7 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 256) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -9462,8 +9324,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $7) ) ) @@ -17563,8 +17424,7 @@ (nop) ) (func $_i64Subtract (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.sub (i32.sub (get_local $1) @@ -17582,8 +17442,7 @@ ) ) (func $_i64Add (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (get_local $1) @@ -17747,8 +17606,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_u (get_local $1) (get_local $2) @@ -17780,8 +17638,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (i32.shr_u @@ -17799,8 +17656,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.shl (get_local $1) @@ -17838,8 +17694,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shl (get_local $0) (i32.sub @@ -18007,8 +17862,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_s (get_local $1) (get_local $2) @@ -18040,8 +17894,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (select (i32.const -1) (i32.const 0) @@ -18106,8 +17959,7 @@ (get_local $3) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (i32.shr_u @@ -18208,9 +18060,7 @@ (get_local $4) (get_local $0) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (call $_i64Subtract (i32.xor (tee_local $1 @@ -18266,9 +18116,7 @@ (get_local $1) (get_local $2) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (i32.const 0) ) (tee_local $1 @@ -18279,9 +18127,7 @@ ) ) (i32.xor - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (tee_local $0 (i32.xor (get_local $2) @@ -18298,16 +18144,11 @@ (local $5 i32) (local $6 i32) (set_local $6 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -18368,9 +18209,7 @@ (get_local $4) (get_local $5) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (call $_i64Subtract (i32.xor (tee_local $0 @@ -18426,9 +18265,7 @@ (get_local $0) (get_local $1) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (tee_local $0 (get_local $6) ) @@ -18453,16 +18290,12 @@ ) ) (set_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $6) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $1) ) (get_local $0) @@ -18475,8 +18308,7 @@ (get_local $2) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.add (i32.add @@ -18490,9 +18322,7 @@ ) ) (tee_local $0 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) ) (i32.and @@ -18521,16 +18351,11 @@ (func $___uremdi3 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -18545,12 +18370,10 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.load offset=4 (get_local $0) ) @@ -18625,8 +18448,7 @@ (get_local $5) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18639,8 +18461,7 @@ (get_local $2) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18662,8 +18483,7 @@ (i32.const 0) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18714,8 +18534,7 @@ (get_local $5) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18754,8 +18573,7 @@ (get_local $7) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18808,8 +18626,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18886,8 +18703,7 @@ (i32.const 0) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18915,8 +18731,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -19007,8 +18822,7 @@ (i32.const 0) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -19036,8 +18850,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -19208,8 +19021,7 @@ (i32.const 1) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (get_local $9) (i32.and @@ -19229,8 +19041,7 @@ ) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.const 0) (i32.shr_u @@ -19304,9 +19115,7 @@ ) ) (set_local $8 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $9 (get_local $0) @@ -19376,9 +19185,7 @@ (i32.or (i32.shr_s (tee_local $5 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 31) ) @@ -19436,9 +19243,7 @@ ) ) (set_local $13 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (if (i32.eq @@ -19497,8 +19302,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.or (i32.or diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index e51d8ce07..07ee8d33f 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -7,6 +7,13 @@ (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $cttz_i8 global "env" "cttz_i8" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort") (import $nullFunc_ii "env" "nullFunc_ii" (param i32)) (import $nullFunc_iiii "env" "nullFunc_iiii" (param i32)) @@ -49,31 +56,47 @@ (export "dynCall_vi" $dynCall_vi) (export "___udivmoddi4" $___udivmoddi4) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2) (func $stackAlloc (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -81,53 +104,40 @@ ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) (get_local $1) ) (func $stackSave (result i32) - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (func $stackRestore (param $0 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) ) (func $establishStackSpace (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $1) ) ) (func $setThrew (param $0 i32) (param $1 i32) (if (i32.eq - (i32.load - (i32.const 48) - ) + (get_global $__THREW__) (i32.const 0) ) (block - (i32.store - (i32.const 48) + (set_global $__THREW__ (get_local $0) ) - (i32.store - (i32.const 56) + (set_global $threwValue (get_local $1) ) ) @@ -135,33 +145,25 @@ ) (func $copyTempFloat (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) @@ -169,105 +171,77 @@ ) (func $copyTempDouble (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s offset=7 (get_local $0) ) ) ) (func $setTempRet0 (param $0 i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $0) ) ) (func $getTempRet0 (result i32) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (func $_main (result i32) (local $0 i32) (set_local $0 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -277,8 +251,7 @@ (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $0) ) (i32.const 0) @@ -288,25 +261,19 @@ (local $3 i32) (local $4 i32) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $0) ) (set_local $2 (call $_bitshift64Lshr (tee_local $3 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (tee_local $4 (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (i32.const 52) @@ -371,15 +338,11 @@ ) ) (i32.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $3) ) (i32.store offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.or (i32.and (get_local $4) @@ -389,9 +352,7 @@ ) ) (f64.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) ) @@ -574,27 +535,18 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -614,8 +566,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $1) ) (get_local $0) @@ -625,27 +576,18 @@ (local $4 i32) (local $5 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -709,8 +651,7 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -719,27 +660,18 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -795,8 +727,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) (get_local $0) @@ -961,27 +892,18 @@ (local $2 i32) (local $3 i32) (set_local $2 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1000,8 +922,7 @@ (get_local $3) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $2) ) (get_local $0) @@ -1029,27 +950,18 @@ (local $16 i32) (local $17 i32) (set_local $8 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1404,8 +1316,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $8) ) (get_local $14) @@ -1424,27 +1335,18 @@ (local $13 i32) (local $14 i32) (set_local $3 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 224) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1731,8 +1633,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $3) ) (get_local $0) @@ -2961,27 +2862,18 @@ (local $82 i32) (local $83 i32) (set_local $31 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 624) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -4675,9 +4567,7 @@ ) (i32.eq (tee_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 0) ) @@ -4782,9 +4672,7 @@ ) ) (set_local $5 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.store (tee_local $33 @@ -5025,18 +4913,14 @@ (i32.const 0) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $14) ) (set_local $51 (if (i32.lt_s (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) (i32.const 0) ) @@ -5087,9 +4971,7 @@ ) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $14) ) (set_local $20 @@ -5103,9 +4985,7 @@ (tee_local $1 (i32.and (i32.load offset=4 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) (i32.const 2146435072) ) @@ -5758,17 +5638,13 @@ (i32.const 0) (get_local $11) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $5) (i32.const 0) ) ) (tee_local $7 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 1000000000) (i32.const 0) @@ -7913,9 +7789,7 @@ ) (i32.eq (tee_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 0) ) @@ -8700,8 +8574,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $31) ) (get_local $24) @@ -9174,9 +9047,7 @@ ) ) (set_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (if (i32.or @@ -9289,27 +9160,18 @@ (local $6 i32) (local $7 i32) (set_local $7 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 256) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -9456,8 +9318,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $7) ) ) @@ -17557,8 +17418,7 @@ (nop) ) (func $_i64Subtract (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.sub (i32.sub (get_local $1) @@ -17576,8 +17436,7 @@ ) ) (func $_i64Add (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (get_local $1) @@ -17741,8 +17600,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_u (get_local $1) (get_local $2) @@ -17774,8 +17632,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (i32.shr_u @@ -17793,8 +17650,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.shl (get_local $1) @@ -17832,8 +17688,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shl (get_local $0) (i32.sub @@ -18001,8 +17856,7 @@ (i32.const 32) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_s (get_local $1) (get_local $2) @@ -18034,8 +17888,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (select (i32.const -1) (i32.const 0) @@ -18100,8 +17953,7 @@ (get_local $3) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (i32.shr_u @@ -18202,9 +18054,7 @@ (get_local $4) (get_local $0) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (call $_i64Subtract (i32.xor (tee_local $1 @@ -18260,9 +18110,7 @@ (get_local $1) (get_local $2) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (i32.const 0) ) (tee_local $1 @@ -18273,9 +18121,7 @@ ) ) (i32.xor - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (tee_local $0 (i32.xor (get_local $2) @@ -18292,16 +18138,11 @@ (local $5 i32) (local $6 i32) (set_local $6 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -18362,9 +18203,7 @@ (get_local $4) (get_local $5) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (call $_i64Subtract (i32.xor (tee_local $0 @@ -18420,9 +18259,7 @@ (get_local $0) (get_local $1) ) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (tee_local $0 (get_local $6) ) @@ -18447,16 +18284,12 @@ ) ) (set_local $1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $6) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $1) ) (get_local $0) @@ -18469,8 +18302,7 @@ (get_local $2) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.add (i32.add @@ -18484,9 +18316,7 @@ ) ) (tee_local $0 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) ) (i32.and @@ -18515,16 +18345,11 @@ (func $___uremdi3 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -18539,12 +18364,10 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $4) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.load offset=4 (get_local $0) ) @@ -18613,8 +18436,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18630,8 +18452,7 @@ (get_local $2) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18653,8 +18474,7 @@ (i32.const 0) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18699,8 +18519,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18736,8 +18555,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18793,8 +18611,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18871,8 +18688,7 @@ (i32.const 0) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18900,8 +18716,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -18992,8 +18807,7 @@ (i32.const 0) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -19021,8 +18835,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -19193,8 +19006,7 @@ (i32.const 1) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (get_local $9) (i32.and @@ -19214,8 +19026,7 @@ ) ) (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.const 0) (i32.shr_u @@ -19289,9 +19100,7 @@ ) ) (set_local $8 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $9 (get_local $0) @@ -19361,9 +19170,7 @@ (i32.or (i32.shr_s (tee_local $5 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.const 31) ) @@ -19421,9 +19228,7 @@ ) ) (set_local $13 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (if (i32.eq @@ -19482,8 +19287,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.or (i32.or diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts index 77f4b2a7f..4e174f6ee 100644 --- a/test/emcc_hello_world.fromasm.imprecise.no-opts +++ b/test/emcc_hello_world.fromasm.imprecise.no-opts @@ -7,6 +7,13 @@ (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $cttz_i8 global "env" "cttz_i8" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort") (import $nullFunc_ii "env" "nullFunc_ii" (param i32)) (import $nullFunc_iiii "env" "nullFunc_iiii" (param i32)) @@ -49,31 +56,47 @@ (export "dynCall_vi" $dynCall_vi) (export "___udivmoddi4" $___udivmoddi4) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2) (func $stackAlloc (param $size i32) (result i32) (local $ret i32) (set_local $ret - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $size) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -81,12 +104,8 @@ ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -96,42 +115,33 @@ ) (func $stackSave (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) ) (func $stackRestore (param $top i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $top) ) ) (func $establishStackSpace (param $stackBase i32) (param $stackMax i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $stackBase) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $stackMax) ) ) (func $setThrew (param $threw i32) (param $value i32) (if (i32.eq - (i32.load - (i32.const 48) - ) + (get_global $__THREW__) (i32.const 0) ) (block - (i32.store - (i32.const 48) + (set_global $__THREW__ (get_local $threw) ) - (i32.store - (i32.const 56) + (set_global $threwValue (get_local $value) ) ) @@ -139,18 +149,14 @@ ) (func $copyTempFloat (param $ptr i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $ptr) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -162,9 +168,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -176,9 +180,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -191,18 +193,14 @@ ) (func $copyTempDouble (param $ptr i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $ptr) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -214,9 +212,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -228,9 +224,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -242,9 +236,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (i32.load8_s @@ -256,9 +248,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 5) ) (i32.load8_s @@ -270,9 +260,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 6) ) (i32.load8_s @@ -284,9 +272,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 7) ) (i32.load8_s @@ -298,16 +284,13 @@ ) ) (func $setTempRet0 (param $value i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $value) ) ) (func $getTempRet0 (result i32) (return - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) ) (func $_main (result i32) @@ -316,27 +299,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -352,8 +326,7 @@ (get_local $$vararg_buffer) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -381,29 +354,21 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$x) ) (set_local $$0 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$1 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -416,9 +381,7 @@ ) ) (set_local $$3 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$conv (i32.and @@ -528,25 +491,19 @@ ) ) (i32.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$0) ) (i32.store (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (get_local $$6) ) (set_local $$7 (f64.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$retval$0 @@ -564,9 +521,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$call (call $_frexp @@ -601,9 +556,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$i$012 (i32.const 0) @@ -812,9 +765,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$0 (i32.load @@ -865,27 +816,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -918,8 +860,7 @@ (get_local $$call) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -944,27 +885,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1080,8 +1012,7 @@ (get_local $$len) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1105,27 +1036,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1232,8 +1154,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1280,9 +1201,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -1575,27 +1494,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1618,8 +1528,7 @@ (get_local $$ap) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1630,9 +1539,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (return (i32.const 0) @@ -1642,9 +1549,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (return) ) @@ -1721,27 +1626,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -2306,8 +2202,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -2363,27 +2258,18 @@ (local $sp i32) (local $stop i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 224) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -2782,8 +2668,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -2835,9 +2720,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$wend (i32.add @@ -3219,9 +3102,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$mode (i32.add @@ -3442,9 +3323,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -3832,9 +3711,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -3924,9 +3801,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$conv1 (i32.and @@ -4462,9 +4337,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.gt_u @@ -4525,9 +4398,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$wpos (i32.add @@ -4728,9 +4599,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$lockcount (i32.add @@ -5823,27 +5692,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 624) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -8426,9 +8286,7 @@ ) ) (set_local $$131 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$132 (i32.eq @@ -8605,9 +8463,7 @@ ) ) (set_local $$143 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$144 (get_local $$arg) @@ -8981,24 +8837,18 @@ (i32.const 0) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$181) ) (set_local $$182 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$183 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -9087,24 +8937,18 @@ ) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$y$addr$0$i) ) (set_local $$185 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$186 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -10129,9 +9973,7 @@ ) ) (set_local $$214 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$215 (call $_i64Add @@ -10142,9 +9984,7 @@ ) ) (set_local $$216 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$217 (call $___uremdi3 @@ -10155,9 +9995,7 @@ ) ) (set_local $$218 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.store (get_local $$d$0545$i) @@ -10172,9 +10010,7 @@ ) ) (set_local $$220 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$d$0$i (i32.add @@ -13466,9 +13302,7 @@ ) ) (set_local $$103 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$104 (i32.eq @@ -14602,8 +14436,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -14800,9 +14633,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.gt_u @@ -15953,9 +15784,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$2 (i32.gt_u @@ -16010,9 +15839,7 @@ ) ) (set_local $$10 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$11 (i32.or @@ -16045,9 +15872,7 @@ ) ) (set_local $$14 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$15 (i32.gt_u @@ -16244,27 +16069,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 256) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -16465,8 +16281,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return) @@ -17662,9 +17477,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.lt_u @@ -27467,9 +27280,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.eq @@ -30463,8 +30274,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $h) ) (get_local $l) @@ -30494,8 +30304,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $h) ) (get_local $l) @@ -30679,8 +30488,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_u (get_local $high) (get_local $bits) @@ -30706,8 +30514,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -30737,8 +30544,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.shl (get_local $high) @@ -30770,8 +30576,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shl (get_local $low) (i32.sub @@ -30966,8 +30771,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_s (get_local $high) (get_local $bits) @@ -30993,8 +30797,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (if (i32.lt_s (get_local $high) @@ -31072,8 +30875,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (i32.shr_u @@ -31233,9 +31035,7 @@ ) ) (set_local $$4$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$6$0 (call $_i64Subtract @@ -31268,9 +31068,7 @@ (get_local $$4$0) (get_local $$4$1) (get_local $$6$0) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (i32.const 0) ) ) @@ -31281,9 +31079,7 @@ (get_local $$7$0) ) (i32.xor - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $$7$1) ) (get_local $$7$0) @@ -31307,16 +31103,11 @@ (local $$10$1 i32) (local $__stackBase__ i32) (set_local $__stackBase__ - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -31428,9 +31219,7 @@ ) ) (set_local $$4$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$6$0 (call $_i64Subtract @@ -31451,9 +31240,7 @@ (get_local $$4$0) (get_local $$4$1) (get_local $$6$0) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $$rem) ) ) @@ -31479,18 +31266,14 @@ ) ) (set_local $$10$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $__stackBase__) ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$10$1) ) (get_local $$10$0) @@ -31516,9 +31299,7 @@ ) ) (set_local $$1$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$2 (i32.mul @@ -31528,8 +31309,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.add (i32.add @@ -31576,16 +31356,11 @@ (local $$rem i32) (local $__stackBase__ i32) (set_local $__stackBase__ - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -31601,14 +31376,12 @@ (get_local $$rem) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $__stackBase__) ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.load (i32.add (get_local $$rem) @@ -31753,8 +31526,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31775,8 +31547,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31809,8 +31580,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31869,8 +31639,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31917,8 +31686,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31988,8 +31756,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32075,8 +31842,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32115,8 +31881,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32222,8 +31987,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32262,8 +32026,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32464,8 +32227,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32504,8 +32266,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32569,9 +32330,7 @@ ) ) (set_local $$137$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$q_sroa_1_1198 (get_local $$q_sroa_1_1_ph) @@ -32650,9 +32409,7 @@ ) ) (set_local $$150$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$151$0 (i32.or @@ -32720,9 +32477,7 @@ (get_local $$154$0) ) (set_local $$r_sroa_1_4_extract_trunc - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$155 (i32.sub @@ -32867,8 +32622,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts index 4d2fb5e7a..41db5a7a1 100644 --- a/test/emcc_hello_world.fromasm.no-opts +++ b/test/emcc_hello_world.fromasm.no-opts @@ -8,6 +8,13 @@ (type $FUNCSIG$v (func)) (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) + (import $STACKTOP global "env" "STACKTOP" i32) + (import $STACK_MAX global "env" "STACK_MAX" i32) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $ABORT global "env" "ABORT" i32) + (import $cttz_i8 global "env" "cttz_i8" i32) + (import $nan global "global" "NaN" f64) + (import $inf global "global" "Infinity" f64) (import $abort "env" "abort") (import $nullFunc_ii "env" "nullFunc_ii" (param i32)) (import $nullFunc_iiii "env" "nullFunc_iiii" (param i32)) @@ -55,31 +62,47 @@ (export "dynCall_vi" $dynCall_vi) (export "___udivmoddi4" $___udivmoddi4) (export "memory" memory) + (global $__THREW__ i32 (i32.const 0)) + (global $threwValue i32 (i32.const 0)) + (global $setjmpId i32 (i32.const 0)) + (global $undef i32 (i32.const 0)) + (global $tempInt i32 (i32.const 0)) + (global $tempBigInt i32 (i32.const 0)) + (global $tempBigIntP i32 (i32.const 0)) + (global $tempBigIntS i32 (i32.const 0)) + (global $tempBigIntR f64 (f64.const 0)) + (global $tempBigIntI i32 (i32.const 0)) + (global $tempBigIntD i32 (i32.const 0)) + (global $tempValue i32 (i32.const 0)) + (global $tempDouble f64 (f64.const 0)) + (global $tempRet0 i32 (i32.const 0)) + (global $tempRet1 i32 (i32.const 0)) + (global $tempRet2 i32 (i32.const 0)) + (global $tempRet3 i32 (i32.const 0)) + (global $tempRet4 i32 (i32.const 0)) + (global $tempRet5 i32 (i32.const 0)) + (global $tempRet6 i32 (i32.const 0)) + (global $tempRet7 i32 (i32.const 0)) + (global $tempRet8 i32 (i32.const 0)) + (global $tempRet9 i32 (i32.const 0)) + (global $tempFloat f64 (f64.const 0)) (table 18 18 anyfunc) (elem (i32.const 0) $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2) (func $stackAlloc (param $size i32) (result i32) (local $ret i32) (set_local $ret - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (get_local $size) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 15) ) (i32.const -16) @@ -87,12 +110,8 @@ ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -102,42 +121,33 @@ ) (func $stackSave (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) ) (func $stackRestore (param $top i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $top) ) ) (func $establishStackSpace (param $stackBase i32) (param $stackMax i32) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $stackBase) ) - (i32.store - (i32.const 16) + (set_global $STACK_MAX (get_local $stackMax) ) ) (func $setThrew (param $threw i32) (param $value i32) (if (i32.eq - (i32.load - (i32.const 48) - ) + (get_global $__THREW__) (i32.const 0) ) (block - (i32.store - (i32.const 48) + (set_global $__THREW__ (get_local $threw) ) - (i32.store - (i32.const 56) + (set_global $threwValue (get_local $value) ) ) @@ -145,18 +155,14 @@ ) (func $copyTempFloat (param $ptr i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $ptr) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -168,9 +174,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -182,9 +186,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -197,18 +199,14 @@ ) (func $copyTempDouble (param $ptr i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.load8_s (get_local $ptr) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 1) ) (i32.load8_s @@ -220,9 +218,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 2) ) (i32.load8_s @@ -234,9 +230,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 3) ) (i32.load8_s @@ -248,9 +242,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (i32.load8_s @@ -262,9 +254,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 5) ) (i32.load8_s @@ -276,9 +266,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 6) ) (i32.load8_s @@ -290,9 +278,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 7) ) (i32.load8_s @@ -304,16 +290,13 @@ ) ) (func $setTempRet0 (param $value i32) - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $value) ) ) (func $getTempRet0 (result i32) (return - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) ) (func $_main (result i32) @@ -322,27 +305,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -358,8 +332,7 @@ (get_local $$vararg_buffer) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -387,29 +360,21 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$x) ) (set_local $$0 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$1 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -422,9 +387,7 @@ ) ) (set_local $$3 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$conv (i32.and @@ -534,25 +497,19 @@ ) ) (i32.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$0) ) (i32.store (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) (get_local $$6) ) (set_local $$7 (f64.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$retval$0 @@ -570,9 +527,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$call (call $_frexp @@ -607,9 +562,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$i$012 (i32.const 0) @@ -818,9 +771,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$0 (i32.load @@ -871,27 +822,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -924,8 +866,7 @@ (get_local $$call) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -950,27 +891,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 80) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1086,8 +1018,7 @@ (get_local $$len) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1111,27 +1042,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 32) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1238,8 +1160,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1286,9 +1207,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -1581,27 +1500,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -1624,8 +1534,7 @@ (get_local $$ap) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -1636,9 +1545,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (return (i32.const 0) @@ -1648,9 +1555,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (return) ) @@ -1727,27 +1632,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 48) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -2312,8 +2208,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -2369,27 +2264,18 @@ (local $sp i32) (local $stop i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 224) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -2788,8 +2674,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -2841,9 +2726,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$wend (i32.add @@ -3225,9 +3108,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$mode (i32.add @@ -3448,9 +3329,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -3838,9 +3717,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$tobool (i32.eq @@ -3930,9 +3807,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$conv1 (i32.and @@ -4468,9 +4343,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.gt_u @@ -4531,9 +4404,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$wpos (i32.add @@ -4734,9 +4605,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$lockcount (i32.add @@ -5829,27 +5698,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 624) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -8432,9 +8292,7 @@ ) ) (set_local $$131 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$132 (i32.eq @@ -8611,9 +8469,7 @@ ) ) (set_local $$143 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$144 (get_local $$arg) @@ -8987,24 +8843,18 @@ (i32.const 0) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$181) ) (set_local $$182 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$183 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -9093,24 +8943,18 @@ ) ) (f64.store - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (get_local $$y$addr$0$i) ) (set_local $$185 (i32.load - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) ) ) (set_local $$186 (i32.load (i32.add - (i32.load - (i32.const 24) - ) + (get_global $tempDoublePtr) (i32.const 4) ) ) @@ -10135,9 +9979,7 @@ ) ) (set_local $$214 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$215 (call $_i64Add @@ -10148,9 +9990,7 @@ ) ) (set_local $$216 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$217 (call $___uremdi3 @@ -10161,9 +10001,7 @@ ) ) (set_local $$218 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (i32.store (get_local $$d$0545$i) @@ -10178,9 +10016,7 @@ ) ) (set_local $$220 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$d$0$i (i32.add @@ -13472,9 +13308,7 @@ ) ) (set_local $$103 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$104 (i32.eq @@ -14608,8 +14442,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return @@ -14806,9 +14639,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.gt_u @@ -15959,9 +15790,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$2 (i32.gt_u @@ -16016,9 +15845,7 @@ ) ) (set_local $$10 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$11 (i32.or @@ -16051,9 +15878,7 @@ ) ) (set_local $$14 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$15 (i32.gt_u @@ -16250,27 +16075,18 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 256) ) ) (if (i32.ge_s - (i32.load - (i32.const 8) - ) - (i32.load - (i32.const 16) - ) + (get_global $STACKTOP) + (get_global $STACK_MAX) ) (call_import $abort) ) @@ -16471,8 +16287,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $sp) ) (return) @@ -17668,9 +17483,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.lt_u @@ -27473,9 +27286,7 @@ (local $label i32) (local $sp i32) (set_local $sp - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) (set_local $$cmp (i32.eq @@ -30469,8 +30280,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $h) ) (get_local $l) @@ -30500,8 +30310,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $h) ) (get_local $l) @@ -30685,8 +30494,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_u (get_local $high) (get_local $bits) @@ -30712,8 +30520,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.const 0) ) (return @@ -30743,8 +30550,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.shl (get_local $high) @@ -30776,8 +30582,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shl (get_local $low) (i32.sub @@ -30972,8 +30777,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.shr_s (get_local $high) (get_local $bits) @@ -30999,8 +30803,7 @@ ) ) ) - (i32.store - (i32.const 168) + (set_global $tempRet0 (if (i32.lt_s (get_local $high) @@ -31078,8 +30881,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.add (i32.add (i32.shr_u @@ -31239,9 +31041,7 @@ ) ) (set_local $$4$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$6$0 (call $_i64Subtract @@ -31274,9 +31074,7 @@ (get_local $$4$0) (get_local $$4$1) (get_local $$6$0) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (i32.const 0) ) ) @@ -31287,9 +31085,7 @@ (get_local $$7$0) ) (i32.xor - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $$7$1) ) (get_local $$7$0) @@ -31313,16 +31109,11 @@ (local $$10$1 i32) (local $__stackBase__ i32) (set_local $__stackBase__ - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -31434,9 +31225,7 @@ ) ) (set_local $$4$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$6$0 (call $_i64Subtract @@ -31457,9 +31246,7 @@ (get_local $$4$0) (get_local $$4$1) (get_local $$6$0) - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) (get_local $$rem) ) ) @@ -31485,18 +31272,14 @@ ) ) (set_local $$10$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $__stackBase__) ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$10$1) ) (get_local $$10$0) @@ -31522,9 +31305,7 @@ ) ) (set_local $$1$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$2 (i32.mul @@ -31534,8 +31315,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.or (i32.add (i32.add @@ -31582,16 +31362,11 @@ (local $$rem i32) (local $__stackBase__ i32) (set_local $__stackBase__ - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (i32.add - (i32.load - (i32.const 8) - ) + (get_global $STACKTOP) (i32.const 16) ) ) @@ -31607,14 +31382,12 @@ (get_local $$rem) ) ) - (i32.store - (i32.const 8) + (set_global $STACKTOP (get_local $__stackBase__) ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (i32.load (i32.add (get_local $$rem) @@ -31759,8 +31532,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31781,8 +31553,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31815,8 +31586,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31875,8 +31645,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31923,8 +31692,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -31994,8 +31762,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32081,8 +31848,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32121,8 +31887,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32228,8 +31993,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32268,8 +32032,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32470,8 +32233,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32510,8 +32272,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) @@ -32575,9 +32336,7 @@ ) ) (set_local $$137$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$q_sroa_1_1198 (get_local $$q_sroa_1_1_ph) @@ -32656,9 +32415,7 @@ ) ) (set_local $$150$1 - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$151$0 (i32.or @@ -32726,9 +32483,7 @@ (get_local $$154$0) ) (set_local $$r_sroa_1_4_extract_trunc - (i32.load - (i32.const 168) - ) + (get_global $tempRet0) ) (set_local $$155 (i32.sub @@ -32873,8 +32628,7 @@ ) (return (block - (i32.store - (i32.const 168) + (set_global $tempRet0 (get_local $$_0$1) ) (get_local $$_0$0) diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index 692c8438f..a092e87b4 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -6,6 +6,12 @@ (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $r global "env" "STACKTOP" i32) + (import $s global "env" "STACK_MAX" i32) + (import $t global "env" "tempDoublePtr" i32) + (import $u global "env" "ABORT" i32) + (import $z global "global" "NaN" f64) + (import $A global "global" "Infinity" f64) (import $ja "env" "abort" (param i32)) (import $oa "env" "_pthread_cleanup_pop" (param i32)) (import $pa "env" "___lock" (param i32)) @@ -40,6 +46,30 @@ (export "dynCall_vi" $mb) (export "__growWasmMemory" $__growWasmMemory) (export "memory" memory) + (global $v i32 (i32.const 0)) + (global $w i32 (i32.const 0)) + (global $x i32 (i32.const 0)) + (global $y i32 (i32.const 0)) + (global $B i32 (i32.const 0)) + (global $C i32 (i32.const 0)) + (global $D i32 (i32.const 0)) + (global $E i32 (i32.const 0)) + (global $F f64 (f64.const 0)) + (global $G i32 (i32.const 0)) + (global $H i32 (i32.const 0)) + (global $I i32 (i32.const 0)) + (global $J f64 (f64.const 0)) + (global $K i32 (i32.const 0)) + (global $L i32 (i32.const 0)) + (global $M i32 (i32.const 0)) + (global $N i32 (i32.const 0)) + (global $O i32 (i32.const 0)) + (global $P i32 (i32.const 0)) + (global $Q i32 (i32.const 0)) + (global $R i32 (i32.const 0)) + (global $S i32 (i32.const 0)) + (global $T i32 (i32.const 0)) + (global $za f64 (f64.const 0)) (table 8 8 anyfunc) (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa) (func $eb (param $0 i32) (result i32) @@ -98,16 +128,11 @@ (local $53 i32) (local $54 i32) (set_local $31 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -280,8 +305,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -651,8 +675,7 @@ (i32.const 1228) (get_local $0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -1388,8 +1411,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -2882,8 +2904,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3006,8 +3027,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3064,8 +3084,7 @@ (i32.const 3) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3161,8 +3180,7 @@ (get_local $18) ) (block - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3197,8 +3215,7 @@ ) ) (block - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -5116,8 +5133,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -6026,8 +6042,7 @@ (i32.const 3) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -6044,8 +6059,7 @@ (call $Qa) (i32.const 12) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (i32.const 0) @@ -7926,16 +7940,11 @@ (local $17 i32) (local $18 i32) (set_local $11 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 48) ) ) @@ -8298,8 +8307,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $11) ) (get_local $16) @@ -8842,16 +8850,11 @@ (local $8 i32) (local $9 i32) (set_local $5 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -8981,8 +8984,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $5) ) (get_local $4) @@ -9652,16 +9654,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 32) ) ) @@ -9717,8 +9714,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $4) ) (get_local $0) @@ -9727,16 +9723,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 80) ) ) @@ -9793,73 +9784,56 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $4) ) (get_local $3) ) (func $Ka (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=7 (get_local $0) ) @@ -9869,16 +9843,11 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -9898,8 +9867,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $1) ) (get_local $0) @@ -9925,33 +9893,25 @@ ) (func $Ja (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=3 (get_local $0) ) @@ -9985,26 +9945,18 @@ (func $Ea (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $r (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 15) ) (i32.const -16) @@ -10034,17 +9986,13 @@ (func $Ia (param $0 i32) (param $1 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $v) ) (block - (i32.store - (i32.const 40) + (set_global $v (get_local $0) ) - (i32.store - (i32.const 48) + (set_global $w (get_local $1) ) ) @@ -10087,12 +10035,10 @@ ) ) (func $Ha (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $s (get_local $1) ) ) @@ -10122,26 +10068,20 @@ ) ) (func $La (param $0 i32) - (i32.store - (i32.const 160) + (set_global $K (get_local $0) ) ) (func $Ga (param $0 i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $0) ) ) (func $Ma (result i32) - (i32.load - (i32.const 160) - ) + (get_global $K) ) (func $Fa (result i32) - (i32.load - (i32.const 8) - ) + (get_global $r) ) (func $ib (result i32) (i32.const 0) diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index 2e22608a8..ae2d79d38 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -6,6 +6,12 @@ (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (import $r global "env" "STACKTOP" i32) + (import $s global "env" "STACK_MAX" i32) + (import $t global "env" "tempDoublePtr" i32) + (import $u global "env" "ABORT" i32) + (import $z global "global" "NaN" f64) + (import $A global "global" "Infinity" f64) (import $ja "env" "abort" (param i32)) (import $oa "env" "_pthread_cleanup_pop" (param i32)) (import $pa "env" "___lock" (param i32)) @@ -39,6 +45,30 @@ (export "dynCall_vi" $mb) (export "__growWasmMemory" $__growWasmMemory) (export "memory" memory) + (global $v i32 (i32.const 0)) + (global $w i32 (i32.const 0)) + (global $x i32 (i32.const 0)) + (global $y i32 (i32.const 0)) + (global $B i32 (i32.const 0)) + (global $C i32 (i32.const 0)) + (global $D i32 (i32.const 0)) + (global $E i32 (i32.const 0)) + (global $F f64 (f64.const 0)) + (global $G i32 (i32.const 0)) + (global $H i32 (i32.const 0)) + (global $I i32 (i32.const 0)) + (global $J f64 (f64.const 0)) + (global $K i32 (i32.const 0)) + (global $L i32 (i32.const 0)) + (global $M i32 (i32.const 0)) + (global $N i32 (i32.const 0)) + (global $O i32 (i32.const 0)) + (global $P i32 (i32.const 0)) + (global $Q i32 (i32.const 0)) + (global $R i32 (i32.const 0)) + (global $S i32 (i32.const 0)) + (global $T i32 (i32.const 0)) + (global $za f64 (f64.const 0)) (table 8 8 anyfunc) (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa) (func $eb (param $0 i32) (result i32) @@ -97,16 +127,11 @@ (local $53 i32) (local $54 i32) (set_local $31 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -279,8 +304,7 @@ (i32.const 1) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -650,8 +674,7 @@ (i32.const 1228) (get_local $0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -1387,8 +1410,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -2881,8 +2903,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3005,8 +3026,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3063,8 +3083,7 @@ (i32.const 3) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3160,8 +3179,7 @@ (get_local $18) ) (block - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -3196,8 +3214,7 @@ ) ) (block - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -5115,8 +5132,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -6025,8 +6041,7 @@ (i32.const 3) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (return @@ -6043,8 +6058,7 @@ (call $Qa) (i32.const 12) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $31) ) (i32.const 0) @@ -7925,16 +7939,11 @@ (local $17 i32) (local $18 i32) (set_local $11 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 48) ) ) @@ -8297,8 +8306,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $11) ) (get_local $16) @@ -8841,16 +8849,11 @@ (local $8 i32) (local $9 i32) (set_local $5 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -8980,8 +8983,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $5) ) (get_local $4) @@ -9651,16 +9653,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 32) ) ) @@ -9716,8 +9713,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $4) ) (get_local $0) @@ -9726,16 +9722,11 @@ (local $3 i32) (local $4 i32) (set_local $4 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 80) ) ) @@ -9792,73 +9783,56 @@ (get_local $2) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $4) ) (get_local $3) ) (func $Ka (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=3 (get_local $0) ) ) (i32.store8 offset=4 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=4 (get_local $0) ) ) (i32.store8 offset=5 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=5 (get_local $0) ) ) (i32.store8 offset=6 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=6 (get_local $0) ) ) (i32.store8 offset=7 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=7 (get_local $0) ) @@ -9868,16 +9842,11 @@ (local $1 i32) (local $2 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -9897,8 +9866,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $1) ) (get_local $0) @@ -9924,33 +9892,25 @@ ) (func $Ja (param $0 i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $0) ) ) (i32.store8 offset=1 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=1 (get_local $0) ) ) (i32.store8 offset=2 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=2 (get_local $0) ) ) (i32.store8 offset=3 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s offset=3 (get_local $0) ) @@ -9984,26 +9944,18 @@ (func $Ea (param $0 i32) (result i32) (local $1 i32) (set_local $1 - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (get_local $0) ) ) - (i32.store - (i32.const 8) + (set_global $r (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 15) ) (i32.const -16) @@ -10033,17 +9985,13 @@ (func $Ia (param $0 i32) (param $1 i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $v) ) (block - (i32.store - (i32.const 40) + (set_global $v (get_local $0) ) - (i32.store - (i32.const 48) + (set_global $w (get_local $1) ) ) @@ -10086,12 +10034,10 @@ ) ) (func $Ha (param $0 i32) (param $1 i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $0) ) - (i32.store - (i32.const 16) + (set_global $s (get_local $1) ) ) @@ -10121,26 +10067,20 @@ ) ) (func $La (param $0 i32) - (i32.store - (i32.const 160) + (set_global $K (get_local $0) ) ) (func $Ga (param $0 i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $0) ) ) (func $Ma (result i32) - (i32.load - (i32.const 160) - ) + (get_global $K) ) (func $Fa (result i32) - (i32.load - (i32.const 8) - ) + (get_global $r) ) (func $ib (result i32) (i32.const 0) diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts index f121bfc20..758fff869 100644 --- a/test/memorygrowth.fromasm.imprecise.no-opts +++ b/test/memorygrowth.fromasm.imprecise.no-opts @@ -6,6 +6,12 @@ (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (import $r global "env" "STACKTOP" i32) + (import $s global "env" "STACK_MAX" i32) + (import $t global "env" "tempDoublePtr" i32) + (import $u global "env" "ABORT" i32) + (import $z global "global" "NaN" f64) + (import $A global "global" "Infinity" f64) (import $ja "env" "abort" (param i32)) (import $oa "env" "_pthread_cleanup_pop" (param i32)) (import $pa "env" "___lock" (param i32)) @@ -39,6 +45,30 @@ (export "dynCall_vi" $mb) (export "__growWasmMemory" $__growWasmMemory) (export "memory" memory) + (global $v i32 (i32.const 0)) + (global $w i32 (i32.const 0)) + (global $x i32 (i32.const 0)) + (global $y i32 (i32.const 0)) + (global $B i32 (i32.const 0)) + (global $C i32 (i32.const 0)) + (global $D i32 (i32.const 0)) + (global $E i32 (i32.const 0)) + (global $F f64 (f64.const 0)) + (global $G i32 (i32.const 0)) + (global $H i32 (i32.const 0)) + (global $I i32 (i32.const 0)) + (global $J f64 (f64.const 0)) + (global $K i32 (i32.const 0)) + (global $L i32 (i32.const 0)) + (global $M i32 (i32.const 0)) + (global $N i32 (i32.const 0)) + (global $O i32 (i32.const 0)) + (global $P i32 (i32.const 0)) + (global $Q i32 (i32.const 0)) + (global $R i32 (i32.const 0)) + (global $S i32 (i32.const 0)) + (global $T i32 (i32.const 0)) + (global $za f64 (f64.const 0)) (table 8 8 anyfunc) (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa) (func $eb (param $a i32) (result i32) @@ -136,16 +166,11 @@ (local $Ra i32) (local $Sa i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -339,8 +364,7 @@ (set_local $p (get_local $m) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -760,8 +784,7 @@ (set_local $p (get_local $o) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -1649,8 +1672,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3404,8 +3426,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3538,8 +3559,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3609,8 +3629,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3712,8 +3731,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3755,8 +3773,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -6135,8 +6152,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -7044,8 +7060,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -7065,8 +7080,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -9288,16 +9302,11 @@ (local $y i32) (local $z i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 48) ) ) @@ -9728,8 +9737,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -10410,16 +10418,11 @@ (local $m i32) (local $n i32) (set_local $c - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -10573,8 +10576,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $c) ) (return @@ -11380,16 +11382,11 @@ (local $f i32) (local $g i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 32) ) ) @@ -11464,8 +11461,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -11476,16 +11472,11 @@ (local $d i32) (local $e i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 80) ) ) @@ -11557,8 +11548,7 @@ (get_local $c) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -11567,18 +11557,14 @@ ) (func $Ka (param $a i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $a) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 1) ) (i32.load8_s @@ -11590,9 +11576,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 2) ) (i32.load8_s @@ -11604,9 +11588,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 3) ) (i32.load8_s @@ -11618,9 +11600,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 4) ) (i32.load8_s @@ -11632,9 +11612,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 5) ) (i32.load8_s @@ -11646,9 +11624,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 6) ) (i32.load8_s @@ -11660,9 +11636,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 7) ) (i32.load8_s @@ -11677,16 +11651,11 @@ (local $b i32) (local $c i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -11710,8 +11679,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -11751,18 +11719,14 @@ ) (func $Ja (param $a i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $a) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 1) ) (i32.load8_s @@ -11774,9 +11738,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 2) ) (i32.load8_s @@ -11788,9 +11750,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 3) ) (i32.load8_s @@ -11850,26 +11810,18 @@ (func $Ea (param $a i32) (result i32) (local $b i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (get_local $a) ) ) - (i32.store - (i32.const 8) + (set_global $r (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 15) ) (i32.const -16) @@ -11905,17 +11857,13 @@ (func $Ia (param $a i32) (param $b i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $v) ) (block - (i32.store - (i32.const 40) + (set_global $v (get_local $a) ) - (i32.store - (i32.const 48) + (set_global $w (get_local $b) ) ) @@ -11964,12 +11912,10 @@ ) ) (func $Ha (param $a i32) (param $b i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $a) ) - (i32.store - (i32.const 16) + (set_global $s (get_local $b) ) ) @@ -12005,29 +11951,23 @@ ) ) (func $La (param $a i32) - (i32.store - (i32.const 160) + (set_global $K (get_local $a) ) ) (func $Ga (param $a i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $a) ) ) (func $Ma (result i32) (return - (i32.load - (i32.const 160) - ) + (get_global $K) ) ) (func $Fa (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $r) ) ) (func $ib (result i32) diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts index 88e2e1869..b506e580c 100644 --- a/test/memorygrowth.fromasm.no-opts +++ b/test/memorygrowth.fromasm.no-opts @@ -6,6 +6,12 @@ (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$vii (func (param i32 i32))) + (import $r global "env" "STACKTOP" i32) + (import $s global "env" "STACK_MAX" i32) + (import $t global "env" "tempDoublePtr" i32) + (import $u global "env" "ABORT" i32) + (import $z global "global" "NaN" f64) + (import $A global "global" "Infinity" f64) (import $ja "env" "abort" (param i32)) (import $oa "env" "_pthread_cleanup_pop" (param i32)) (import $pa "env" "___lock" (param i32)) @@ -40,6 +46,30 @@ (export "dynCall_vi" $mb) (export "__growWasmMemory" $__growWasmMemory) (export "memory" memory) + (global $v i32 (i32.const 0)) + (global $w i32 (i32.const 0)) + (global $x i32 (i32.const 0)) + (global $y i32 (i32.const 0)) + (global $B i32 (i32.const 0)) + (global $C i32 (i32.const 0)) + (global $D i32 (i32.const 0)) + (global $E i32 (i32.const 0)) + (global $F f64 (f64.const 0)) + (global $G i32 (i32.const 0)) + (global $H i32 (i32.const 0)) + (global $I i32 (i32.const 0)) + (global $J f64 (f64.const 0)) + (global $K i32 (i32.const 0)) + (global $L i32 (i32.const 0)) + (global $M i32 (i32.const 0)) + (global $N i32 (i32.const 0)) + (global $O i32 (i32.const 0)) + (global $P i32 (i32.const 0)) + (global $Q i32 (i32.const 0)) + (global $R i32 (i32.const 0)) + (global $S i32 (i32.const 0)) + (global $T i32 (i32.const 0)) + (global $za f64 (f64.const 0)) (table 8 8 anyfunc) (elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa) (func $eb (param $a i32) (result i32) @@ -137,16 +167,11 @@ (local $Ra i32) (local $Sa i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -340,8 +365,7 @@ (set_local $p (get_local $m) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -761,8 +785,7 @@ (set_local $p (get_local $o) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -1650,8 +1673,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3405,8 +3427,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3539,8 +3560,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3610,8 +3630,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3713,8 +3732,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -3756,8 +3774,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -6136,8 +6153,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -7045,8 +7061,7 @@ (i32.const 8) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -7066,8 +7081,7 @@ (set_local $p (i32.const 0) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -9289,16 +9303,11 @@ (local $y i32) (local $z i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 48) ) ) @@ -9729,8 +9738,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -10411,16 +10419,11 @@ (local $m i32) (local $n i32) (set_local $c - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -10574,8 +10577,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $c) ) (return @@ -11381,16 +11383,11 @@ (local $f i32) (local $g i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 32) ) ) @@ -11465,8 +11462,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -11477,16 +11473,11 @@ (local $d i32) (local $e i32) (set_local $d - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 80) ) ) @@ -11558,8 +11549,7 @@ (get_local $c) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $d) ) (return @@ -11568,18 +11558,14 @@ ) (func $Ka (param $a i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $a) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 1) ) (i32.load8_s @@ -11591,9 +11577,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 2) ) (i32.load8_s @@ -11605,9 +11589,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 3) ) (i32.load8_s @@ -11619,9 +11601,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 4) ) (i32.load8_s @@ -11633,9 +11613,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 5) ) (i32.load8_s @@ -11647,9 +11625,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 6) ) (i32.load8_s @@ -11661,9 +11637,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 7) ) (i32.load8_s @@ -11678,16 +11652,11 @@ (local $b i32) (local $c i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 16) ) ) @@ -11711,8 +11680,7 @@ ) ) ) - (i32.store - (i32.const 8) + (set_global $r (get_local $b) ) (return @@ -11752,18 +11720,14 @@ ) (func $Ja (param $a i32) (i32.store8 - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.load8_s (get_local $a) ) ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 1) ) (i32.load8_s @@ -11775,9 +11739,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 2) ) (i32.load8_s @@ -11789,9 +11751,7 @@ ) (i32.store8 (i32.add - (i32.load - (i32.const 24) - ) + (get_global $t) (i32.const 3) ) (i32.load8_s @@ -11851,26 +11811,18 @@ (func $Ea (param $a i32) (result i32) (local $b i32) (set_local $b - (i32.load - (i32.const 8) - ) + (get_global $r) ) - (i32.store - (i32.const 8) + (set_global $r (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (get_local $a) ) ) - (i32.store - (i32.const 8) + (set_global $r (i32.and (i32.add - (i32.load - (i32.const 8) - ) + (get_global $r) (i32.const 15) ) (i32.const -16) @@ -11906,17 +11858,13 @@ (func $Ia (param $a i32) (param $b i32) (if (i32.eqz - (i32.load - (i32.const 40) - ) + (get_global $v) ) (block - (i32.store - (i32.const 40) + (set_global $v (get_local $a) ) - (i32.store - (i32.const 48) + (set_global $w (get_local $b) ) ) @@ -11965,12 +11913,10 @@ ) ) (func $Ha (param $a i32) (param $b i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $a) ) - (i32.store - (i32.const 16) + (set_global $s (get_local $b) ) ) @@ -12006,29 +11952,23 @@ ) ) (func $La (param $a i32) - (i32.store - (i32.const 160) + (set_global $K (get_local $a) ) ) (func $Ga (param $a i32) - (i32.store - (i32.const 8) + (set_global $r (get_local $a) ) ) (func $Ma (result i32) (return - (i32.load - (i32.const 160) - ) + (get_global $K) ) ) (func $Fa (result i32) (return - (i32.load - (i32.const 8) - ) + (get_global $r) ) ) (func $ib (result i32) diff --git a/test/min.fromasm b/test/min.fromasm index 06967379c..9c0d90097 100644 --- a/test/min.fromasm +++ b/test/min.fromasm @@ -1,5 +1,6 @@ (module (memory 256 256) + (import $tDP global "env" "tempDoublePtr" i32) (export "floats" $floats) (export "memory" memory) (func $floats (param $0 f32) (result f32) diff --git a/test/min.fromasm.imprecise b/test/min.fromasm.imprecise index 06967379c..9c0d90097 100644 --- a/test/min.fromasm.imprecise +++ b/test/min.fromasm.imprecise @@ -1,5 +1,6 @@ (module (memory 256 256) + (import $tDP global "env" "tempDoublePtr" i32) (export "floats" $floats) (export "memory" memory) (func $floats (param $0 f32) (result f32) diff --git a/test/min.fromasm.imprecise.no-opts b/test/min.fromasm.imprecise.no-opts index ff101cc82..899bf5317 100644 --- a/test/min.fromasm.imprecise.no-opts +++ b/test/min.fromasm.imprecise.no-opts @@ -1,5 +1,6 @@ (module (memory 256 256) + (import $tDP global "env" "tempDoublePtr" i32) (export "floats" $floats) (export "memory" memory) (func $floats (param $f f32) (result f32) diff --git a/test/min.fromasm.no-opts b/test/min.fromasm.no-opts index ff101cc82..899bf5317 100644 --- a/test/min.fromasm.no-opts +++ b/test/min.fromasm.no-opts @@ -1,5 +1,6 @@ (module (memory 256 256) + (import $tDP global "env" "tempDoublePtr" i32) (export "floats" $floats) (export "memory" memory) (func $floats (param $f f32) (result f32) diff --git a/test/unit.fromasm b/test/unit.fromasm index 1abe2a5e8..78a97a9d7 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -6,6 +6,10 @@ (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vd (func (param f64))) + (import $t global "global" "NaN" f64) + (import $u global "global" "Infinity" f64) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $n global "env" "gb" i32) (import $abort "env" "abort" (param f64)) (import $print "env" "print" (param i32)) (import $h "env" "h" (param i32)) @@ -15,6 +19,8 @@ (export "big_negative" $big_negative) (export "pick" $big_negative) (export "memory" memory) + (global $Int i32 (i32.const 0)) + (global $Double f64 (f64.const 0)) (table 10 10 anyfunc) (elem (i32.const 0) $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative @@ -23,9 +29,7 @@ (func $importedDoubles (result f64) (if (i32.gt_s - (i32.load - (i32.const 24) - ) + (get_global $Int) (i32.const 0) ) (return @@ -34,9 +38,7 @@ ) (if (f64.gt - (f64.load - (i32.const 32) - ) + (get_global $Double) (f64.const 0) ) (return @@ -439,9 +441,7 @@ (get_local $0) (i32.add (i32.add - (i32.load - (i32.const 48) - ) + (get_global $n) (i32.const 136) ) (i32.const 8) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index bba8a11a4..a18e1f436 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -4,6 +4,10 @@ (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vd (func (param f64))) + (import $t global "global" "NaN" f64) + (import $u global "global" "Infinity" f64) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $n global "env" "gb" i32) (import $abort "env" "abort" (param f64)) (import $print "env" "print" (param i32)) (import $h "env" "h" (param i32)) @@ -11,6 +15,8 @@ (export "big_negative" $big_negative) (export "pick" $big_negative) (export "memory" memory) + (global $Int i32 (i32.const 0)) + (global $Double f64 (f64.const 0)) (table 10 10 anyfunc) (elem (i32.const 0) $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative @@ -19,9 +25,7 @@ (func $importedDoubles (result f64) (if (i32.gt_s - (i32.load - (i32.const 24) - ) + (get_global $Int) (i32.const 0) ) (return @@ -30,9 +34,7 @@ ) (if (f64.gt - (f64.load - (i32.const 32) - ) + (get_global $Double) (f64.const 0) ) (return @@ -421,9 +423,7 @@ (get_local $0) (i32.add (i32.add - (i32.load - (i32.const 48) - ) + (get_global $n) (i32.const 136) ) (i32.const 8) diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts index 824606764..46d746946 100644 --- a/test/unit.fromasm.imprecise.no-opts +++ b/test/unit.fromasm.imprecise.no-opts @@ -4,6 +4,10 @@ (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vd (func (param f64))) + (import $t global "global" "NaN" f64) + (import $u global "global" "Infinity" f64) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $n global "env" "gb" i32) (import $abort "env" "abort" (param f64)) (import $print "env" "print" (param i32)) (import $h "env" "h" (param i32)) @@ -11,6 +15,8 @@ (export "big_negative" $big_negative) (export "pick" $exportMe) (export "memory" memory) + (global $Int i32 (i32.const 0)) + (global $Double f64 (f64.const 0)) (table 10 10 anyfunc) (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) (func $big_negative @@ -37,31 +43,21 @@ (f64.add (f64.add (f64.add - (f64.load - (i32.const 8) - ) - (f64.load - (i32.const 16) - ) + (get_global $t) + (get_global $u) ) (f64.neg - (f64.load - (i32.const 16) - ) + (get_global $u) ) ) (f64.neg - (f64.load - (i32.const 8) - ) + (get_global $t) ) ) ) (if (i32.gt_s - (i32.load - (i32.const 24) - ) + (get_global $Int) (i32.const 0) ) (return @@ -70,9 +66,7 @@ ) (if (f64.gt - (f64.load - (i32.const 32) - ) + (get_global $Double) (f64.const 0) ) (return @@ -781,9 +775,7 @@ (get_local $a) (i32.add (i32.add - (i32.load - (i32.const 48) - ) + (get_global $n) (i32.const 136) ) (i32.const 8) diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts index 5fba592a6..56a1d4085 100644 --- a/test/unit.fromasm.no-opts +++ b/test/unit.fromasm.no-opts @@ -6,6 +6,10 @@ (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vd (func (param f64))) + (import $t global "global" "NaN" f64) + (import $u global "global" "Infinity" f64) + (import $tempDoublePtr global "env" "tempDoublePtr" i32) + (import $n global "env" "gb" i32) (import $abort "env" "abort" (param f64)) (import $print "env" "print" (param i32)) (import $h "env" "h" (param i32)) @@ -15,6 +19,8 @@ (export "big_negative" $big_negative) (export "pick" $exportMe) (export "memory" memory) + (global $Int i32 (i32.const 0)) + (global $Double f64 (f64.const 0)) (table 10 10 anyfunc) (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) (func $big_negative @@ -41,31 +47,21 @@ (f64.add (f64.add (f64.add - (f64.load - (i32.const 8) - ) - (f64.load - (i32.const 16) - ) + (get_global $t) + (get_global $u) ) (f64.neg - (f64.load - (i32.const 16) - ) + (get_global $u) ) ) (f64.neg - (f64.load - (i32.const 8) - ) + (get_global $t) ) ) ) (if (i32.gt_s - (i32.load - (i32.const 24) - ) + (get_global $Int) (i32.const 0) ) (return @@ -74,9 +70,7 @@ ) (if (f64.gt - (f64.load - (i32.const 32) - ) + (get_global $Double) (f64.const 0) ) (return @@ -787,9 +781,7 @@ (get_local $a) (i32.add (i32.add - (i32.load - (i32.const 48) - ) + (get_global $n) (i32.const 136) ) (i32.const 8) |