summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Return to more structured type rules for block and if (#1148)Alon Zakai2017-09-059-89/+123
| | | | | | | | * if a block has a concrete final element (or a break with a value), then even if it has an unreachable child, keep it with that concrete type. this means we no longe allow the silly case of a block with an unreachable in the middle and a concrete as the final element while the block is unreachable - after this change, the block would have the type of the final element * if an if has a concrete element in one arm, make it have that type as a result, even if the if condition is unreachable, to parallel block * make type rules for brs and switches simpler, ignore whether they are reachable or not. whether they are dead code should not affect how they influence other types in our IR.
* wasm-reduce tool (#1139)Alon Zakai2017-09-018-11/+711
| | | Reduce an interesting wasm to a smaller still interesting wasm. This takes an arbitrary command to run, and reduces the wasm as much as it can while keeping the behavior of that command fixed. This can be used to reduce compiler bugs in an arbitrary VM, etc.
* i64 to i32 lowering for wasm2asm (#1134)Thomas Lively2017-09-019-118/+1435
|
* Fix uninitialized members in Wasm2AsmBuilder::Flags (#1152)Sam Clegg2017-08-291-2/+2
|
* Merge pull request #1154 from WebAssembly/fuzzAlon Zakai2017-08-283-10/+21
|\ | | | | Fuzz fixes
| * improve fuzzing of functions with unreachable bodyAlon Zakai (kripken)2017-08-281-7/+7
| |
| * fix an inlining bug where a void function has an unreachable bodyAlon Zakai (kripken)2017-08-281-1/+10
| |
| * fix remove-unused-brs bug with merging br_ifs with unreachable codeAlon Zakai2017-08-281-2/+4
| |
* | Safe heap pass (#1145)Alon Zakai2017-08-285-0/+362
|/ | | Adds --safe-heap which instruments the code to check heap loads and stores for validity (null pointer derefs, within range of valid sbrk memory, and alignment). Used in SAFE_HEAP in emscripten.
* fix flow of values stopping in remove-unused-brs: we must remove all flows ↵Alon Zakai2017-08-251-5/+21
| | | | with a value from the current state, not just set the global state as to whether we can flow or not (as it will be set later by other things)
* avoid trying to optimize ifs with unreachable conditions in ↵Alon Zakai2017-08-251-2/+5
| | | | remove-unused-brs, as they are dead code anyhow, and it is pointless to work hard to handle the type changes
* quickly avoid all unreachable branching in ifsAlon Zakai2017-08-251-0/+5
|
* don't turn unreachable ifs into br_ifs, they are dead anyhow, and would need ↵Alon Zakai2017-08-251-0/+2
| | | | special handling to emit valid code
* set the type of a set_local properly when it is unreachableAlon Zakai2017-08-252-2/+6
|
* add an option to run an extra command when fuzzing in wasm-optAlon Zakai2017-08-251-13/+56
| | | | for now this is linux-only as it uses popen etc.
* add a chance to make a get_local in makeTrivial, so that hang-check returns ↵Alon Zakai (kripken)2017-08-251-5/+11
| | | | etc. don't always return a constant, but may return the result of computation
* increase fuzz hang limit (to basically the point where the spec interpreter ↵Alon Zakai (kripken)2017-08-251-1/+1
| | | | almost fails)
* Add support for atomic wait and wake operators (#1140)Derek Schuff2017-08-2412-2/+221
| | | According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
* Initial asm.js output for binaryen-c / binaryen.js (#1136)Daniel Wirtz2017-08-246-7/+42
| | | | * Added BinaryenModulePrintAsmjs (using wasm2asm) + Module#emitAsmjs JS binding
* Fuzzing improvement: Run execution results on the same instance (#1132)Alon Zakai2017-08-221-12/+27
| | | | | | | | * run execution results on the same instance, so side effects of memory writes persist, which is the same as when we run the code in a js vm, so we can directly compare * fuzz only exported functions, not things that opts might remove * note results in fuzz-exec by export name
* Inline many (#1125)Alon Zakai2017-08-222-64/+96
| | | | | | | * Improve inlining pass to inline single-use functions that are fairly small, which makes it useful for removing unnecessary global constructors from clang. * Add an inlining-optimizing pass that also optimizes where it inlined, as new opportunities arise. enable that it by default in O2+ * In addition, in -O3+ also inline small functions with multiple uses. This helps a lot with things like safe-int-divide functions (where each int divide is replaced by a safe divide that won't trap). Inlining gets rid of around half of the overhead there.
* Ignore unreachable code in wasm binaries (#1122)Alon Zakai2017-08-222-8/+66
| | | Ignoring unreachable code in wasm binaries lets us avoid corner cases with unstructured code in wasm binaries that is a poor fit for Binaryen's structured IR.
* Don't reorder an implicit trap with a global side effect (#1133)Alon Zakai2017-08-181-6/+10
|
* Do not export start function (#998)Daniel Wirtz2017-08-181-1/+0
|
* wasm2asm test generation (#1124)Thomas Lively2017-08-169-115/+300
| | | | | | | | | | | | | | | | | * Translate assert_return invokes to asm * Translate assert_trap tests to JS * Enable wasm2asm tests * Fix wasm2asm translation of store * Update ubuntu nodejs in Travis * Free JSPrinter buffer * Use unique_ptr for Functions to prevent leaks * Add tests for assert translation
* Emit optimal-size LEBs in section/subsection/function body sizes (#1128)Alon Zakai2017-08-152-12/+42
| | | | * emit optimal-size LEBs in section/subsection/function body sizes, instead of preallocating 5 bytes
* New fuzzer (#1126)Alon Zakai2017-08-117-83/+1448
| | | | | | This adds a new method of fuzzing, "translate to fuzz" which means we consider the input to be a stream of data that we translate into a valid wasm module. It's sort of like a random seed for a process that creates a random wasm module. By using the input that way, we can explore the space of valid wasm modules quickly, and it makes afl-fuzz integration easy. Also adds a "fuzz binary" option which is similar to "fuzz execution". It makes wasm-opt not only execute the code before and after opts, but also write to binary and read from it, helping to fuzz the binary format.
* when inlining, we must zero out non-param locals, as their initial zero ↵Alon Zakai2017-08-101-5/+11
| | | | value may be depended on (#1127)
* Improve and enable inlining pass (#966)Alon Zakai2017-08-076-52/+154
| | | | | | | | * improve inlining pass to inline single-use functions that are fairly small, which makes it useful for removing unnecessary global constructors from clang. add an inlining-optimizing pass that also optimizes where it inlined, as new opportunities arise. enable that it by default in O2+ * fix a bug where we didn't run all passes properly - refactor addDefaultGlobalOptimizationPasses() into a pre and post version. we can only run the post version in incremental optimizing builds (functions appear one by one, we optimize them first, and do global stuff when all are done), but can run both when doing a full optimize * copy in inlining, allowing multiple inlinings of the same function in the future
* Merge pull request #1123 from WebAssembly/fuzz-2Alon Zakai2017-08-075-35/+86
|\ | | | | Yet more fuzz fixes
| * properly handle merging of blocks with concrete unreachable elements in the ↵Alon Zakai2017-08-061-6/+10
| | | | | | | | middle
| * handle merging blocks with items after an unreachable, that if merged would ↵Alon Zakai2017-08-061-9/+6
| | | | | | | | be invalid. stop on the unreachable, it is easier and better
| * fix merge-blocks bug with replacing an unreachable block with a concrete ↵Alon Zakai2017-08-051-4/+5
| | | | | | | | final element (which is never reached)
| * don't turn untaken br_ifs into ifs in remove-unused-brsAlon Zakai2017-08-051-1/+3
| |
| * fix merge-blocks logic: ensure that optimize() does not change the outside typeAlon Zakai (kripken)2017-08-051-36/+67
| |
| * merge blocks in remove-unused-names only when their type is identical, so ↵Alon Zakai (kripken)2017-08-051-1/+1
| | | | | | | | branches to them are interchangeable
| * emit an unreachable if an unreachable block context does not end in an ↵Alon Zakai2017-08-051-0/+5
| | | | | | | | unreachable
| * fix reading of stacky unreadable code with elements we need to dropAlon Zakai (kripken)2017-08-052-16/+17
| |
| * don't move code around a drop-block when the block contains unreachables, ↵Alon Zakai2017-08-051-22/+32
| | | | | | | | which can cause type changes in the outside. dce should be run on that anyhow
* | wasm2asm i32 arithmetic support (#1120)Thomas Lively2017-08-076-35/+243
|/ | | * Rotations, popcnt, ctz, etc
* Get wasm2asm building again (#1107)Thomas Lively2017-08-028-109/+916
| | | | | | | | | | | | | | | | | | * Get wasm2asm building again Updates CMakeLists.txt to have wasm2asm built by default, updates wasm2asm.h to account for recent interface changes, and restores JSPrinter functionality. * Implement splice for array values * Clean up wasm2asm testing * Print semicolons after statements in blocks * Cleanups and semicolons for condition arms * Prettify semicolon emission
* fix off-by-one error in clz/ctz/popcount used bits computationAlon Zakai2017-08-011-2/+2
|
* fix proper wasm emitting of untaken br_tablesAlon Zakai2017-08-011-1/+9
|
* use effective shifts in more places in optimize-instructionsAlon Zakai (kripken)2017-08-013-7/+8
|
* Merge remote-tracking branch 'origin/master' into fuzzAlon Zakai (kripken)2017-07-311-1/+33
|\
| * Polymophic stack support (#1117)Alon Zakai2017-07-311-1/+33
| | | | | | | | | | | | | | Emit valid wasm binaries even for corner cases of unreachable code. * emit an unreachable after a node that pushes a value that has unreachable type (where wasm type checking would have pushed a concrete type) * conversely, as a hack, emulate the wasm polymorphic stack mode by not emptying the stack when it has one element and that element is unreachable. this lets further pops work (all returning an unreachable element)
* | review commentsAlon Zakai (kripken)2017-07-313-11/+11
| |
* | handle squared shifts of an unreachableAlon Zakai (kripken)2017-07-311-2/+2
| |
* | don't remove values from breaks if the values have side effectsAlon Zakai (kripken)2017-07-301-11/+23
| |
* | fix optimizing two shifts into one; if the number of effective shifts ↵Alon Zakai (kripken)2017-07-303-14/+41
| | | | | | | | overflows, it is not vali to just add them