summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Increase FuncCastEmulation NUM_PARAMS (#1884)Will Glynn2019-01-291-16/+24
| | | | | | | | | | FuncCastEmulation supports a hardcoded number of parameters: // This should be enough for everybody. (As described above, we need this // to match when dynamically linking, and also dynamic linking is why we // can't just detect this automatically in the module we see.) static const int NUM_PARAMS = 15; Turns out 15 is not enough for everybody: Ruby 2.6.0 needs NUM_PARAMS = 16. This patch is necessary to support Ruby 2.6.0 in WebAssembly, and in fact is the only patch needed to make the relevant build process work with an otherwise normal emscripten toolchain.
* Handle EM_ASM/EM_JS in LLVM wasm backend O0 output (#1888)Alon Zakai2019-01-284-0/+270
| | | | | | | See emscripten-core/emscripten#7928 - we have been optimizing all wasms until now, and noticed this when the wasm object file path did not do so. When not optimizing, our methods of handling EM_ASM and EM_JS fail since the patterns are different. Specifically, for EM_ASM we hunt for emscripten_asm_const(X, where X is a constant, but without opts it may be a get of a local. For EM_JS, the function body may not just contain a const, but a block with a set of the const and a return of a get later. This adds logic to track gets and sets in basic blocks, which is sufficient to handle this.
* Validate unique local names, and use validation in wasm2js. Fixes #1885 (#1886)Alon Zakai2019-01-234-5/+5
| | | | | * Also fixes some bugs in wasm2js tests that did not validate. * Rename FeatureOptions => ToolOptions, as they now contain all the basic stuff each tool needs for commandline options (validation yes or no, and which features if so).
* Emscripten stack simplification (#1870)Alon Zakai2019-01-1616-18/+54
| | | | | | This takes advantage of the recent memory simplification in emscripten, where JS static allocation is done at compile time. That means we know the stack's initial location at compile time, and can apply it. This is the binaryen side of that: * asm2wasm support for asm.js globals with an initial value var X = Y; where Y is not 0 (which is what the stack now is). * wasm-emscripten-finalize support for a flag --initial-stack-pointer=X, and remove the old code to import the stack's initial location.
* Compare binaryen fuzz-exec to JS VMs (#1856)Alon Zakai2019-01-105-38/+55
| | | | | | | | | | | The main fuzz_opt.py script compares JS VMs, and separately runs binaryen's fuzz-exec that compares the binaryen interpreter to itself (before and after opts). This PR lets us directly compare binaryen's interpreter output to JS VMs. This found a bunch of minor things we can do better on both sides, giving more fuzz coverage. To enable this, a bunch of tiny fixes were needed: * Add --fuzz-exec-before which is like --fuzz-exec but just runs the code before opts are run, instead of before and after. * Normalize double printing (so JS and C++ print comparable things). This includes negative zero in JS, which we never printed properly til now. * Various improvements to how we print fuzz-exec logging - remove unuseful things, and normalize the others across JS and C++. * Properly legalize the wasm when --emit-js-wrapper (i.e., we will run the code from JS), and use that in the JS wrapper code.
* Fix copying of globals (#1854)Alon Zakai2019-01-102-0/+29
| | | | | This broke when we refactored imports, as now Global has two more fields. Test is on --func-metrics, which depends on copying to compute some things.
* Remove interp and fix tests (#1858)Alon Zakai2019-01-082-12/+12
| | | Updates tests to the latest notation changes, and also remove wasm.js (see kripken/emscripten#7831 ) as we'd need to either rebuild it or update it for the new notation as well, and it's not used at this point.
* determinism fix for code-folding (#1852)Alon Zakai2019-01-083-6/+97
| | | Don't depend on the hash values for ordering - use a fixed order based on order of appearance.
* Massive renaming (#1855)Thomas Lively2019-01-07609-108529/+108529
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Fix SIMD test placement (#1853)Thomas Lively2019-01-061-2/+2
|
* Determinism fix for SSA pass (#1841)Alon Zakai2019-01-022-20/+22
| | | We iterated over a set. Instead, iterate over the relevant items in their order in the IR.
* Fix fuzzing JS glue code (#1843)Alon Zakai2018-12-273-11/+94
| | | | | | | | | After we added logging to the fuzzer, we forgot to add to the JS glue code the necessary imports so it can be run there too. Also adds legalization for the JS glue code imports and exports. Also adds a missing validator check on imports having a function type (the fuzzing code was missing one). Fixes #1842
* LocalCSE: Consider pass options, both size and cost (#1840)Alon Zakai2018-12-216-0/+68
| | | With this we can optimize redundant global accesses fairly well (at least locally; licm also works), see #1831
* Do not precompute v128 expressions (#1839)Thomas Lively2018-12-192-0/+11
| | | | | | | Without this change, sequences like `i32.const 0, i32x4.splat` will get precomputed to v128.const ops, which are much larger and also not implemented in V8 yet. Until we have SIMD-aware optimization passes or at least engine support for v128.const, do not perform such transformations.
* remove-unused-brs: do not flow a value through a block if the block does not ↵Alon Zakai2018-12-182-8/+63
| | | | actually flow a value. fixes #1833 (#1835)
* Fix i64 select lowering. (#1773)Yury Delendik2018-12-174-9/+85
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-141-697/+386
| | | | * Fuzzing v128 and associated bug fixes
* Minimal JS legalization (#1824)Alon Zakai2018-12-142-0/+54
| | | | | Even when we don't want to fully legalize code for JS, we should still legalize things that only JS cares about. In particular, dynCall_* methods are used from JS to call into the wasm table, and if they exist they are only for JS, so we should only legalize them. The use case motivating this is that in dynamic linking you may want to disable legalization, so that wasm=>wasm module calls are fast even with i64s, but you do still need dynCalls to be legalized even in that case, otherwise an invoke with an i64 parameter would fail.
* wasm-emscripten-finalize: Add tableSize to metadata (#1826)Sam Clegg2018-12-149-0/+9
| | | | This allows emscripten to generate table of the correct size. Right now is simply defaults to creating a table to size 1024.
* SIMD (#1820)Thomas Lively2018-12-1314-1237/+13383
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* No exit runtime pass (#1816)Alon Zakai2018-12-132-0/+47
| | | When emscripten knows that the runtime will not be exited, it can tell codegen to not emit atexit() calls (since those callbacks will never be run). This saves both code size and startup time. In asm2wasm the JSBackend does it directly. For the wasm backend, this pass does the same on the output wasm.
* Don't error on too many locals - just oom (#1822)Alon Zakai2018-12-131-0/+0
| | | I think I added this error for fuzzing, but it is harmful as it prevents a module with too many locals from being loaded - if we could load it, we might be able to optimize it to have fewer locals...
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-119-9/+18
|
* wasm-ctor-eval: handle the stack going either up or downAlon Zakai2018-12-113-0/+33
|
* Use template magic for tracing expressions (#1815)Thomas Lively2018-12-102-16/+16
|
* Remove unused tests from test/dot_s (#1814)Sam Clegg2018-12-0740-3383/+0
| | | | We have a bug open (#1813) to verify that we don't loose coverage but there is no point in keeping these unused files for now.
* Format metadata json using mutliple lines for readability (#1804)Sam Clegg2018-12-059-9/+336
|
* Fix initializerFunctions output by wasm-emscripten-finalize (#1803)Sam Clegg2018-12-058-8/+8
| | | I broke this to be alwasy empty in #1795.
* Properly optimize loop values (#1800)Alon Zakai2018-12-0515-5794/+5885
| | | Remove the existing hack, and optimize them just like we do for ifs and blocks. This is now able to handle a few more cases than before.
* remove unnecessary constraint on remove-unused-br optimization of if-br-* ↵Alon Zakai2018-12-043-8/+51
| | | | into br_if,* - we can handle a concretely typed if as well, which can happen at the end of a block (#1799)
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-0411-1472/+1513
|
* Run coalesce-locals after the final simplify-locals.Alon Zakai (kripken)2018-12-0418-3618/+3431
| | | | | | We now emit more sets and tees of if-elses from simplify-locals, and coalesce-locals is necessary to remove them if they are ineffectual, that is, if no get will read them.
* Improve selectification in remove-unused-brsAlon Zakai (kripken)2018-12-045-52/+89
| | | | | | | | We turned an if into a select when optimizing for size (and if side effects etc. allow so). This patch improves that, doing it not just when optimizing for size, but also when it looks beneficial given the amount of work on both sides of the if. As a result we can create selects in -O3 etc.
* Speculate in simplify-locals that it is worth turning an if intoAlon Zakai (kripken)2018-12-0422-3226/+3608
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | an if-else. If an if sets a local, (if (..condition..) (set_local $x (..value..)) ) we can turn it into (set_local $x (if (..condition..) (..value..) (get_local $x) ) ) This increases code size and adds a branch in the if, but allows the set to be optimized into a tee or optimized out entirely. In the worst case, other optimizations can break up an if with a copy in one of its arms later. Includes a determinism fix for EquivalentSets, which this patch triggered.
* Move if copy logic from coalesce-locals to remove-unused-brs.Alon Zakai (kripken)2018-12-043-22/+332
| | | | | | | | | | | | | | | | | | | | | | | If copies is the case where an if arm is a get that feeds into a set of the same local: (set_local $x (if (result i32) (..condition..) (..result) (get_local $x) ) ) We can rework this so that the if-else is only an if, which executes the code path not going to the get. This was done in coalesce-locals only because it is likely to work there as after coalescing there are more copies. However, the logic is of removing a branch, and so belongs in remove-unused-brs, and fits alongside existing logic there for handling ifs with an arm that is a br. Also refactor that code so that the two optimizations can feed into each other.
* wasm-emscripten-finalize: ensure table/memory imports use emscripten's ↵Sam Clegg2018-12-038-16/+16
| | | | | | | | expected names (#1795) This means lld can emscripten can disagree about the naming of these imports and emscripten-wasm-finalize will take care of paper over the differences.
* Add --strip that removes debug info (#1787)Alon Zakai2018-12-032-0/+15
| | | | This is sort of like --strip on a native binary. The more specific use case for us is e.g. you link with a library that has -g in its CFLAGS, but you don't want debug info in your final executable (I hit this with poppler now). We can make emcc pass this to binaryen if emcc is not building an output with intended debug info.
* Fuzzing: log values during execution (#1779)Alon Zakai2018-11-302-793/+1092
| | | | | | | | Before we just looked at function return values when looking for differences before and after running some passes, while fuzzing. This adds logging of values during execution, which can represent control flow, monitor locals, etc., giving a lot more opportunities for the fuzzer to find problems. Also: * Clean up the sigToFunctionType function, which allocated a struct and returned it. This makes it safer by returning the struct by value, which is also easier to use in this PR. * Fix printing of imported function calls without a function type - turns out we always generate function types in loading, so we didn't notice this was broken, but this new fuzzer feature hit it.
* Add support for a mutable globals as a Feature (#1785)Sam Clegg2018-11-306-0/+63
| | | | | This picks up from #1644 and indeed borrows the test case from there.
* Add v128 type (#1777)Thomas Lively2018-11-294-3/+6
|
* LocalCSE fuzz fix: invalidate the set operations too (#1778)Alon Zakai2018-11-282-0/+43
| | | | | We invalidated based on effects of set values, but not of the sets themselves. Without that, a set could be overridden by something irrelevant and we thought we could still reuse the old value. Before this PR, the testcase would have the last set's value be optimized into a get, incorrectly.
* Start to implement #1764 (#1776)Alon Zakai2018-11-282-0/+145
| | | | | | This adds a first instance of the rules discussed in #1764 , specifically, x == y || x > y => x >= y
* Stricter Canonicalization (#1774)Alon Zakai2018-11-2727-19858/+20422
| | | In OptimizeInstructions we canonicalized a const on the right side. This PR adds further canonicalization, of a get to the right, and of sorting by binary and unary op ids. This guarantees fixed orders for small combinations of instructions that can then be pattern-matched in a simple way in future PRs.
* ReFinalize fuzz fix (#1771)Alon Zakai2018-11-272-0/+45
| | | | | | If we refinalize after adding a value that flows out of a block, we need to fix up any branches that might exist without a value, which is possible if the branches were not taken in practice Also refactor ReFinalize into a separate file.
* Relooper: Merge consecutive blocks (#1770)Alon Zakai2018-11-269-441/+590
| | | That is, A -> B where no other branches go to B. In that case we are guaranteed to not increase code size.
* Branches only invalidate side effects (#1765)Alon Zakai2018-11-264-7118/+7115
| | | Previously we assumed that we can't reorder a branching instruction and anything else. However, the only risk is when the other thing has side effects.
* Merge-Blocks improvements (#1760)Alon Zakai2018-11-2613-11394/+11917
| | | | | | | | | | | | | | | | | | | | | | Previously we didn't try to merge a block into the parent if the block had a name. This lets us merge part of it, that is: (block (..a..) (block $child (..b..) (.. some br to $child ..) (..c..) ) ) => (block (..a..) (..b..) ;; moved out (block $child (.. some br to $child ..) (..c..) ) ) This is beneficial for 2 reasons: the child may now be a singleton, so we can remove the block; or, now that we canonicalized the br-containing code to the head of the child, we may be able to turn it into an if.
* Merge pull request #1761 from juj/minify_exportsjuj2018-11-222-0/+15024
|\ | | | | minify_exports
| * Adjust MinifyImportsAndExports to optionally minify the export names, ↵Jukka Jylänki2018-11-222-0/+15024
| | | | | | | | sometimes that is not desirable.
* | Relooper CFG optimizations (#1759)Alon Zakai2018-11-2126-558/+3066
|/ | | | | | | | | | | | | | | | Previously the relooper would do some optimizations when deciding when to use an if vs a switch, how to group blocks, etc. This PR adds an additional pre-optimization phase with some basic but useful simplify-cfg style passes, * Skip empty blocks when they have just one exit. * Merge exiting branches when they are equivalent. * Canonicalize block contents to make such comparisons more useful. * Turn a trivial one-target switch into a simple branch. This can help in noticeable ways when running the rereloop pass, e.g. on LLVM wasm backend output. Also: * Binaryen C API changes to the relooper, which now gets a Module for its constructor. It needs it for the optimizations, as it may construct new nodes. * Many relooper-fuzzer improvements. * Clean up HashType usage.