diff options
author | Jacob Gravelle <jgravelle@google.com> | 2018-02-14 10:30:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 10:30:16 -0800 |
commit | ee78bc9bccb02bb2b63fbb881fd2893a5fca0044 (patch) | |
tree | f757a2b8d0baed7d73628905038894217ab4bdee | |
parent | e97d485bb1f1818e2c2118d28507d49cb61ea57b (diff) | |
download | binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.tar.gz binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.tar.bz2 binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.zip |
Fold wasm-link-metadata into wasm-emscripten-finalize (#1408)
* wasm-link-metadata: Use `__data_end` symbol.
* Add --global-base param to emscripten-wasm-finalize to compute staticBump properly
* Let ModuleWriter write to a provided Output object
32 files changed, 197 insertions, 314 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 749bf6f33..90b69302f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,17 +279,6 @@ SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD 11) SET_PROPERTY(TARGET s2wasm PROPERTY CXX_STANDARD_REQUIRED ON) INSTALL(TARGETS s2wasm DESTINATION ${CMAKE_INSTALL_BINDIR}) -SET(wasm-link-metadata_SOURCES - src/tools/wasm-link-metadata.cpp - src/wasm-emscripten.cpp -) -ADD_EXECUTABLE(wasm-link-metadata - ${wasm-link-metadata_SOURCES}) -TARGET_LINK_LIBRARIES(wasm-link-metadata passes wasm asmjs ir cfg support) -SET_PROPERTY(TARGET wasm-link-metadata PROPERTY CXX_STANDARD 11) -SET_PROPERTY(TARGET wasm-link-metadata PROPERTY CXX_STANDARD_REQUIRED ON) -INSTALL(TARGETS wasm-link-metadata DESTINATION ${CMAKE_INSTALL_BINDIR}) - SET(wasm-emscripten-finalize_SOURCES src/tools/wasm-emscripten-finalize.cpp src/wasm-emscripten.cpp diff --git a/auto_update_tests.py b/auto_update_tests.py index 8e75ffb6b..6f87234f9 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -6,7 +6,7 @@ from scripts.test.support import run_command, split_wast, node_test_glue, node_h from scripts.test.shared import ( ASM2WASM, MOZJS, NODEJS, S2WASM, WASM_SHELL, WASM_OPT, WASM_AS, WASM_DIS, WASM_CTOR_EVAL, WASM_MERGE, WASM_REDUCE, WASM2ASM, WASM_METADCE, - WASM_LINK_METADATA, WASM_EMSCRIPTEN_FINALIZE, BINARYEN_INSTALL_DIR, + WASM_EMSCRIPTEN_FINALIZE, BINARYEN_INSTALL_DIR, files_with_pattern, has_shell_timeout) from scripts.test.wasm2asm import tests, spec_tests, extra_tests, assert_tests @@ -74,22 +74,6 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']: with open(expected_file, 'w') as o: o.write(actual) -print '\n[ checking wasm-link-metadata testcases... ]\n' - -link_metadata_extension_arg_map = { - '.json': [], - '.jscall.json': ['--emscripten-reserved-function-pointers=3'], -} -for obj_path in files_with_pattern('test', 'lld', '*.o'): - print '..', obj_path - for ext, ext_args in link_metadata_extension_arg_map.items(): - json_path = obj_path.replace('.o', ext) - if ext != 'json' and not os.path.exists(json_path): - continue - cmd = WASM_LINK_METADATA + [obj_path] + ext_args - actual = run_command(cmd) - with open(json_path, 'w') as o: o.write(actual) - print '\n[ checking wasm-emscripten-finalize testcases... ]\n' emscripten_finalize_extension_arg_map = { @@ -102,7 +86,8 @@ for wast_path in files_with_pattern('test', 'lld', '*.wast'): out_path = wast_path + ext if ext != '.out' and not os.path.exists(out_path): continue - cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + ext_args + cmd = (WASM_EMSCRIPTEN_FINALIZE + + [wast_path, '-S', '--global-base=568'] + ext_args) actual = run_command(cmd) with open(out_path, 'w') as o: o.write(actual) @@ -360,7 +360,7 @@ def run_binaryen_js_tests(): if not s.endswith('.js'): continue print s f = open('a.js', 'w') - binaryen_js = open(os.path.join(options.binaryen_bin, 'binaryen.js')).read() + binaryen_js = open(os.path.join(options.binaryen_root, 'bin', 'binaryen.js')).read() f.write(binaryen_js) if NODEJS: f.write(node_test_glue()) @@ -607,7 +607,6 @@ def main(): run_binaryen_js_tests() s2wasm.test_s2wasm() s2wasm.test_linker() - lld.test_wasm_link_metadata() lld.test_wasm_emscripten_finalize() wasm2asm.test_wasm2asm() run_validator_tests() diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index c959bd857..4f1718068 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -27,58 +27,54 @@ def files_with_extensions(path, extensions): yield file, ext -def generate_object_files(clang_bin): - print '\n[ building object files from C sources... ]\n' +def generate_wast_files(clang_bin, lld_bin, emscripten_root): + print '\n[ building wast files from C sources... ]\n' lld_path = os.path.join(shared.options.binaryen_test, 'lld') for src_file, ext in files_with_extensions(lld_path, ['.c', '.cpp']): print '..', src_file - obj_file = src_file.replace(ext, '.o') - - src_path = os.path.join(lld_path, src_file) - obj_path = os.path.join(lld_path, obj_file) - run_command([ - clang_bin, src_path, '-o', obj_path, - '--target=wasm32-unknown-unknown-wasm', - '-c', - '-nostdinc', - '-Xclang', '-nobuiltininc', - '-Xclang', '-nostdsysteminc', - '-Xclang', '-I/s/work/emscripten/system/include', - '-O1', - ]) + try: + obj_file = src_file.replace(ext, '.o') + src_path = os.path.join(lld_path, src_file) + obj_path = os.path.join(lld_path, obj_file) + run_command([ + clang_bin, src_path, '-o', obj_path, + '--target=wasm32-unknown-unknown-wasm', + '-c', + '-nostdinc', + '-Xclang', '-nobuiltininc', + '-Xclang', '-nostdsysteminc', + '-Xclang', '-I%s/system/include' % emscripten_root, + '-O1', + ]) -def generate_wast_files(lld_bin): - print '\n[ linking wasm files from object files... ]\n' - lld_path = os.path.join(shared.options.binaryen_test, 'lld') - for obj_file, ext in files_with_extensions(lld_path, ['.o']): - print '..', obj_file - wasm_file = obj_file.replace(ext, '.wasm') - wast_file = obj_file.replace(ext, '.wast') + wasm_file = src_file.replace(ext, '.wasm') + wast_file = src_file.replace(ext, '.wast') - obj_path = os.path.join(lld_path, obj_file) - wasm_path = os.path.join(lld_path, wasm_file) - wast_path = os.path.join(lld_path, wast_file) - run_command([ - lld_bin, '-flavor', 'wasm', - '-z', '-stack-size=1048576', - obj_path, '-o', wasm_path, - '--entry=main', - '--allow-undefined', - '--export', '__wasm_call_ctors', - ]) - try: + obj_path = os.path.join(lld_path, obj_file) + wasm_path = os.path.join(lld_path, wasm_file) + wast_path = os.path.join(lld_path, wast_file) + run_command([ + lld_bin, '-flavor', 'wasm', + '-z', '-stack-size=1048576', + obj_path, '-o', wasm_path, + '--entry=main', + '--allow-undefined', + '--export', '__wasm_call_ctors', + '--global-base=568', + ]) run_command(shared.WASM_DIS + [wasm_path, '-o', wast_path]) finally: - # Don't need the .wasm file, don't leave it around + # Don't need the .o or .wasm files, don't leave them around + shared.delete_from_orbit(obj_path) shared.delete_from_orbit(wasm_path) if __name__ == '__main__': - if len(sys.argv) != 3: - print 'Usage: generate_lld_tests.py [path/to/clang] [path/to/lld]' + if len(sys.argv) != 4: + print 'Usage: generate_lld_tests.py [path/to/clang] [path/to/lld] \ +[path/to/emscripten]' sys.exit(1) - generate_object_files(sys.argv[1]) - generate_wast_files(sys.argv[2]) + generate_wast_files(*sys.argv[1:]) diff --git a/scripts/test/lld.py b/scripts/test/lld.py index 85159ba3a..f6aa91e6f 100755 --- a/scripts/test/lld.py +++ b/scripts/test/lld.py @@ -18,36 +18,10 @@ import os from support import run_command from shared import ( fail, fail_with_error, files_with_pattern, options, - WASM_LINK_METADATA, WASM_EMSCRIPTEN_FINALIZE + WASM_EMSCRIPTEN_FINALIZE ) -def test_wasm_link_metadata(): - print '\n[ checking wasm-link-metadata testcases... ]\n' - - extension_arg_map = { - '.json': [], - '.jscall.json': ['--emscripten-reserved-function-pointers=3'], - } - - for obj_path in files_with_pattern(options.binaryen_test, 'lld', '*.o'): - print '..', obj_path - for ext, ext_args in extension_arg_map.items(): - expected_file = obj_path.replace('.o', ext) - if ext != '.json' and not os.path.exists(expected_file): - continue - - cmd = WASM_LINK_METADATA + [obj_path] + ext_args - actual = run_command(cmd) - - if not os.path.exists(expected_file): - print actual - fail_with_error('output ' + expected_file + ' does not exist') - expected = open(expected_file, 'rb').read() - if actual != expected: - fail(actual, expected) - - def test_wasm_emscripten_finalize(): print '\n[ checking wasm-emscripten-finalize testcases... ]\n' @@ -63,7 +37,8 @@ def test_wasm_emscripten_finalize(): if ext != '.out' and not os.path.exists(expected_file): continue - cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + ext_args + cmd = (WASM_EMSCRIPTEN_FINALIZE + + [wast_path, '-S', '--global-base=568'] + ext_args) actual = run_command(cmd) if not os.path.exists(expected_file): @@ -75,5 +50,4 @@ def test_wasm_emscripten_finalize(): if __name__ == '__main__': - test_wasm_link_metadata() test_wasm_emscripten_finalize() diff --git a/scripts/test/shared.py b/scripts/test/shared.py index 863e97ec0..b48202e98 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -170,7 +170,6 @@ WASM_MERGE = [os.path.join(options.binaryen_bin, 'wasm-merge')] S2WASM = [os.path.join(options.binaryen_bin, 's2wasm')] WASM_REDUCE = [os.path.join(options.binaryen_bin, 'wasm-reduce')] WASM_METADCE = [os.path.join(options.binaryen_bin, 'wasm-metadce')] -WASM_LINK_METADATA = [os.path.join(options.binaryen_bin, 'wasm-link-metadata')] WASM_EMSCRIPTEN_FINALIZE = [os.path.join(options.binaryen_bin, 'wasm-emscripten-finalize')] diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 28f5a7c06..1cb1b5758 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -40,7 +40,7 @@ int main(int argc, const char *argv[]) { std::string outfile; bool emitBinary = true; unsigned numReservedFunctionPointers = 0; - std::vector<Name> forcedExports; + uint64_t globalBase; Options options("wasm-emscripten-finalize", "Performs Emscripten-specific transforms on .wasm files"); options @@ -63,6 +63,11 @@ int main(int argc, const char *argv[]) { const std::string &argument) { numReservedFunctionPointers = std::stoi(argument); }) + .add("--global-base", "", "Where lld started to place globals", + Options::Arguments::One, + [&globalBase](Options*, const std::string&argument ) { + globalBase = std::stoull(argument); + }) .add_positional("INFILE", Options::Arguments::One, [&infile](Options *o, const std::string& argument) { infile = argument; @@ -85,18 +90,37 @@ int main(int argc, const char *argv[]) { WasmPrinter::printModule(&wasm, std::cerr); } + Export* dataEndExport = wasm.getExport("__data_end"); + if (dataEndExport == nullptr) { + Fatal() << "__data_end export not found"; + } + Global* dataEnd = wasm.getGlobal(dataEndExport->value); + if (dataEnd == nullptr) { + Fatal() << "__data_end global not found"; + } + if (dataEnd->type != Type::i32) { + Fatal() << "__data_end global has wrong type"; + } + Const* dataEndConst = dataEnd->init->cast<Const>(); + uint32_t dataSize = dataEndConst->value.geti32() - globalBase; + + std::vector<Name> initializerFunctions; + initializerFunctions.push_back("__wasm_call_ctors"); + EmscriptenGlueGenerator generator(wasm); generator.generateRuntimeFunctions(); generator.generateMemoryGrowthFunction(); generator.generateDynCallThunks(); generator.generateJSCallThunks(numReservedFunctionPointers); - generator.fixEmAsmConsts(); + std::string metadata = generator.generateEmscriptenMetadata(dataSize, initializerFunctions, numReservedFunctionPointers); if (options.debug) { std::cerr << "Module after:\n"; WasmPrinter::printModule(&wasm, std::cerr); } + auto outputBinaryFlag = emitBinary ? Flags::Binary : Flags::Text; + Output output(outfile, outputBinaryFlag, Flags::Release); ModuleWriter writer; // writer.setDebug(options.debug); writer.setDebugInfo(true); @@ -107,7 +131,11 @@ int main(int argc, const char *argv[]) { // writer.setSourceMapFilename(sourceMapFilename); // writer.setSourceMapUrl(sourceMapUrl); // } - writer.write(wasm, outfile); + writer.write(wasm, output); + if (!emitBinary) { + output << ";; METADATA: "; + } + output << metadata; return 0; } diff --git a/src/tools/wasm-link-metadata.cpp b/src/tools/wasm-link-metadata.cpp deleted file mode 100644 index 3af00fbbf..000000000 --- a/src/tools/wasm-link-metadata.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2017 WebAssembly Community Group participants - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -// wasm-link-metadata console tool -// Reads wasm .o file and emits .json metadata -// - -#include <exception> - -#include "abi/wasm-object.h" -#include "ir/trapping.h" -#include "support/colors.h" -#include "support/command-line.h" -#include "support/file.h" -#include "wasm-binary.h" -#include "wasm-emscripten.h" -#include "wasm-io.h" -#include "wasm-linker.h" -#include "wasm-printing.h" -#include "wasm-validator.h" - -using namespace cashew; -using namespace wasm; - -void parseLinkingSection(std::vector<char> const& data, uint32_t &dataSize) { - unsigned idx = 0; - auto get = [&idx, &data](){ return data[idx++]; }; - auto readNext = [get](){ - U32LEB leb; - leb.read(get); - return leb.value; - }; - - while (idx < data.size()) { - ABI::LinkType type = static_cast<ABI::LinkType>(readNext()); - uint32_t size = readNext(); - uint32_t startIdx = idx; - - switch(type) { - case ABI::WASM_DATA_SIZE: { - dataSize = readNext(); - break; - } - default: { - break; - } - } - // Always go to the end of the subsection based on size, not contents. - idx = startIdx + size; - } -} - -int main(int argc, const char *argv[]) { - std::string infile; - std::string outfile; - unsigned numReservedFunctionPointers = 0; - Options options("wasm-link-metadata", - "Reads wasm .o file and emits .json metadata"); - options - .add("--output", "-o", "Output file", - Options::Arguments::One, - [&outfile](Options *o, const std::string& argument) { - outfile = argument; - Colors::disable(); - }) - .add("--emscripten-reserved-function-pointers", "", - "Number of reserved function pointers for emscripten addFunction " - "support", - Options::Arguments::One, - [&numReservedFunctionPointers](Options *o, - const std::string &argument) { - numReservedFunctionPointers = std::stoi(argument); - }) - .add_positional("INFILE", Options::Arguments::One, - [&infile](Options *o, const std::string& argument) { - infile = argument; - }); - options.parse(argc, argv); - - if (infile == "") { - Fatal() << "Need to specify an infile\n"; - } - - Module wasm; - try { - ModuleReader reader; - reader.readBinary(infile, wasm); - } catch (ParseException& p) { - p.dump(std::cerr); - Fatal() << "error in parsing wasm binary"; - } - - if (options.debug) { - WasmPrinter::printModule(&wasm, std::cerr); - } - - uint32_t dataSize = 0; - for (auto §ion : wasm.userSections) { - if (section.name == "linking") { - parseLinkingSection(section.data, dataSize); - } - } - - std::vector<Name> initializerFunctions; - initializerFunctions.push_back("__wasm_call_ctors"); - - EmscriptenGlueGenerator generator(wasm); - std::string metadata = generator.generateEmscriptenMetadata( - dataSize, initializerFunctions, numReservedFunctionPointers); - Output output(outfile, Flags::Text, Flags::Release); - output << metadata; - - return 0; -} diff --git a/src/wasm-io.h b/src/wasm-io.h index 17a722472..cbb8f36c8 100644 --- a/src/wasm-io.h +++ b/src/wasm-io.h @@ -23,6 +23,7 @@ #include "wasm.h" #include "parsing.h" +#include "support/file.h" namespace wasm { @@ -62,12 +63,15 @@ public: void setSourceMapUrl(std::string sourceMapUrl_) { sourceMapUrl = sourceMapUrl_; } // write text + void writeText(Module& wasm, Output& output); void writeText(Module& wasm, std::string filename); // write binary + void writeBinary(Module& wasm, Output& output); void writeBinary(Module& wasm, std::string filename); // write text or binary, defaulting to binary unless setBinary(false), // and unless there is no output file (in which case we write text // to stdout). + void write(Module& wasm, Output& output); void write(Module& wasm, std::string filename); }; diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp index 1f50d7140..d7ba4cf25 100644 --- a/src/wasm/wasm-io.cpp +++ b/src/wasm/wasm-io.cpp @@ -27,7 +27,6 @@ #include "wasm-io.h" #include "wasm-s-parser.h" #include "wasm-binary.h" -#include "support/file.h" namespace wasm { @@ -65,14 +64,17 @@ void ModuleReader::read(std::string filename, Module& wasm) { } } +void ModuleWriter::writeText(Module& wasm, Output& output) { + WasmPrinter::printModule(&wasm, output.getStream()); +} + void ModuleWriter::writeText(Module& wasm, std::string filename) { if (debug) std::cerr << "writing text to " << filename << "\n"; Output output(filename, Flags::Text, debug ? Flags::Debug : Flags::Release); - WasmPrinter::printModule(&wasm, output.getStream()); + writeText(wasm, output); } -void ModuleWriter::writeBinary(Module& wasm, std::string filename) { - if (debug) std::cerr << "writing binary to " << filename << "\n"; +void ModuleWriter::writeBinary(Module& wasm, Output& output) { BufferWithRandomAccess buffer(debug); WasmBinaryWriter writer(&wasm, buffer, debug); // if debug info is used, then we want to emit the names section @@ -85,13 +87,26 @@ void ModuleWriter::writeBinary(Module& wasm, std::string filename) { } if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap); writer.write(); - Output output(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release); buffer.writeTo(output); if (sourceMapStream) { sourceMapStream->close(); } } +void ModuleWriter::writeBinary(Module& wasm, std::string filename) { + if (debug) std::cerr << "writing binary to " << filename << "\n"; + Output output(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release); + writeBinary(wasm, output); +} + +void ModuleWriter::write(Module& wasm, Output& output) { + if (binary) { + writeBinary(wasm, output); + } else { + writeText(wasm, output); + } +} + void ModuleWriter::write(Module& wasm, std::string filename) { if (binary && filename.size() > 0) { writeBinary(wasm, filename); diff --git a/test/lld/em_asm.json b/test/lld/em_asm.json deleted file mode 100644 index f5027845d..000000000 --- a/test/lld/em_asm.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {"2": ["{ Module.print(\"Got \" + $0); }", ["ii"]],"0": ["{ Module.print(\"Hello world\"); }", ["i"]],"1": ["{ return $0 + $1; }", ["iii"]]},"staticBump": 84, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/em_asm.o b/test/lld/em_asm.o Binary files differdeleted file mode 100644 index f95befdee..000000000 --- a/test/lld/em_asm.o +++ /dev/null diff --git a/test/lld/em_asm.wast b/test/lld/em_asm.wast index da1d8c3b6..b1f4d4fe2 100644 --- a/test/lld/em_asm.wast +++ b/test/lld/em_asm.wast @@ -1,32 +1,34 @@ (module - (type $0 (func (result i32))) - (type $1 (func (param i32) (result i32))) - (type $2 (func (param i32 i32 i32) (result i32))) - (type $3 (func (param i32 i32) (result i32))) + (type $0 (func (param i32) (result i32))) + (type $1 (func (param i32 i32 i32) (result i32))) + (type $2 (func (param i32 i32) (result i32))) + (type $3 (func (result i32))) (type $4 (func)) (import "env" "_Z24emscripten_asm_const_intIJEEiPKcDpT_" (func $_Z24emscripten_asm_const_intIJEEiPKcDpT_ (param i32) (result i32))) (import "env" "_Z24emscripten_asm_const_intIJiiEEiPKcDpT_" (func $_Z24emscripten_asm_const_intIJiiEEiPKcDpT_ (param i32 i32 i32) (result i32))) (import "env" "_Z24emscripten_asm_const_intIJiEEiPKcDpT_" (func $_Z24emscripten_asm_const_intIJiEEiPKcDpT_ (param i32 i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66656)) - (global $global$1 i32 (i32.const 66656)) + (global $global$0 (mut i32) (i32.const 66192)) + (global $global$1 i32 (i32.const 66192)) + (global $global$2 i32 (i32.const 652)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") + (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) - (func $main (; 3 ;) (type $0) (result i32) + (export "__data_end" (global $global$2)) + (func $main (; 3 ;) (type $3) (result i32) (drop (call $_Z24emscripten_asm_const_intIJEEiPKcDpT_ - (i32.const 1024) + (i32.const 568) ) ) (drop (call $_Z24emscripten_asm_const_intIJiEEiPKcDpT_ - (i32.const 1077) + (i32.const 621) (call $_Z24emscripten_asm_const_intIJiiEEiPKcDpT_ - (i32.const 1057) + (i32.const 601) (i32.const 13) (i32.const 27) ) diff --git a/test/lld/em_asm.wast.out b/test/lld/em_asm.wast.out index 921cd9782..4aacefc05 100644 --- a/test/lld/em_asm.wast.out +++ b/test/lld/em_asm.wast.out @@ -1,8 +1,8 @@ (module - (type $0 (func (result i32))) - (type $1 (func (param i32) (result i32))) - (type $2 (func (param i32 i32 i32) (result i32))) - (type $3 (func (param i32 i32) (result i32))) + (type $0 (func (param i32) (result i32))) + (type $1 (func (param i32 i32 i32) (result i32))) + (type $2 (func (param i32 i32) (result i32))) + (type $3 (func (result i32))) (type $4 (func)) (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) @@ -10,20 +10,22 @@ (import "env" "emscripten_asm_const_i" (func $emscripten_asm_const_i (param i32) (result i32))) (import "env" "emscripten_asm_const_iii" (func $emscripten_asm_const_iii (param i32 i32 i32) (result i32))) (import "env" "emscripten_asm_const_ii" (func $emscripten_asm_const_ii (param i32 i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66656)) - (global $global$1 i32 (i32.const 66656)) + (global $global$0 (mut i32) (i32.const 66192)) + (global $global$1 i32 (i32.const 66192)) + (global $global$2 i32 (i32.const 652)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") + (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00{ return $0 + $1; }\00{ Module.print(\"Got \" + $0); }\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) (export "__growWasmMemory" (func $__growWasmMemory)) - (func $main (; 3 ;) (type $0) (result i32) + (func $main (; 3 ;) (type $3) (result i32) (drop (call $emscripten_asm_const_i (i32.const 0) @@ -73,3 +75,4 @@ ) ) ) +;; METADATA: { "asmConsts": {"2": ["{ Module.print(\"Got \" + $0); }", ["ii"]],"0": ["{ Module.print(\"Hello world\"); }", ["i"]],"1": ["{ return $0 + $1; }", ["iii"]]},"staticBump": 84, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/hello_world.json b/test/lld/hello_world.json deleted file mode 100644 index c0a391b6e..000000000 --- a/test/lld/hello_world.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {},"staticBump": 13, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/hello_world.o b/test/lld/hello_world.o Binary files differdeleted file mode 100644 index a14f95993..000000000 --- a/test/lld/hello_world.o +++ /dev/null diff --git a/test/lld/hello_world.wast b/test/lld/hello_world.wast index d1610cece..0564e64a8 100644 --- a/test/lld/hello_world.wast +++ b/test/lld/hello_world.wast @@ -1,21 +1,23 @@ (module - (type $0 (func (result i32))) - (type $1 (func (param i32) (result i32))) + (type $0 (func (param i32) (result i32))) + (type $1 (func (result i32))) (type $2 (func)) (import "env" "puts" (func $puts (param i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66576)) - (global $global$1 i32 (i32.const 66576)) + (global $global$0 (mut i32) (i32.const 66128)) + (global $global$1 i32 (i32.const 66128)) + (global $global$2 i32 (i32.const 581)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "Hello, world\00") + (data (i32.const 568) "Hello, world\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) - (func $main (; 1 ;) (type $0) (result i32) + (export "__data_end" (global $global$2)) + (func $main (; 1 ;) (type $1) (result i32) (drop (call $puts - (i32.const 1024) + (i32.const 568) ) ) (i32.const 0) diff --git a/test/lld/hello_world.wast.out b/test/lld/hello_world.wast.out index ab861cc94..f106f6fc7 100644 --- a/test/lld/hello_world.wast.out +++ b/test/lld/hello_world.wast.out @@ -1,26 +1,28 @@ (module - (type $0 (func (result i32))) - (type $1 (func (param i32) (result i32))) + (type $0 (func (param i32) (result i32))) + (type $1 (func (result i32))) (type $2 (func)) (type $FUNCSIG$ii (func (param i32) (result i32))) (import "env" "puts" (func $puts (param i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66576)) - (global $global$1 i32 (i32.const 66576)) + (global $global$0 (mut i32) (i32.const 66128)) + (global $global$1 i32 (i32.const 66128)) + (global $global$2 i32 (i32.const 581)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "Hello, world\00") + (data (i32.const 568) "Hello, world\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) (export "__growWasmMemory" (func $__growWasmMemory)) - (func $main (; 1 ;) (type $0) (result i32) + (func $main (; 1 ;) (type $1) (result i32) (drop (call $puts - (i32.const 1024) + (i32.const 568) ) ) (i32.const 0) @@ -57,3 +59,4 @@ ) ) ) +;; METADATA: { "asmConsts": {},"staticBump": 13, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/init.json b/test/lld/init.json deleted file mode 100644 index f4d13ada1..000000000 --- a/test/lld/init.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {},"staticBump": 8, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/init.o b/test/lld/init.o Binary files differdeleted file mode 100644 index e86c68092..000000000 --- a/test/lld/init.o +++ /dev/null diff --git a/test/lld/init.wast b/test/lld/init.wast index be25ed464..87c2e862f 100644 --- a/test/lld/init.wast +++ b/test/lld/init.wast @@ -1,33 +1,35 @@ (module (type $0 (func)) (type $1 (func (result i32))) - (global $global$0 (mut i32) (i32.const 66576)) - (global $global$1 i32 (i32.const 66576)) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 66112)) + (global $global$2 i32 (i32.const 576)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "\00\00\00\00\00\00\00\00") + (data (i32.const 568) "\00\00\00\00\00\00\00\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (func $init_x (; 0 ;) (type $0) - (i32.store offset=1024 + (i32.store offset=568 (i32.const 0) (i32.const 14) ) ) (func $init_y (; 1 ;) (type $0) - (i32.store offset=1028 + (i32.store offset=572 (i32.const 0) (i32.const 144) ) ) (func $main (; 2 ;) (type $1) (result i32) (i32.add - (i32.load offset=1024 + (i32.load offset=568 (i32.const 0) ) - (i32.load offset=1028 + (i32.load offset=572 (i32.const 0) ) ) diff --git a/test/lld/init.wast.out b/test/lld/init.wast.out index 3b46d26d4..edcfff482 100644 --- a/test/lld/init.wast.out +++ b/test/lld/init.wast.out @@ -1,37 +1,39 @@ (module (type $0 (func)) (type $1 (func (result i32))) - (global $global$0 (mut i32) (i32.const 66576)) - (global $global$1 i32 (i32.const 66576)) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 66112)) + (global $global$2 i32 (i32.const 576)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "\00\00\00\00\00\00\00\00") + (data (i32.const 568) "\00\00\00\00\00\00\00\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $init_x (; 0 ;) (type $0) - (i32.store offset=1024 + (i32.store offset=568 (i32.const 0) (i32.const 14) ) ) (func $init_y (; 1 ;) (type $0) - (i32.store offset=1028 + (i32.store offset=572 (i32.const 0) (i32.const 144) ) ) (func $main (; 2 ;) (type $1) (result i32) (i32.add - (i32.load offset=1024 + (i32.load offset=568 (i32.const 0) ) - (i32.load offset=1028 + (i32.load offset=572 (i32.const 0) ) ) @@ -69,3 +71,4 @@ ) ) ) +;; METADATA: { "asmConsts": {},"staticBump": 8, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/recursive.json b/test/lld/recursive.json deleted file mode 100644 index a976be232..000000000 --- a/test/lld/recursive.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {},"staticBump": 19, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/recursive.o b/test/lld/recursive.o Binary files differdeleted file mode 100644 index 409257fd4..000000000 --- a/test/lld/recursive.o +++ /dev/null diff --git a/test/lld/recursive.wast b/test/lld/recursive.wast index 21b46a31f..c6dbdd359 100644 --- a/test/lld/recursive.wast +++ b/test/lld/recursive.wast @@ -3,15 +3,17 @@ (type $1 (func (result i32))) (type $2 (func)) (import "env" "printf" (func $printf (param i32 i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66592)) - (global $global$1 i32 (i32.const 66592)) + (global $global$0 (mut i32) (i32.const 66128)) + (global $global$1 i32 (i32.const 66128)) + (global $global$2 i32 (i32.const 587)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "%d:%d\n\00Result: %d\n\00") + (data (i32.const 568) "%d:%d\n\00Result: %d\n\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (func $foo (; 1 ;) (type $0) (param $var$0 i32) (param $var$1 i32) (result i32) (local $var$2 i32) (set_global $global$0 @@ -32,7 +34,7 @@ ) (drop (call $printf - (i32.const 1024) + (i32.const 568) (get_local $var$2) ) ) @@ -66,7 +68,7 @@ ) (drop (call $printf - (i32.const 1031) + (i32.const 575) (get_local $var$0) ) ) diff --git a/test/lld/recursive.wast.out b/test/lld/recursive.wast.out index 4920a7622..13659ac36 100644 --- a/test/lld/recursive.wast.out +++ b/test/lld/recursive.wast.out @@ -4,15 +4,17 @@ (type $2 (func)) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (import "env" "printf" (func $printf (param i32 i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66592)) - (global $global$1 i32 (i32.const 66592)) + (global $global$0 (mut i32) (i32.const 66128)) + (global $global$1 i32 (i32.const 66128)) + (global $global$2 i32 (i32.const 587)) (table 1 1 anyfunc) (memory $0 2) - (data (i32.const 1024) "%d:%d\n\00Result: %d\n\00") + (data (i32.const 568) "%d:%d\n\00Result: %d\n\00") (export "memory" (memory $0)) - (export "main" (func $main)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) + (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) @@ -37,7 +39,7 @@ ) (drop (call $printf - (i32.const 1024) + (i32.const 568) (get_local $var$2) ) ) @@ -71,7 +73,7 @@ ) (drop (call $printf - (i32.const 1031) + (i32.const 575) (get_local $var$0) ) ) @@ -115,3 +117,4 @@ ) ) ) +;; METADATA: { "asmConsts": {},"staticBump": 19, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/reserved_func_ptr.jscall.json b/test/lld/reserved_func_ptr.jscall.json deleted file mode 100644 index e463aafe7..000000000 --- a/test/lld/reserved_func_ptr.jscall.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"], "jsCallStartIndex": 3, "jsCallFuncType": ["ddi", "fffi", "iii", "v", "vi", "viii"] } diff --git a/test/lld/reserved_func_ptr.json b/test/lld/reserved_func_ptr.json deleted file mode 100644 index 82f73d077..000000000 --- a/test/lld/reserved_func_ptr.json +++ /dev/null @@ -1 +0,0 @@ -{ "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"] } diff --git a/test/lld/reserved_func_ptr.o b/test/lld/reserved_func_ptr.o Binary files differdeleted file mode 100644 index f352c5cfe..000000000 --- a/test/lld/reserved_func_ptr.o +++ /dev/null diff --git a/test/lld/reserved_func_ptr.wast b/test/lld/reserved_func_ptr.wast index 6a77ec71b..b3c6fd9b3 100644 --- a/test/lld/reserved_func_ptr.wast +++ b/test/lld/reserved_func_ptr.wast @@ -7,8 +7,9 @@ (type $5 (func (param i32 i32 i32))) (type $6 (func (param i32) (result i32))) (import "env" "_Z4atoiPKc" (func $_Z4atoiPKc (param i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66560)) - (global $global$1 i32 (i32.const 66560)) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 66112)) + (global $global$2 i32 (i32.const 568)) (table 3 3 anyfunc) (elem (i32.const 1) $_Z18address_taken_funciii $_Z19address_taken_func2iii) (memory $0 2) @@ -16,6 +17,7 @@ (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (func $_Z18address_taken_funciii (; 1 ;) (type $5) (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) ) (func $_Z19address_taken_func2iii (; 2 ;) (type $5) (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) diff --git a/test/lld/reserved_func_ptr.wast.jscall.out b/test/lld/reserved_func_ptr.wast.jscall.out index 02166bf6c..cdcbfe159 100644 --- a/test/lld/reserved_func_ptr.wast.jscall.out +++ b/test/lld/reserved_func_ptr.wast.jscall.out @@ -25,8 +25,9 @@ (import "env" "jsCall_v" (func $jsCall_v (param i32))) (import "env" "jsCall_vi" (func $jsCall_vi (param i32 i32))) (import "env" "jsCall_viii" (func $jsCall_viii (param i32 i32 i32 i32))) - (global $global$0 (mut i32) (i32.const 66560)) - (global $global$1 i32 (i32.const 66560)) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 66112)) + (global $global$2 i32 (i32.const 568)) (table 21 21 anyfunc) (elem (i32.const 1) $_Z18address_taken_funciii $_Z19address_taken_func2iii $jsCall_ddi_0 $jsCall_ddi_1 $jsCall_ddi_2 $jsCall_fffi_0 $jsCall_fffi_1 $jsCall_fffi_2 $jsCall_iii_0 $jsCall_iii_1 $jsCall_iii_2 $jsCall_v_0 $jsCall_v_1 $jsCall_v_2 $jsCall_vi_0 $jsCall_vi_1 $jsCall_vi_2 $jsCall_viii_0 $jsCall_viii_1 $jsCall_viii_2) (memory $0 2) @@ -34,6 +35,7 @@ (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) @@ -292,3 +294,4 @@ ) ) ) +;; METADATA: { "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"], "jsCallStartIndex": 2, "jsCallFuncType": ["ddi", "fffi", "iii", "v", "vi", "viii"] } diff --git a/test/lld/reserved_func_ptr.wast.out b/test/lld/reserved_func_ptr.wast.out index 983269810..a8c09a443 100644 --- a/test/lld/reserved_func_ptr.wast.out +++ b/test/lld/reserved_func_ptr.wast.out @@ -9,8 +9,9 @@ (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$viii (func (param i32 i32 i32))) (import "env" "_Z4atoiPKc" (func $_Z4atoiPKc (param i32) (result i32))) - (global $global$0 (mut i32) (i32.const 66560)) - (global $global$1 i32 (i32.const 66560)) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 66112)) + (global $global$2 i32 (i32.const 568)) (table 3 3 anyfunc) (elem (i32.const 1) $_Z18address_taken_funciii $_Z19address_taken_func2iii) (memory $0 2) @@ -18,6 +19,7 @@ (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "main" (func $main)) (export "__heap_base" (global $global$1)) + (export "__data_end" (global $global$2)) (export "stackSave" (func $stackSave)) (export "stackAlloc" (func $stackAlloc)) (export "stackRestore" (func $stackRestore)) @@ -153,3 +155,4 @@ ) ) ) +;; METADATA: { "asmConsts": {},"staticBump": 0, "initializers": ["__wasm_call_ctors"] } |