summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Let s2wasm emit binary output (#1465)Jacob Gravelle2018-03-0896-96/+96
| | | | | | | | | | | | | | | | | | | | * Emit invokeFuncs list as metadata * Refactor s2wasm to use ModuleWriter * Fix wasm-emscripten-finalize metadata output for binary output * Add a flag to emit binary from s2wasm NOTE: I chose to emit text by default, and binary behind a flag. This mismatches with asm2wasm (and the expectations of users of a "2wasm" tool), but doesn't break any existing users of s2wasm. If s2wasm is deprecated in favor of lld, this will be the least disruptive change, and we won't have to live with awkward defaults for too long. * Emit source maps in the binary output of s2wasm * Only emit binary with an outfile specified
* Allow small names in test/passes (#1450)Alon Zakai2018-03-053-0/+1
| | | | | * allow tests in test/passes/ to have a numeric name, in which case there is a name.passes file with the names instead of the name containing the passes (which might be long, see #1020)
* eliminate multiple return statements for wasm2asm functions (#1448)Nathan Froyd2018-03-0115-204/+101
| | | | This change eliminates one issue that prevents asm.js validation of the generated code, see #1443.
* Drop 'start' in RemoveUnusedModuleElements if the function is empty (#1449)Daniel Wirtz2018-02-282-3/+22
| | | | | | * Drop start function in RemoveUnusedModuleElements if empty * Update tests and dist files
* Fuzz parameter improvements: more params&vars (#1451)Alon Zakai2018-02-281-979/+1030
|
* Flexible param numbers in asm2wasm (#1439)Alon Zakai2018-02-277-0/+183
| | | | | | | | | | * refactor BINARYEN_PASS_DEBUG code for writing byn-* files, make it easy to emit binaries instead of text * fix up bad argument numbers in asm2wasm. This can be caused by undefined behavior on the LLVM side, which happens to work natively. it's nicer to fix it up like it would be in a native build, and give a warning, instead of failing to compile * update build-js.sh * updated builds
* EM_JS binaryen support (#1410)Jacob Gravelle2018-02-262-0/+79
| | | | | | | | | | | * Emit EM_JS metadata * Include s2wasm-style em_js support * Change em_js metadata to be keyed on name * Add testcase for em_js, don't always emit emJsFuncs metadata * Better error handling for unexpectedly-formatted __em_js__ functions
* fix and implement more unary ops (#1442)Nathan Froyd2018-02-262-0/+313
| | | | | | | | | | | | | | | | | | * add tests for i32.popcnt * lower i64.popcnt * add tests for i64.extend_u/i32 * lower i64.extend_s/i32 * fix lowering i64.eqz * lower i64.eqz more efficiently * add tests for i32.clz/i32.ctz * lower i64.clz/i64.ctz
* Generate all s2wasm metadata in binaryen (#1440)Jacob Gravelle2018-02-2695-95/+95
| | | | | | | | | * Extract comma-handling logic into a lambda function * Start emitting all metadata from binaryen - handle declares and externs * Add implementedFunctions and exports metadata * Remove EM_ASM calls from declares
* fix an ssa bug: we can't assume that even if all set locations assign to the ↵Alon Zakai2018-02-222-10/+125
| | | | same local that it is ok to read that local, as locals may also be written elsewhere (#1423)
* ensure unique import names for each type, by giving them a prefix, avoiding ↵Alon Zakai2018-02-228-57/+57
| | | | collisions between say a global import and a function with a name from the name section that happens to match it (#1424)
* Add i64 high bits (tempRet0) helper funcs when legalizing JS interface (#1428)Alon Zakai2018-02-2214-0/+165
| | | | * add tempRet0 helpers when necessary in legalize-js-interface
* Improve name mangling of asm.js identifiers (#1433)Daniel Wirtz2018-02-2114-925/+925
| | | | | | Also refactors mangling to its own file so it can be reused by generators and consumers, i.e., where it is important to know that an import must be named 'switch_' where it otherwise would be 'switch'. * Update tests and JS dist files
* wasm2asm fixes (#1436)Alon Zakai2018-02-201-6/+6
| | | | | | * don't look for asm.js compilation message if almost asm * fix wasm2asm f32 operations
* better handling of float ops in wasm2asm (#1427)Nathan Froyd2018-02-152-0/+378
| | | | | | | | | | | | | | | | | | | | * explicitly handle binary float operations in processFunctionBody We weren't handling them before, but it wasn't obvious. Make the (non-) handling of them explicit in the code. We'll add handlers for them shortly. * add handling for simple binary float operations min, max, and copysign will require more sophisticated handling. * add handling for float comparisons * move float min/max handling to the correct place It was previously grouped with the i32 ops. * handle float promotion and demotion
* implement lowering for i64 subtraction (#1429)Nathan Froyd2018-02-142-0/+169
| | | | | | | | | * fix lowering of i64 adds We're not permitted to reuse the input as temporary variables for the results. Weird things happen otherwise. * add support for lowering i64 subtraction
* add wasm2asm lowering for 64-bit signed comparisons (#1421)Nathan Froyd2018-02-142-0/+485
| | | Plus some tests, to make sure we implemented things correctly.
* Fold wasm-link-metadata into wasm-emscripten-finalize (#1408)Jacob Gravelle2018-02-1422-77/+99
| | | | | | | * 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
* More simple math opts (#1414)Alon Zakai2018-02-148-80/+289
| | | | | | | | * optimize more simple math operations: mul of 0, or of 0, and of 0, mul of 1, mul of a power of 2, urem of a power of 2 * fix asm2wasm callImport parsing: the optimizer may get rid of the added offset to a function table * update js builds
* Fix safe-heap bounds checking (#1415)Alon Zakai2018-02-121-185/+185
| | | | | * fix safe heap check for load/store of fewer bytes than the type
* Emscripten addFunction support for Wasm backend (#1395)Heejin Ahn2018-02-0710-0/+1083
| | | This adds necessary command line options for addFunction support, and generates required jsCall imports and generates jsCall thunk functions.
* Dedupe function names when reading a binary (#1396)Jacob Gravelle2018-02-064-0/+26
| | | | | | | | * Dedupe function names when reading a binary * More robust name deduplication, use .s instead of _s * Add name-duplicated wasm binaries
* Update wasm2asm to generate "almost asm" if grow_memory is used (#1340)Kris Selden2018-02-065-0/+176
| | | | | | | | | | * Allow wasm2asm to generate "almost asm" If grow_memory, current_memory or export memory is used then generate "almost asm" with memory growth support. * Log reason for "almost asm" to stderr
* Note isAtomic in loads and stores (#1406)Alon Zakai2018-02-052-0/+33
| | | | | | * check isAtomic in comparisons * hash isAtomic
* Inlining improvements (#1397)Alon Zakai2018-02-028-327/+392
| | | | | | | Simplify inlining logic: don't special case the first iteration or change behavior based on when we are optimizing or not. Instead, use one simpler set of heuristics for both inlining and inlining-optimizing. We only run inlining-optimizing by default anyhow, no point to try to make inlining without optimizations useful by itself, it's not a realistic use case. (inlining is still useful for debugging, and if you will run optimizations anyhow later on everything, in which case inlining-optimizing might add some redundancy.) The simpler heuristics after this let us do a somewhat better job as we are no longer paranoid about inlining in multiple iterations. Also raise limit on inlining things that are obviously worth it from size 1 to size 2: things of size 2 will never lead to an increase in code size after we optimize (it takes at least 3 nodes to generate something that reads two locals and reverses their order, which would require a temp local in the outside scope etc.). Also fix infinite recursion of inlining an infinitely recursive set of calls.
* Fix hard-wired buffer limit in the JS API (#1394)Daniel Wirtz2018-02-011-1/+1
|
* Sourcemap support for Binaryen C/JS (#1392)Daniel Wirtz2018-01-292-0/+47
| | | | | | * Initial source map support for C/JS * Also test getDebugInfoFileName
* ThreadPool refactoring (#1389)Alon Zakai2018-01-262-0/+62
| | | | | | | | Refactor ThreadPool code for clarity and to fix some bugs with using the pool from different threads in parallel. We have a singleton pool, and need to ensure it is created only once and used only by one thread at a time. This model is a simple way to ensure we use a number of threads equal to the number of cores, more or less (a pool per Module might lead to number of cores * number of Modules being optimized). This refactoring adds a parent pointer in the worker threads (giving them direct access to the pool makes it simpler to make sure that pool and thread creation and teardown are threadsafe). This commit also adds proper locking around pool creation and pool usage.
* Inlining improvements (#1375)Alon Zakai2018-01-2420-860/+381
| | | | | | * inline 1-element functions when optimizing, as they will be smaller than the call we are replacing * add an extra useful vacuum after inlining+optimizing
* Improve LocalGraph (#1382)Alon Zakai2018-01-242-0/+243
| | | | | This simplifies the logic there into a more standard flow operation. This is not always faster, but it is much faster on the worst cases we saw before like sqlite, and it is simpler. The rewrite also fixes a fuzz bug.
* Show the binary bytes we can remove without each export, in --func-metrics ↵Alon Zakai2018-01-233-12/+185
| | | | | | | | (#1379) * show the binary bytes we can remove without each export, in --func-metrics * check start too
* First pass at LLD support for Emscripten (#1346)Jacob Gravelle2018-01-2220-0/+564
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Skeleton of a beginning of o2wasm, WIP and probably not going to be used * Get building post-cherry-pick * ast->ir, remove commented out code, include a debug module print because linking * Read linking section, print emscripten metadata json * WasmBinaryWriter emits user sections on Module * Remove debugging prints, everything that isn't needed to build metadata * Rename o2wasm to lld-metadata * lld-metadata support for outputting to file * Use tables index instead of function index for initializer functions * Add lld-emscripten tool to add emscripten-runtime functions to wasm modules (built with lld) * Handle EM_ASM in lld-emscripten * Add a list of functions to forcibly export (for initializer functions) * Disable incorrect initializer function reading * Add error printing when parsing .o files in lld-metadata * Remove ';; METADATA: ' prefix from lld-metadata, output is now standalone json * Support em_asm consts that aren't at the start of a segment * Initial test framework for lld-metadata tool * Add em_asm test * Add support for WASM_INIT_FUNCS in the linking section * Remove reloc section parsing because it's unused * lld-emscripten can read and write text * Add test harness for lld-emscripten * Export all functions for now * Add missing lld test output * Add support for reading object files differently Only difference so far is in importing mutable globals being an object file representation for symbols, but invalid wasm. * Update help strings * Update linking tests for stackAlloc fix * Rename lld-emscripten,lld-metadata to wasm-emscripten-finalize,wasm-link-metadata * Add help text to header comments * auto& instead of auto & * Extract LinkType to abi/wasm-object.h * Remove special handling for wasm object file reading, allow mutable globals * Add braces around default switch case * Fix flake8 errors * Handle generating dyncall thunks for imports as well * Use explicit bool for stackPointerGlobal * Use glob patterns for lld file iteration * Use __wasm_call_ctors for all initializer functions
* Optimize wasm-reduce (#1359)Alon Zakai2018-01-201-16/+16
|
* Also clear imports and exports maps in BinaryenModuleDispose (#1372)Daniel Wirtz2018-01-192-2/+2
| | | | | | fixes #1369 * Update binaries and kitchen-sink test
* optimize out 0-x, a zero only used to negate an int, when possible (#1365)Alon Zakai2018-01-1711-47/+97
|
* Refactor optimization defaults (#1366)Alon Zakai2018-01-172-2/+32
| | | | | Followup to #1357. This moves the optimization settings into pass.h, and uses it from there in the various places. This also splits up huge lines from the tracing code, which put all block children (whose number can be arbitrarily large) on one line. This seems to have caused random errors on the bots, I suspect from overflowing a buffer. Anyhow, it's much more clear to split the lines at a reasonable length.
* Global optimization fixes (#1360)Alon Zakai2018-01-1721-47675/+542
| | | | | | | | | | | | | | | | * run dfe at the very end, as it may be more effective after inlining * optimize reorder-functions * do a final dfe in asm2wasm after all other opts * make inlining deterministic: std::atomic<T> values are not zero-initialized * do global post opts at the end of asm2wasm, and don't also do them in the module builder * fix function type removing * don't inline+optimize when preserving debug info
* Add optimize, shrink level and debug info options to C/JS (#1357)Daniel Wirtz2018-01-1710-6/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add optimize, shrink level and debug info options to C/JS * Add instantiate functionality for creating additional unique instances of the API * Use a workaround when running tests in node Tests misuse a module as a script by concatenating, so instead of catching this case in the library, catch it there * Update sieve test Seems optimized output changed due to running with optimize levels 2/1 now * Use the options with all pass runners * Update relooper-fuzz C-API test * Share defaults between tools and the C-API * Add a test for optimize levels * Unify node test support in check.by and auto_update_tests.py * Also add getters for optimize levels and test them * Also test debugInfo * Add debug info to C tests that used it as well * Fix missing NODEJS import in auto_update_tests * Detect node.js version (WASM support) * Update hello-world JS test (now also runs with node) * feature-test WebAssembly in node instead * Document that these options apply globally, and where * Make sure hello-world.js output doesn't differ between mozjs/node
* update test/passes/func-metrics.txt after racing landingsAlon Zakai (kripken)2018-01-131-1/+0
|
* Function metrics pass (#1353)Alon Zakai2018-01-123-3/+152
| | | Emits binary size and opcode counts for each function, which helps investigating what's taking up space in a wasm binary.
* Update wasm-shell expected failures (#1268)Jacob Gravelle2018-01-101240-53307/+48164
| | | | | | | | * Update wasm-shell expected failures * Update waterfall revision, check.py waterfall test driver * Update torture-s files with latest from waterfall
* Optimize out memory and table when possible (#1352)Alon Zakai2018-01-10195-685/+779
| | | We can remove the memory/table (itself, or an import if imported) if they are not used. This is pretty minor on a large wasm file, but when reading small wasts it's very noticeable to have an unused memory and table all the time.
* Do not emit 100k data segments, browsers reject it (#1350)Alon Zakai2018-01-094-0/+406861
| | | | | Instead merge constant-offset segments if we must in order to stay under the limit. If we can't - too many non-constant-offset segments - then issue a warning.
* Redundant Set Elimination pass (#1344)Alon Zakai2018-01-0526-495/+776
| | | | This optimizes #1343. It looks for stores of a value that is already present in the local, which in particular can remove the initial set to 0 of loops starting at zero, since all locals are initialized to that already. This helps in real-world code, but is not super-common since coalescing means we tend to have assigned something else to it anyhow before we need it to be zero, so this mainly helps in small functions (and running this before coalescing would extend live ranges in potentially bad ways).
* Fix stackAlloc runtime function generation for wasm backend (#1348)Derek Schuff2018-01-0487-870/+783
| | | | It was returning the top of the allocated space rather than the bottom. Fix taken from @tbfleming in kripken/emscripten#5974
* Validation fixes for #1317 (#1347)Alon Zakai2018-01-036-2/+38
| | | | | | | * add get_global/set_global validation * validate get_local index * update builds * fix tests
* fix an infinite loop in fuzz testcase generation code (#1345)Alon Zakai2018-01-031-21/+3
|
* Fixes for #5998 (#1341)Alon Zakai2017-12-304-13/+35
| | | | | | | | | | | | | | * binaryen.js and wasm.js don't need filesystem support * newest emscripten no longer uses Runtime.* * build fixes for binaryen.js and wasm.js also move binaryen.js to use standard emscripten MODULARIZE * run binaryen.js in all possible engines ; update js builds * don't emit debug build to a different name, just emit binaryen.js. makes testing easier and safer * remove volatile things from binaryen.js info printing in tests
* SpillPointers pass (#1339)Alon Zakai2017-12-302-0/+812
| | | | | | | | | | | | | This is an experiment to help with Boehm-style GC. It will spill things that could be pointers to the C stack, so that they can be seen by conservative garbage collection. The spills add code size and runtime overhead, but actually less than I thought: 10% slower (smaller than the difference between VMs), 15% gzip size larger. We can do even better with more optimizations for this, like a dead store elimination pass. This PR does the following: * Add the new pass. * Create an abi/ dir, with info about the pointer size and stack manipulation utilities. * Separates out the liveness analysis from CoalesceLocals, so that other passes can use it (like SpillPointers). * Refactor out the SortedVector class from the liveness analysis to a separate file (just seems nicer that way).
* Add getters for various specific expression fields to C/JS (#1332)Daniel Wirtz2017-12-2011-229/+258
|