summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* Update lld test expectations (#1960)Sam Clegg2019-03-2112-250/+722
|
* Discover and run unit tests from check.py (#1948)Thomas Lively2019-03-192-0/+18
| | | | | | unittest is Python's standard testing framework, so this change allows arbitrary tests to be written without introducing any new dependencies or code in check.py. A new test that was not possible to write before is also included. It is the first of many.
* improve zlib test (#1953)Alon Zakai2019-03-192-5132/+3559
| | | | | Recreate it using --extract-function which turns unwanted functions into exports. This avoids weirdness with them having empty function bodies and the inliner taking advantage of that. Also uses updated LLVM, which no longer has incorrectly identified irreducible control flow here.
* Add export count to --metrics (#1954)Sam Clegg2019-03-196-0/+52
| | | | Also, always output high level metrics even when zero.
* Update v128.const text formats (#1934)Thomas Lively2019-03-1914-1782/+1852
| | | | | Parse the formats allowed by the spec proposal and emit the i32x4 canonical format.
* add AssemblyScript n-body benchmark test (#1951)Alon Zakai2019-03-182-0/+3024
|
* Add strip-target-features pass (#1946)Thomas Lively2019-03-142-0/+3
| | | And run it in wasm-emscripten-finalize. This will prevent the emscripten output from changing when the target features section lands in LLVM.
* Add BinaryenConstGetValueV128 to C/JS-API (#1931)Daniel Wirtz2019-03-132-0/+6
| | | | | | | This PR adds void BinaryenConstGetValueV128(BinaryenExpressionRef expr, uint8_t* out); to the C-API and uses it in Binaryen.getExpressionInfo in the JS-API.
* wasm-emscripten-finalize: Remove JSCall thunk generation (#1938)Sam Clegg2019-03-121-359/+0
| | | | We now implement addFunction by creating a wasm module to wrap that JS function and simply adding it to the table.
* Optimize away sets of the same local (#1940)Alon Zakai2019-03-0742-930/+186
|
* Fix getExitingBranches, which had |targets| instead of |curr->targets| (#1936)Alon Zakai2019-03-072-0/+43
| | | | | | | That caused it to miss switch targets, and a code-folding bug. Fixes #1838 Sadly the fuzzer didn't find this because code folding looks for very particular code patterns that are unlikely to be emitted randomly.
* add testAlon Zakai2019-03-062-0/+8043
|
* CoalesceLocals: run even if we have just 1 var, as we may be able to remove ↵Alon Zakai2019-03-0619-77/+127
| | | | that one var by reusing a param
* Optimize added constants with propagation only if we see we will remove all ↵Alon Zakai2019-03-0627-13853/+12976
| | | | uses of the original add, as otherwise we may just be adding work (both an offset, and an add). Refactor local-utils.h, and make UnneededSetRemover also check for side effects, so it cleanly removes all traces of unneeded sets.
* Run multiple iterations in OptimizeAddedConstantsAlon Zakai2019-03-0611-13577/+13566
| | | | | Multiple propagations may be possible in some cases, like nested structs in C.
* Propagate a load/store offset even if locals are not in ssa formAlon Zakai2019-03-0610-22447/+21937
| | | | | | | | | | | | | | | | | The initial OptimizeAddedConstants pass did not try to handle the case of non-ssa locals. However, that can happen, and optimizing those cases too improves us by almost 1% of code size on some large benchmarks like bullet. How this works is that if we see b = a + 10 a = c load(b) then we copy the base value at the add, a' = a b = a' + 10 a = c load(a', offset=10) This no longer has a guarantee of improving code size, since in theory both b and a may have other uses. However, in practice it's very common for b to be optimized out later.
* Don't create already-existing dynCalls (#1932)Alon Zakai2019-03-062-0/+51
| | | | | This can happen in emscripten if we run fpcast-emu after previous passes created dynCalls already. If so, it's fine to just do nothing. Fixes emscripten-core/emscripten#8229
* Align v128 text format with WABT (#1930)Daniel Wirtz2019-03-0410-1063/+1063
| | | | | | | | This PR changes the formatting of v128.const literals in text format / stack ir like so - v128.const i32 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x80 + v128.const i32 0x04030201 0x08070605 0x0c0b0a09 0x800f0e0d Recently hit this when trying to load Binaryen generated text format with WABT, which errored with `error: unexpected token 0x5, expected ).
* Consistently optimize small added constants into load/store offsets (#1924)Alon Zakai2019-03-0119-15126/+26046
| | | | | | | | | | | | | | | | | | | | | | | | | | See #1919 - we did not do this consistently before. This adds a lowMemoryUnused option to PassOptions. It can be passed on the commandline with --low-memory-unused. If enabled, we run the new optimize-added-constants pass, which does the real work here, replacing older code in post-emscripten. Aside from running at the proper time (unlike the old pass, see #1919), this also has a -propagate mode, which can do stuff like this: y = x + 10 [..] load(y) [..] load(y) => y = x + 10 [..] load(x, offset=10) [..] load(x, offset=10) That is, it can propagate such offsets to the loads/stores. This pattern is common in big interpreter loops, where the pointers are offsets into a big struct of state. The pass does this propagation by using a new feature of LocalGraph, which can verify which locals are in SSA mode. Binaryen IR is not SSA (intentionally, since it's a later IR), but if a local only has a single set for all gets, that means that local is in such a state, and can be optimized. The tricky thing is that all locals are initialized to zero, so there are at minimum two sets. But if we verify that the real set dominates all the gets, then the zero initialization cannot reach them, and we are safe. This PR also makes safe-heap aware of lowMemoryUnused. If so, we check for not just an access of 0, but the range 0-1023. This makes zlib 5% faster, with either the wasm backend or asm2wasm. It also makes it 0.5% smaller. Also helps sqlite (1.5% faster) and lua (1% faster)
* Optimize normally with debug info (#1927)Alon Zakai2019-02-285-95/+82
| | | | | * optimize normally with debug info - some of it may be removed, but that's the price of higher optimization levels, and by optimizing normally in profiling and -g2 etc. builds they are more comparable to normal ones, yielding better data * copy debug locations automatically in replaceCurrent in wasm-traversal, so optimization passes at least by default will preserve debuggability
* Simplify ExpressionAnalyzer (#1920)Alon Zakai2019-02-272-2/+2
| | | | | This refactors the hashing and comparison code to use a single immediate-value iterator. This makes us have a single place that knows the list of immediate fields in every node type, instead of 2. This also fixes a few bugs found by doing that. In particular, this makes us slightly slower than before since we are hashing more fields.
* Dead return value elimination in DeadArgumentElimination (#1917)Alon Zakai2019-02-2617-5857/+4902
| | | | | | | * Finds functions whose return value is always dropped, and removes the return. * Run multiple iterations of the pass, as one can enable others. * Do not run DeadArgumentElimination at all if debug info is present (with these improvements, it became much more likely to destroy debug info). Saves 2.5% on hello world, because of some simple libc calls.
* Vacuum unused values (#1918)Alon Zakai2019-02-252-0/+269
| | | | | | | | | | | | | | Checks if a value is being dropped higher up, like ``` (drop (block i32 (block i32 (i32.const 1) ) ) ) ``` Handling this forces us to be careful in that pass about whether a value is used, and whether the type matters (for example, we can't replace a unary with its child in all cases, if the return value matters).
* SmallVector (#1912)Alon Zakai2019-02-252-0/+69
| | | | | Trying to refactor the code to be simpler and less redundant, I ran into some perf issues that it seems like a small vector, with fixed-size storage and optional additional storage as needed, might help with. This implements that class and uses it in a few places. This seems to help, I see some 1-2% fewer instructions and cycles in `perf stat`, but it's hard to tell if it really makes a noticeable difference.
* NaN fuzzing improvements (#1913)Alon Zakai2019-02-194-36/+689
| | | | | | | | | * make DE_NAN avoid creating nan literals in the first place * add a reducer option `--denan` to not introduce nans in destructive reduction * add a `Literal::isNaN()` method * also remove the default exception logging from the fuzzer js glue, which is a source of non-useful VM differences (like nan nondeterminism) * added an option `--no-fuzz-nans` to make it easy to avoid nans when fuzzing (without hacking the source and recompiling). Background: trying to get fuzzing on jsc working despite this open issue: https://bugs.webkit.org/show_bug.cgi?id=175691
* legalize invokes even when doing minimal legalization, as js needs them (#1883)Alon Zakai2019-02-082-3/+24
| | | See [emscripten-core/emscripten#7679
* wasm-emscripten-finalize: separateDataSegments() fix (#1897)Alon Zakai2019-02-062-0/+0
| | | | | We should emit a file with only the data segments, starting from the global base, and not starting from zero (the data before is unneeded, and the emscripten loading code assumes it isn't there). Also fix the auto updater to work properly on .mem test updating.
* fix binaryen.js bindings handling of literals (#1896)Alon Zakai2019-02-062-0/+6
| | | The hardcoded 16 size was no longer valid. This was broken for a while, but happened to not overwrite important memory. Testing with the wasm backend did hit breakage.
* Bulk memory operations (#1892)Thomas Lively2019-02-059-172/+439
| | | | | | Bulk memory operations The only parts missing are the interpreter implementation and spec tests.
* Fix EM_ASM+pthreads (#1891)Alon Zakai2019-02-042-0/+117
| | | To calculate the metadata, we must look at the segments. If we split them out earlier (which we do for threads), they aren't there.
* Strip the producers section in --strip-producers (#1875)Alon Zakai2019-01-3110-0/+65
| | | | | | | | WebAssembly/tool-conventions#93 has a summary of emscripten's current thinking on this. For Binaryen, we don't want to do anything to the producers section by default, but do want it to be possible to optionally remove it. To achieve that, this PR * creates a --strip-producers pass that removes that section. * creates a --strip-debug pass that removes debug info, same as the old --strip, which is still around but deprecated. A followup in emscripten will use this pass by default.
* wasm-emscripten-finalize: Emit illegal dynCalls, and legalize them (#1890)Alon Zakai2019-01-293-43/+176
| | | Before this, we just did not emit illegal dynCalls. This was wrong as we do need them (e.g. if a function with a setjmp call calls a function with an i64 param - we'll have an invoke with that signature there). We just need to legalize them. This fixes that by first emitting them, and second by running legalization late, after dynCalls have been generated, so it legalizes them too.
* 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.