summaryrefslogtreecommitdiff
path: root/src/passes
Commit message (Collapse)AuthorAgeFilesLines
* Exporting/importing debug location information from .wast/.asm.js/.s formats ↵Yury Delendik2017-06-011-2/+7
| | | | | | | | (#1017) * Extends wasm-as, wasm-dis and s2wasm to consume debug locations. * Exports source map from asm2wasm
* relooper improvementsAlon Zakai (kripken)2017-05-201-0/+3
|
* use TypeUpdater in vacuumAlon Zakai (kripken)2017-05-201-30/+33
|
* afl-fuzz bug fixes (#1018)Alon Zakai2017-05-201-0/+3
| | | | | | | | * values cannot flow through an if without an else, they never return a value * check pass tests in pass-debug mode too * add missing finalization in binary reading
* Address review feedback for #1014 (#1016)Alon Zakai2017-05-182-5/+5
| | | | | | * address review feedback for #1014
* optimize dceing of blocks and known-to-exist children (#1015)Alon Zakai2017-05-181-57/+34
|
* Validate finalization (#1014)Alon Zakai2017-05-1812-65/+127
| | | | | | | * validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
* optimize if and select in the case their values are identical (#1013)Alon Zakai2017-05-171-0/+39
|
* Re-reloop pass (#1009)Alon Zakai2017-05-164-11/+331
| | | | | This adds a pass that converts to a CFG, runs the relooper, and re-generates wasm from that. This depends on flatten-control-flow being run before. The main goal here is to help code generators other than asm2wasm (which already receives relooped code from fastcomp).
* Parallelize istring creation (#1008)Alon Zakai2017-05-161-28/+8
| | | | | | | | * parallelize istring creation, by having a thread-local set and a global set guarded by a mutex. each time a new string shows up in a thread, it will be added to that thread's set, after accessing the global set through the lock first, which means we lock at most once per new string per thread * don't leak strings in istring store * since we now create names in a parallel thread-safe manner, we don't need to pre-create names in RelooperJumpThreading
* merge blocks before and after remove-unused-brsAlon Zakai (kripken)2017-05-101-1/+2
|
* allow values to flow out of loops in RemoveUnneededBrs, and simplify some ↵Alon Zakai (kripken)2017-05-101-12/+4
| | | | unnecessary complexity in that pass as well
* Flatten control flow pass (#999)Alon Zakai2017-05-104-0/+474
| | | | | | | | | | | This pass flattens out control flow in order to achieve 2 properties: * Control flow structures (block, loop, if) and control flow operations (br, br_if, br_table, return, unreachable) may only be block children, a loop body, or an if-true or if-false. (I.e., they cannot be nested inside an i32.add, a drop, a call, an if-condition, etc.) * Disallow block, loop, and if return values, i.e., do not use control flow to pass around values. As a result, expressions cannot contain control flow, and overall control flow is simpler, more structured, and more "flat". This should make things like re-relooping wasm code much easier, as they can run after the cfg is flattened
* fix an afl-fuzz bug where precompute alters a br to remove its condition, ↵Alon Zakai2017-05-081-0/+1
| | | | but does not properly modify the type (#1000)
* when creating blocks during dce, make sure they have the same type as before ↵Alon Zakai (kripken)2017-05-021-9/+14
| | | | the transformation, as the outside might care about that
* improve dce to handle more cases of nested unreachable code (#989)Alon Zakai2017-05-021-7/+41
| | | | | | | | | | * improve dce to handle more cases of nested unreachable code, in particular, when the child is unreachable in type but not an actual Unreachable node, e.g. if it's a br. in that case, we just need to verify that the br is not to us where we are a block or loop * handle unreachable switch conditions in dce * handle dce of br condition which is unreachable, and host arguments * handle dce of block i32 etc. which is actually unreachable
* handle a drop of an if with both arms unreachable, which is possible since ↵Alon Zakai2017-05-011-4/+2
| | | | wasm added if types, which mean the if can be i32 even if the arms are unreachable etc (#991)
* Add pass to instrument loads / stores. (#959)Michael Bebenita2017-04-294-0/+126
| | | | | | | | * Add pass to instrument loads / stores * Simplify instrumentation. * Document.
* ctor evaller (#982)Alon Zakai2017-04-281-1/+1
| | | | | Add wasm-ctor-eval, which evaluates functions at compile time - typically static constructor functions - and applies their effects into memory, saving work at startup. If we encounter something we can't evaluate at compile time in our interpreter, stop there. This is similar to ctor_evaller.py in emscripten (which was for asm.js).
* Preserve debug info through the optimizer (#981)Alon Zakai2017-04-282-1/+22
| | | | | | | | | | | | | | * add debugInfo option to passes, and use it to keep debug info alive through optimizations when we need it * add fib testcase for debug info * when preserving debug info, do not move code around call-imports, so debug info intrinsics remain stationary * improve wasm-module-building handling of the single-threaded case: don't create workers, which is more efficient and also nicer for debugging * process debug info in a more precise way, reordering it from being after the node (as it was a comment in JS) to before the node * remove unreachable hack for debug info, which is no longer needed since we reorder them, and make sure to finalize blocks in which we reorder
* Replace text annotations with explicit file/line for debug info (#967)Derek Schuff2017-04-131-4/+5
| | | Rather than storing debug info as text annotations, store explicit file and line information. This will make it easier to experiment with outputting other serializations or representations (e.g. source maps), and will allow outputting debug info for binaries as well.
* Fix comparisons of sign-extends to weird constants (#956)Alon Zakai2017-03-211-6/+31
| | | | * fix eq/ne of sign-ext with a constant, when the constant can never be equal to it as it has the effective sign bit but not the upper bits above it set, which the sign-ext would emit
* add a pass to log execution traces via instrumenting the code (#950)Alon Zakai2017-03-164-1/+80
|
* Wasm h to cpp (#926)jgravelle-google2017-03-105-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | * Move WasmType function implementations to wasm.cpp * Move Literal methods to wasm.cpp * Reorder wasm.cpp shared constants back to top * Move expression functions to wasm.cpp * Finish moving things to wasm.cpp * Split out Literal into its own .h/.cpp. Also factor out common wasm-type module * Remove unneeded/transitive includes from wasm.h * Add comment to try/check methods * Rename tryX/checkX methods to getXOrNull * Add missing include that should fix appveyor build breakage * More appveyor
* optimize pow (#934)Alon Zakai2017-03-101-0/+23
| | | | | | * optimize pow(x,2) => x*x * optimize pow(x, 0.5) => sqrt(x)
* fix sign-ext opt issues (#935)Alon Zakai2017-03-091-11/+15
| | | | | | * fix a bug where compared sign-exts of different sizes were turned into zero-exts * fix a bug where we consider an almost sign-ext as ok to change the sign of a load inside it, ignoring that the load has the extra shifting
* Local CSE (#930)Alon Zakai2017-03-084-0/+163
| | | Simple local common subexpression elimination. Useful mostly to reduce code size (as VMs do GVN etc.). Enabled by default in -Oz.
* do not merge a drop out of an if if the sides have different types, then the ↵Alon Zakai2017-02-281-5/+9
| | | | if would be invalid (#927)
* fix BINARYEN_PASS_DEBUG option (#908)Alon Zakai2017-02-234-5/+14
| | | | | * fix BINARYEN_PASS_DEBUG option * Add isNested property to passRunner
* Default Walker subclasses to using Visitor<SubType> (#921)jgravelle-google2017-02-2319-41/+41
| | | | Most module walkers use PostWalker<T, Visitor<T>>, let that pattern be expressed as simply PostWalker<T>
* read unknown users sections as binary data stored on the Module (#918)Alon Zakai2017-02-211-0/+5
|
* clean up raw pointer import->functionType, make it a Name like everything ↵Alon Zakai2017-02-173-10/+12
| | | | else (#915)
* finish PickLoadSigns passAlon Zakai2017-02-162-8/+10
|
* refactor sign/zero extension code into nice headers, and prepare ↵Alon Zakai2017-02-165-97/+134
| | | | PickLoadSigns pass
* fix and clean up fallthrough logic in OptimizeInstructionsAlon Zakai (kripken)2017-02-161-22/+18
|
* optimize a compare of a load_s and a sign-extend into a load_u and a cheaper ↵Alon Zakai (kripken)2017-02-161-0/+18
| | | | zero-extend
* take into account loads into local info in OptimizeInstructionsAlon Zakai (kripken)2017-02-161-7/+10
|
* use local info about maxBits and sign-extendedness in OptimizeInstructionsAlon Zakai (kripken)2017-02-161-11/+120
| | | | fix the maxBits of a signed load, which this uncovered - all the bits may be used in such a case
* remove unneeded masks using getMaxBitsAlon Zakai (kripken)2017-02-161-3/+16
|
* tiny refactoring in OptimizeInstructions, for clarityAlon Zakai (kripken)2017-02-161-7/+8
|
* fix fuzz testcase, xor maxBits is the max, not the minAlon Zakai (kripken)2017-02-161-2/+2
|
* handle fallthrough values in load_s/u and sign/zero-extend optimizationAlon Zakai (kripken)2017-02-161-6/+30
|
* handle load in getMaxBitsAlon Zakai (kripken)2017-02-161-0/+2
|
* handle tee_local in getMaxBitsAlon Zakai (kripken)2017-02-161-0/+3
|
* optimize out a sign-ext into a store of the same sizeAlon Zakai (kripken)2017-02-161-0/+6
|
* optimize out add/sub of 0Alon Zakai (kripken)2017-02-161-1/+9
|
* optimize sign-extends to a booleanAlon Zakai (kripken)2017-02-161-0/+4
|
* optimize sign-extends to eqzAlon Zakai (kripken)2017-02-161-0/+7
|
* optimize sign-extends to neAlon Zakai (kripken)2017-02-161-2/+2
|
* Optimize "squared" operations (#905)Alon Zakai2017-02-161-23/+86
| | | | * optimize 'almost' sign extends: when we can remove one entirely, then extra shifts can be left behind. with that in place, we can then optimize 'squared' operations like shl on shl, as doing so does not break our sign extend opts