summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Switch optimizations in remove-unused-brs (#1753)Alon Zakai2018-11-204-47/+95
| | | | | | * Switch optimizations in remove-unused-brs: thread switch jumps, and turn a switch with all identical targets into a br * refinalize in interm operations in remove-unused-brs, as we can be confused by it
* Reject all nonexistent instructions in sexp format (#1756)Thomas Lively2018-11-191-191/+869
|
* Fix a merge-blocks fuzz bug (#1755)Alon Zakai2018-11-192-58/+73
| | | | | | * Moving blocks into if arms may change the block type, and the code we had was written under the assumption that was not true. * Move block sinking merge-blocks => remove-unused-brs, as it's more natural there. that pass refinalizes everything anyhow
* Generate sexp instruction parser (#1754)Thomas Lively2018-11-193-292/+704
| | | Also fix broken tests surfaced by the new parser.
* 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.
* Use assert in addition to abort for WASM_UNREACHABLE (#1747)Thomas Lively2018-11-151-1/+2
| | | | This yields more useful information when something goes wrong.
* Optimize an if exit block into an if arm (#1749)Alon Zakai2018-11-152-1/+41
| | | If an if is enclosed in a block which is only used to exit one arm, move it into that arm, so it can be better optimized. Similar to what we did for loops in #1736.
* wasm-emscripten-finalize: Initial support for handling shared libraries (#1746)Sam Clegg2018-11-153-25/+36
| | | | In this case we won't want generate any of the normal memory helper functions (they come from the main module).
* Fix segment size validation for imported memories (#1745)Sam Clegg2018-11-151-2/+7
| | | | | | | | | | | Without this wasm-opt can't operation on emscripten-produced SIDE_MODULES's which have zero sized memory imports. Technically is not a validation failure if you have segments that are larger than your initial memory, regardless of whether you import them. For non-imported memories it can be helpful though, so leaving it in to catch those errors.
* Don't try to optimize away unused names in RemoveUnusedBrs (#1750)Alon Zakai2018-11-152-2/+2
| | | | | Rely on the dedicated pass for that. It's not worth the extra complexity to try, as we can't easily handle all the cases anyhow. Add another run of the dedicated name-removing pass in the default passes.
* Avoid segfault when printing null nameThomas Lively2018-11-151-3/+3
| | | | `strpbrk` segfaults when `name.str` is nullptr, so check first.
* MergeBlocks: canonicalize loop exit block position on the inside (#1736)Alon Zakai2018-11-141-1/+19
| | | | * move a loop exit block (block with a name, and one child which is the loop) into the loop in MergeBlocks, as that is better for other passes
* Handle EM_ASM functions in Tables (#1739)Jacob Gravelle2018-11-141-7/+27
| | | | | Not at all sure why we're seeing any there, but it's easy enough to handle that we might as well.
* Restructure ifs with a value (#1743)Alon Zakai2018-11-141-20/+70
| | | We previously had code to recreate an if from a block+branch when possible, but not when the block had a return value. This PR adds support to restructure that too, into an if with a value.
* clean up unnecessary type setting in binary format loading - finalize() will ↵Alon Zakai2018-11-141-62/+61
| | | | do it properly later (#1744)
* ReFinalize fix (#1742)Alon Zakai2018-11-141-14/+52
| | | | | | | Handle a corner case in ReFinalize, which incrementally re-types code after changes. The problem is that if we need to figure out the type of a block, we look to the last element flowing out, or to breaks with values. If there is no such last element, and the breaks are not taken - they have unreachable values - then they don't tell us the block's proper type. We asserted that in such a case the block still had a type, and didn't handle this. To fix it, we could look on the parent to see what type would fit. However, it seem simpler to just remove untaken breaks/switches as part of ReFinalization - they carry no useful info anyhow. After removing them, if the block has no other signal of a concrete type, it can just be unreachable. This bug existed for at least 1.5 years - I didn't look back further. I think it was noticed by the fuzzer now due to recent fuzzing improvements and optimizer improvements, as I just saw this bug found a second time.
* Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)Derek Schuff2018-11-144-0/+31
| | | | This writes the data section into a file suitable for use with emscripten's --memory-init-file flag
* Modernize relooper code (#1738)Alon Zakai2018-11-132-177/+176
| | | Use c++11 auto, iterators, etc.
* Fix alignment in MixedAllocator (#1740)Alon Zakai2018-11-133-21/+32
| | | Necessary for simd, as we add a type with alignment >8. We were just broken on that before this PR.
* 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).
* fix flipping in dataflow graph generation (#1732)Alon Zakai2018-11-081-8/+8
| | | For souper we need to flip some operations in DataFlow IR, since souper doesn't have any redundant ones. But we flipped not just left and right but also equal/not equal, which was wrong.
* Rename tableBase/memoryBase to __table_base/__memory_base (#1731)Sam Clegg2018-11-084-14/+14
|
* Fix a merge-blocks fuzz bug (#1730)Alon Zakai2018-11-081-1/+18
| | | | | | | | | | | | | | | If a block has code after an unreachable element, it makes merging to an outer block tricky - the child block may be unreachable, but the parent have a return type, (block (result i32) .. (block (unreachable) (nop) ) ) It's ok to end an unreachable block with a nop, but not a typed one. To avoid this, if a child block has dce-able code, just ignore it.
* Fix a DataFlowOpts bug (#1729)Alon Zakai2018-11-072-8/+10
| | | | | | | We create some fake nodes for internal use, and were looking at one by mistake. This fixes that by * Creating a non-ambiguous fake node, a call (which represents an unknown value properly, unlike a zero which we had before). * Make DFO not rely on those values, if it knows a node is constant, apply those constant values. Found by the fuzzer.
* Fix a bug with (add (sub 0 X) Y) => (sub Y X) (#1727)Alon Zakai2018-11-073-3/+27
| | | | | We need to verify that the reordering is valid if there are side effects. Original bug report: https://groups.google.com/forum/?nomobile=true#!topic/emscripten-discuss/HIlGf8o2Ato
* wasm-ctor-eval: Hard error if requested ctor does not exist (#1728)Sam Clegg2018-11-061-1/+5
| | | | | Not being able to evaluate a ctor is different to that ctor being absent. This is masked a bug in emscripten where we were spelling the names of the ctors wrong on the command line.
* add support for new call_indirect syntax ; fixes #1724 (#1725)Alon Zakai2018-11-051-8/+29
|
* Suppress the 'has StackIR' comment when printing StackIR (#1726)Daniel Wirtz2018-11-041-1/+1
| | | Follow-up to #1717
* Fix asm2wasm handling of HEAP8[x >> 2] (#1720)Alon Zakai2018-11-021-1/+13
| | | | | | fixes kripken/emscripten#1718 The way fastcomp emits compareExchange is a little odd, we just need to ignore the shift.
* Don't call static desructors when Fatal() errors occur (#1722)Sam Clegg2018-11-022-3/+6
| | | | | This was causing a deadlock while destroying the thread pool.
* Add pass to minify import and export names (#1719)Alon Zakai2018-11-014-0/+173
| | | | | | | | | This new pass minifies import and export names, for example, this may minify (import "env" "longname" (func $internal)) to (import "env" "a" (func $internal)) By updating the JS that provides those imports/calls those exports, we can use the minified names properly. This can save a useful amount of space in the wasm and JS, see kripken/emscripten#7414
* Emit imports before defined things in text format (#1715)Alon Zakai2018-11-012-5/+42
| | | | | That is the correct order in the text format, wabt errors otherwise. See AssemblyScript/assemblyscript#310
* Add Module#emitStackIR to the JS-API (#1717)Daniel Wirtz2018-10-311-0/+10
| | | Related to #1716 (comment)
* Add missing include guard (#1713)Michał Janiszewski2018-10-291-0/+1
|
* Expand asmConsts metadata to fit the shape of proxying async EM_ASMs (no ↵Jacob Gravelle2018-10-251-0/+6
| | | | actual support) (#1711)
* comment on nondeterminism in precompute pass [ci skip] (#1704)Alon Zakai2018-10-161-0/+5
|
* Support 4GB Memories (#1702)Alon Zakai2018-10-158-22/+29
| | | This fixes asm2wasm parsing of the max to allow 4GB, and also changes the internal Memory::kMaxValue values to reflect that. We used to use kMaxValue to also represent "no limit", so I split that out into kUnlimitedValue.
* properly handle unreachable atomic operations, fixes a regression from #1693 ↵Alon Zakai2018-10-111-2/+2
| | | | (#1696)
* Shared memory support for add memory import and set memory functions. (#1686)Nidin Vinayakan2018-10-113-10/+13
|
* Add BinaryenRemoveGlobal / Module.removeGlobal to C/JS API (#1692)Daniel Wirtz2018-10-093-0/+14
|
* No atomic float operations (#1693)Alon Zakai2018-10-052-5/+19
| | | | | SafeHeap was emitting them, but it looks like they are invalid according to the wasm-threads spec. Fixes kripken/emscripten#7208
* Add initial/maximum table size parameters to C/JS API (#1687)Daniel Wirtz2018-09-283-9/+11
|
* More #1678 fixes (#1685)Alon Zakai2018-09-204-4/+15
| | | While debugging to fix the waterfall regressions I noticed that wasm-reduce regressed. We need to be more careful with visitFunction which now may visit an imported function - I found a few not-well-tested passes that also regressed that way.
* fix an iterator invalidation regression from #1678 (#1684)Alon Zakai2018-09-201-5/+24
| | | Fixes the 3 regressions mentioned in a comment on #1678
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-1960-1654/+1299
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* Add debug information locations to the function prolog/epilog (#1674)Yury Delendik2018-09-177-78/+154
| | | | | | | The current patch: * Preserves the debug locations from function prolog and epilog * Preserves the debug locations of the nested blocks
* fix sign detection of a floating-point mod ; fixes kripken/emscripten#7123 ↵Alon Zakai2018-09-151-1/+1
| | | | (#1681)
* Note that calls to imports are not lightweight in inlining pass (#1673)Alon Zakai2018-09-121-0/+5
| | | | * call_import is not lightweight for inlining purposes - we had call but not callimport, which is even less light
* Misc tiny fuzz fixes (#1668)Alon Zakai2018-09-124-2/+12
| | | | | | | | | | | | * show a proper error for an empty asm2wasm input * handle end of input in processExpressions in binary reading * memory segment sizes should be unsigned * validate input in wasm-ctor-eval * update tests