summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* use iteration in ExpressionAnalyzer::flexibleEqual, for less manual work on ↵Alon Zakai2019-02-041-70/+16
| | | | each new node
* Strip the producers section in --strip-producers (#1875)Alon Zakai2019-01-316-13/+32
| | | | | | | | 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-292-21/+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.
* Increase FuncCastEmulation NUM_PARAMS (#1884)Will Glynn2019-01-291-1/+1
| | | | | | | | | | 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-282-18/+57
| | | | | | | 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 all function indexes in binary reading (#1887)Alon Zakai2019-01-241-3/+3
| | | fixes bug reported in comment on e63c4a7 , #1885 (comment) , #1879 (comment)
* Validate unique local names, and use validation in wasm2js. Fixes #1885 (#1886)Alon Zakai2019-01-235-13/+27
| | | | | * 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).
* More misc ASAN fixes (#1882)Alon Zakai2019-01-224-0/+11
| | | | | | | | | | * fix buffer overflow in simple_ast.h printing. * check wasm binary format reading of function export indexes for errors. * check if s-expr format imports have a non-empty module and base. Fixes #1876 Fixes #1877 Fixes #1879
* Show a proper error on an invalid type in binary reading ; fixes #1872 (#1874)Alon Zakai2019-01-191-2/+2
|
* Emscripten stack simplification (#1870)Alon Zakai2019-01-164-20/+26
| | | | | | 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.
* Misc minor ASAN fixes (#1869)Alon Zakai2019-01-162-7/+14
| | | | | | | | | | * handle end of input in skipWhitespace in s-parser. fixes #1863 * ignore debug locations when not in a function ; fixes #1867 * error properly on invalid user section sizes ; fixes #1866 * throw a proper error on invalid call offsets in binary reading ; fixes #1865
* Code style improvements (#1868)Alon Zakai2019-01-1523-102/+108
| | | | * 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-104-39/+61
| | | | | | | | | | | 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-101-0/+2
| | | | | 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.
* Fix build on macOS High Sierra 10.13.1 and Xcode 9.2 (9C40b), which does not ↵juj2019-01-101-0/+4
| | | | have aligned_alloc() (not sure if newer macOS/Xcodes do, or if this an issue with old macOS/Xcode version) (#1862)
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-109-26/+23
| | | | | 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.
* Aligned allocation fixes. Fixes #1845 (#1846)Alon Zakai2019-01-092-8/+64
| | | | | | | | | | | | | | The error in #1845 shows: /<<PKGBUILDDIR>>/src/mixed_arena.h: In member function 'void* MixedArena::allocSpace(size_t, size_t)': /<<PKGBUILDDIR>>/src/mixed_arena.h:125:43: error: 'new' of type 'MixedArena::Chunk' {aka 'std::aligned_storage<32768, 16>::type'} with extended alignment 16 [-Werror=aligned-new=] chunks.push_back(new Chunk[numChunks]); ^ /<<PKGBUILDDIR>>/src/mixed_arena.h:125:43: note: uses 'void* operator new [](std::size_t)', which does not have an alignment parameter /<<PKGBUILDDIR>>/src/mixed_arena.h:125:43: note: use '-faligned-new' to enable C++17 over-aligned new support It turns out I had misread the aligned_storage docs, and they don't actually do what we need, which is a convenient cross-platform way to do aligned allocation, since new itself doesn't support that. Sadly it seems there is no cross-platform way to do it right now, so I added a header in support which abstracts over the windows and everything-else ways. Also add some ctest testing, which runs on windows, so we get basic windows coverage in our CI.
* Remove interp and fix tests (#1858)Alon Zakai2019-01-081-548/+0
| | | 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-081-4/+12
| | | Don't depend on the hash values for ordering - use a fixed order based on order of appearance.
* Massive renaming (#1855)Thomas Lively2019-01-0736-627/+641
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* determinism fix for SSAify::computeGetsAndPhis (#1850)Alon Zakai2019-01-031-3/+3
|
* Don't emit simd in fuzzer unless requested (some code paths we missed) (#1849)Alon Zakai2019-01-021-17/+28
|
* Determinism fix for SSA pass (#1841)Alon Zakai2019-01-021-7/+6
| | | We iterated over a set. Instead, iterate over the relevant items in their order in the IR.
* Refactor Features code (#1848)Alon Zakai2019-01-023-4/+183
| | | Add features.h which centralizes all the feature detection code. (I'll need this in another place than the validator which is where it was til now.)
* Minor code style cleanups (#1844)Alon Zakai2019-01-022-26/+25
|
* Fix fuzzing JS glue code (#1843)Alon Zakai2018-12-273-1/+21
| | | | | | | | | 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-212-2/+17
| | | 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-191-0/+4
| | | | | | | 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.
* Use interned Names in NoExitRuntime (#1837)Alon Zakai2018-12-191-8/+8
|
* remove-unused-brs: do not flow a value through a block if the block does not ↵Alon Zakai2018-12-181-6/+18
| | | | actually flow a value. fixes #1833 (#1835)
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-1817-159/+159
|
* Do not attempt to optimize v128s yet (#1834)Thomas Lively2018-12-181-12/+15
| | | Until the `Abstract` interface gains a notion of SIMD lanes, these optimizations will crash on v128 types.
* Partial legalization (#1824) review followup (#1832)Alon Zakai2018-12-174-6/+8
|
* Fix i64 select lowering. (#1773)Yury Delendik2018-12-171-8/+31
|
* Consistent spacing around the namespace keyword (#1829)Alon Zakai2018-12-153-0/+6
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-1411-198/+362
| | | | * Fuzzing v128 and associated bug fixes
* wasm-emscripten-finalize: Delay function creation until after module walk ↵Sam Clegg2018-12-141-2/+11
| | | | | | | (#1828) This fixes a crash where startSave/stackRestore could be created while iterating through `module.functions`.
* Minimal JS legalization (#1824)Alon Zakai2018-12-147-52/+121
| | | | | 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-141-0/+1
| | | | This allows emscripten to generate table of the correct size. Right now is simply defaults to creating a table to size 1024.
* wasm-emscripten-finalize: Don't add a table max if none is present in the ↵Sam Clegg2018-12-141-3/+6
| | | | | | input (#1825)
* SIMD (#1820)Thomas Lively2018-12-1334-1140/+5819
| | | | | | | | | 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-137-5/+68
| | | 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-8/+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...
* Create API for feature dependent picking in fuzzer (#1821)Thomas Lively2018-12-122-48/+69
|
* Update wrap and demote literal op names (#1817)Thomas Lively2018-12-123-22/+16
| | | | | | * Update literal op names * Remove `demoteToF32` in favor of `demote`
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-113-5/+25
|
* 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-113-8/+12
|
* Use template magic for tracing expressions (#1815)Thomas Lively2018-12-101-89/+106
|
* Fix comment in src/ir/module-utils.h (#1810)Sam Clegg2018-12-071-2/+4
| | | | | Followup from #1808