summaryrefslogtreecommitdiff
path: root/src/tools
Commit message (Collapse)AuthorAgeFilesLines
...
* Update v128.const text formats (#1934)Thomas Lively2019-03-191-1/+1
| | | | | Parse the formats allowed by the spec proposal and emit the i32x4 canonical format.
* Add sign-ext feature (#1947)Thomas Lively2019-03-151-0/+10
|
* Add strip-target-features pass (#1946)Thomas Lively2019-03-141-0/+1
| | | And run it in wasm-emscripten-finalize. This will prevent the emscripten output from changing when the target features section lands in LLVM.
* wasm-emscripten-finalize: Remove JSCall thunk generation (#1938)Sam Clegg2019-03-121-11/+1
| | | | We now implement addFunction by creating a wasm module to wrap that JS function and simply adding it to the table.
* Consistently optimize small added constants into load/store offsets (#1924)Alon Zakai2019-03-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* add an option to not fuzz memory (#1915)Alon Zakai2019-02-252-1/+23
|
* NaN fuzzing improvements (#1913)Alon Zakai2019-02-194-10/+55
| | | | | | | | | * 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
* if no output is specified to wasm-opt, warn that we are emitting nothing (#1908)Alon Zakai2019-02-151-1/+3
| | | | | | | | | | | | | | A user that just does ``` wasm-opt input.wasm -O ``` may assume that the input file should have been optimized. But without `-o` we don't emit any output. Often you may not want any output, like if you just want to run a pass like `--metrics`. But for most users wasm-opt is probably going to be used as an optimizer of files. So this PR suggests we emit a warning in that case. For comparison, `llvm-opt` would print to the console, but it avoids printing a binary there so it issues a warning. Instead of this warning, perhaps we should do the same? That would also not be confusing. Closes #1907
* wasm-emscripten-finalize: separateDataSegments() fix (#1897)Alon Zakai2019-02-061-1/+4
| | | | | 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.
* Bulk memory operations (#1892)Thomas Lively2019-02-052-2/+55
| | | | | | Bulk memory operations The only parts missing are the interpreter implementation and spec tests.
* Fix EM_ASM+pthreads (#1891)Alon Zakai2019-02-041-6/+9
| | | 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.
* wasm-emscripten-finalize: Emit illegal dynCalls, and legalize them (#1890)Alon Zakai2019-01-291-12/+15
| | | 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.
* Handle EM_ASM/EM_JS in LLVM wasm backend O0 output (#1888)Alon Zakai2019-01-281-8/+10
| | | | | | | 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-13/+21
| | | | | * 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-161-3/+17
| | | | | | 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.
* Code style improvements (#1868)Alon Zakai2019-01-152-2/+2
| | | | * Use modern T p = v; notation to initialize class fields * Use modern X() = default; notation for empty class constructors
* Compare binaryen fuzz-exec to JS VMs (#1856)Alon Zakai2019-01-103-38/+60
| | | | | | | | | | | 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.
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-101-1/+1
| | | | | This fixes the memory leak in WasmBinaryBuilder::readSignatures() caused probably the exception thrown there before the FunctionType object is safe. This also makes it clear that the Module becomes the owner of the FunctionType objects.
* Massive renaming (#1855)Thomas Lively2019-01-072-2/+2
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Don't emit simd in fuzzer unless requested (some code paths we missed) (#1849)Alon Zakai2019-01-021-17/+28
|
* Fix fuzzing JS glue code (#1843)Alon Zakai2018-12-272-1/+18
| | | | | | | | | 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
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-181-14/+14
|
* Partial legalization (#1824) review followup (#1832)Alon Zakai2018-12-171-1/+2
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-144-112/+253
| | | | * Fuzzing v128 and associated bug fixes
* Minimal JS legalization (#1824)Alon Zakai2018-12-142-9/+10
| | | | | 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.
* SIMD (#1820)Thomas Lively2018-12-134-7/+20
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Create API for feature dependent picking in fuzzer (#1821)Thomas Lively2018-12-121-36/+63
|
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-111-0/+1
|
* wasm-ctor-eval: handle the stack going either up or downAlon Zakai2018-12-111-10/+15
|
* constant refactoring for STACKTOP and STACK_MAXAlon Zakai2018-12-111-8/+8
|
* Wasm2js error handling improvement (#1807)Alon Zakai2018-12-061-22/+24
| | | Move the code around so the assertions are not caught in the big try-catch that reports errors as parsing errors.
* Format metadata json using mutliple lines for readability (#1804)Sam Clegg2018-12-051-1/+3
|
* Fix initializerFunctions output by wasm-emscripten-finalize (#1803)Sam Clegg2018-12-051-1/+2
| | | I broke this to be alwasy empty in #1795.
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-041-4/+32
|
* Feature options (#1797)Thomas Lively2018-12-038-40/+107
| | | | Add feature flags and struct interface. Default feature set has all feature enabled.
* wasm-emscripten-finalize: ensure table/memory imports use emscripten's ↵Sam Clegg2018-12-031-8/+17
| | | | | | | | 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-031-0/+1
| | | | 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.
* wasm-emscripten-finalize: Remove stack pointer global from shared libs (#1791)Sam Clegg2018-11-301-6/+15
| | | | | | | | | | | | | The wasm backend uses a wasm global (__stack_pointer) for the shadow stack location. In order to make this work with shared libraries the main module would have to export this global and shared libraries would need to import it. This means we'd be relying of mutable globals which are not yet implemented in all browsers. This change allows is to move forward with shared libraries without mutable global support by replacing all stack pointer access in shared libraries with functions calls.
* Fuzzing: log values during execution (#1779)Alon Zakai2018-11-302-7/+55
| | | | | | | | 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-301-0/+2
| | | | | This picks up from #1644 and indeed borrows the test case from there.
* Add v128 type (#1777)Thomas Lively2018-11-293-0/+15
|
* standardize on 'template<' over 'template <' (i.e., remove a space) (#1782)Alon Zakai2018-11-291-3/+3
|
* Remove default cases (#1757)Thomas Lively2018-11-273-21/+41
| | | | | | Where reasonable from a readability perspective, remove default cases in switches over types and instructions. This makes future feature additions easier by making the compiler complain about each location where new types and instructions are not yet handled.
* add an option to work on text files in wasm-reduce (#1772)Alon Zakai2018-11-271-6/+19
| | | Reducing on text files can be useful as in binaryen the binary reading and writing has some noticeable effects (due to wasm and binaryen IR not being identical, while the text format is a closer match.
* wasm-opt: Add an option to select generation of atomic opcodes at runtime ↵Benjamin Bouvier2018-11-161-1/+5
| | | | | (#1751) partially solves #1676.
* wasm-reduce: reduce switch targets (#1752)Alon Zakai2018-11-161-2/+21
| | | This tries to reduce by replacing targets with the default, and by shrinking the list of targets.
* wasm-emscripten-finalize: Initial support for handling shared libraries (#1746)Sam Clegg2018-11-151-13/+26
| | | | In this case we won't want generate any of the normal memory helper functions (they come from the main module).
* Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)Derek Schuff2018-11-141-0/+8
| | | | This writes the data section into a file suitable for use with emscripten's --memory-init-file flag
* Better fuzzing (#1735)Alon Zakai2018-11-131-10/+189
| | | | | | * Recombine function pieces after randomly generating them, by creating copies and moving them around. This gives a realistic probability to seeing duplicate expressions, which some optimizations look for, which otherwise the fuzzer would have almost never reached. * Mutate function pieces after recombination, giving not only perfect duplicates but also near-duplicates. These operations take into account the type, but not the nesting and uniqueness of labels, so we fix that up afterwards (when something is broken, we replace it with something trivial).
* Rename tableBase/memoryBase to __table_base/__memory_base (#1731)Sam Clegg2018-11-082-4/+4
|