summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* metadce fixes (#1329)Alon Zakai2017-12-071-37/+114
| | | | | | | | | | | | * ignore missing imports (the wasm may have already had them optimized out) * handle segments that hold on to globals (root them, for now, as we can't remove segments) * run reorder-functions, as the optimal order may have changed after we dce * fix global, global init, and segment offset reachability * fix import rooting and processing - imports may be imported more than once
* binaryen.js improvements (#1324)Alon Zakai2017-12-071-13/+17
| | | | * binaryen.js improvements: block default value is none, not undefined, and add text-format style aliases for things like getLocal (so you can write get_local as in the text format)
* wasm-metadce tool (#1320)Alon Zakai2017-12-063-1/+874
| | | | | | | This adds a new tool for better dead code elimination. The problem this helps overcome is when the wasm module is part of something larger, like a wasm+JS combination, and therefore doing DCE in either one is not sufficient as it can't remove a cycle spanning the wasm and JS worlds. Concretely, when binaryen performs DCE by itself, it can never remove an export, because it considers those roots - but in the larger ("meta") space outside, they may actually be removable. To solve that, this tool receives a description of the outside graph (in very abstract form), including which nodes are roots. It then adds to that graph nodes from the wasm, so that we have a single graph representing the entire space (the outside + wasm + connections between them). It then performs DCE, finding what is not reachable from the roots, and cleaning it up from the wasm. It of course can't clean up things from the outside, since all it has is the abstract representation of those things in the graph, but it prints out the ids of the removable nodes, which an outside tool can use. This tool is written in as general a way as possible, hopefully it can have multiple uses. The use I have in mind is to write something in emscripten that uses this to DCE the JS+wasm combination that we emit.
* support i*.extend* instructions in interpreter (#1322)Alon Zakai2017-12-062-15/+20
| | | * also fixes optimizing them in Precompute
* Handle debug info without a filename in asm2wasm (#1249)Alon Zakai2017-12-051-6/+29
| | | | * support debug info without a filename in asm2wasm input (which can happen if llvm doesn't know the file, only the line)
* support fixed (non-relocatable) segments in wasm-merge. also a few printing ↵Alon Zakai2017-12-053-13/+34
| | | | fixes for multiple segments, which we never really printed that prettily (#1316)
* br_if-to-table (#1313)Alon Zakai2017-12-042-6/+171
| | | | | | | | | | | | | | | Implements #1309: subsequent br_ifs that compare the same value to various constants are converted into a br_table in a block, (br_if $x (i32.eq (get_local $a) (i32.const 0))) (br_if $y (i32.eq (get_local $a) (i32.const 1))) (br_if $z (i32.eq (get_local $a) (i32.const 2))) ==> (block $tablify (br_table $x $y $z $tablify (get_local $a) ) ) The constants for when to apply this (e.g., not if the range of values would make a huge jump table) are fairly conservative, I think, but hard to tell. Probably should be tweaked based on our experience with the pass in practice later on.
* Fixed compilation in GCC 7 (#1301)Iban Eguia2017-11-301-1/+15
|
* De-morgan's "and" law (#1297)Alon Zakai2017-11-301-0/+26
| | | | | (eqz X) and (eqz Y) === eqz (X or Y) Normally de-morgan's laws apply only to boolean vars, but for the and (but not or or xor) version, it works in all cases (both sides are true iff X and Y have all zero bits).
* add invocation functions for fuzz functions, so they are tested with many ↵Alon Zakai2017-11-301-4/+36
| | | | input values (#1303)
* make sure we do not fold out code from blocks with a fallthrough value, and ↵Alon Zakai2017-11-301-4/+18
| | | | then since the parent blocks do not have such values, we can finalize them with their type as a concrete type should not vanish (#1302)
* JS: Make 'segments' optional in setMemory (#1310)Daniel Wirtz2017-11-291-0/+1
| | | Currenty throws if omitted, see AssemblyScript/binaryen.js#2
* Binary fuzz fix: disallow popping from outside a block (#1305)Alon Zakai2017-11-281-0/+6
| | | | | | * remove unneeded code to handle a br to the return from the function. Now that we use getBlockOrSingleton there, it does that for us anyhow * fix a fuzz bug of popping from outside a block
* Provide AddImport/AddExport for each element in the C-API (#1292)Daniel Wirtz2017-11-224-11/+175
| | | | * Provide AddImport/AddExport for each element in the C-API
* Fix reading breaks to the function exit (#1304)Alon Zakai2017-11-212-18/+5
| | | | * remove unneeded code to handle a br to the return from the function. Now that we use getBlockOrSingleton there, it does that for us anyhow
* name function imports using name section (#1290)Alon Zakai2017-11-212-21/+33
|
* Fix wasm-reduce testing out of tree (#1284)Alon Zakai2017-11-212-2/+61
| | | | * fix wasm-reduce when out-of-tree: do not use a hardcoded bin/wasm-opt, instead add a Path namespace with utilities to get the proper path, and use BINARYEN_ROOT which our test setup code ensures
* Running passes on a single function in binaryen-c/.js (#1295)Daniel Wirtz2017-11-213-2/+107
| | | * Also other function utilities in C and JS APIs
* Add atomic load/store to binaryen-c/.js (#1298)Daniel Wirtz2017-11-203-1/+67
|
* Fix a code-folding fuzz bug (#1282)Alon Zakai2017-11-172-2/+15
| | | | * fix a code-folding bug where when merging function-level tails, we moved code out of where it could reach a break target - we must not move code if it has a break target not enclosed in itself. the EffectAnalyzer already had the functionality for that, move the code around a little there to make that clearer too
* Flatten tee (#1296)Alon Zakai2017-11-171-1/+15
| | | | | * flatten tee_local in flatten, as it leads to more-optimizable code (tee_local, when nested, can introduce side effects in bad places). * also fix some test stuff from recent merges
* Fix if copying (#1278)Alon Zakai2017-11-162-6/+36
| | | | * fix if copying - we should preserve the forced explicit type if there is one, and not just infer it from the arms. this adds a builder method for makeIf that receives a type to apply to the if, and for blocks a method that makes a block from a list, also with a variant with a provided type
* Decouple wasm-linker from Emscripten glue (#1293)Jacob Gravelle2017-11-156-139/+170
|
* Add const expression utilities to binaryen-c/.js (#1288)Daniel Wirtz2017-11-153-0/+85
|
* add i64_atomics_* support to asm2wasm (#1262)Alon Zakai2017-11-143-1/+51
| | | | | | * add i64_atomics_* support to asm2wasm * OptimizeInstructions: atomic loads can't be signed
* accept overlapping segments (#1289)Alon Zakai2017-11-141-5/+2
|
* a stacky value in the middle of a block may be consumed (#1267)Alon Zakai2017-11-131-1/+20
|
* Update call_indirect text syntax to match spec update (#1281)Derek Schuff2017-11-132-2/+4
| | | | Function type gets its own element rather than being a part of the call_indirect (see WebAssembly/spec#599)
* Fix yet another BinaryenAddGlobal tracing issue (#1283)Daniel Wirtz2017-11-131-1/+1
| | | Now also includes a test.
* Add atomic ops to binaryen.js (#1280)Daniel Wirtz2017-11-131-0/+180
|
* Fast pass fuzzing (#1258)Alon Zakai2017-11-132-24/+85
| | | | * add fuzz-pass option, which picks random passes to fuzz in each wasm-opt invocation
* Added expression utility functions to binaryen-c/.js (#1269)Daniel Wirtz2017-11-113-0/+121
|
* Fixed use of undefined 'types' array in BinaryenAddGlobal tracing (#1279)Daniel Wirtz2017-11-101-1/+1
| | | | | | * Fixed use of undefined 'types' array in BinaryenAddGlobal tracing * also fix use of 'expressions'
* Rereloop fuzz fix (#1259)Alon Zakai2017-11-091-0/+12
| | | | * fix relooper bug, ensure function body has right type, as relooper output does not flow stuff out, but wasm functions with a result do expect a flow value, so none is not an option. in other words, as the docs say, a relooper block must end with a terminator (return, unreachable, break, etc.) and not flow out.
* Added BinaryenAtomic* incl. ops to binaryen-c (#1276)Daniel Wirtz2017-11-092-1/+57
| | | | | | * Added BinaryenAtomicRMW incl. ops to binaryen-c * AtomicCmpxchg, AtomicWait, AtomicWake
* fix wasm-reduce bug, the second validator param is the features, not the ↵Alon Zakai2017-11-091-1/+1
| | | | flags (#1277)
* Use 'BinaryenGlobalRef' instead of 'BinaryenImportRef' for globals in ↵Daniel Wirtz2017-11-072-2/+4
| | | | binaryen-c (#1270)
* Restrict validation output to just validation errors in the API (#1253)Daniel Wirtz2017-11-018-6/+25
| | | Do not print the entire and possibly very large module when validation fails. Leave printing to tools using the validator, instead of always doing it in the validator where it can't be overridden.
* Fix binaryen.js's wasm2asm (#1257)Alon Zakai2017-11-012-0/+55
| | | | * fix wasm2asm in binaryen.js, the function locals may not all have names, so add them as necessary
* Added the ability to run specific optimization passes to binaryen-c/.js (#1252)Daniel Wirtz2017-10-304-1/+32
|
* Print wasm2asm parsing errors (#1251)Alon Zakai2017-10-271-12/+22
|
* Add Features enum to IR (#1250)Derek Schuff2017-10-2711-12/+41
| | | | | | | | | | | | This enum describes which wasm features the IR is expected to include. The validator should reject operations which require excluded features, and passes should avoid producing IR which requires excluded features. This makes it easier to catch possible errors in Binaryen producers (e.g. emscripten). Asm2wasm has a flag to enable or disable atomics. Other tools currently just accept all features (as, dis and opt are just for inspecting or modifying existing modules, so it would be annoying to have to use flags with those tools and I expect the risk of accidentally introducing atomics to be low).
* notation change: AST => IR (#1245)Alon Zakai2017-10-2467-156/+157
| | | The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
* Improve constant fuzzing (#1244)Alon Zakai2017-10-241-5/+8
| | | | | Generalize constant emitting in fuzzer, using +-1 and *+-1 effects to create more constants in a convenient way. Also workaround for a gcc-7.2/windows issue that we don't fully understand, but removing the 1, -1 from those pick() calls avoids the bug.
* Fix atomics refinalization (we were missing some glue) (#1241)Alon Zakai2017-10-242-2/+118
| | | | And add a visitor which must override all its elements, so this never happens again
* fix safe-heap regression with handling of existing imports (#1237)Alon Zakai2017-10-241-2/+2
|
* Remove unused PassOptions from wasm-ctor-eval.cpp (#1238)Taiju Tsuiki2017-10-241-1/+0
| | | |passOptions| in wasm-ctor-eval.cpp causes a compile failure, -Wunused-variable on the clang build.
* add a timeout param to wasm-reduce (#1230)Alon Zakai2017-10-231-2/+11
|
* only look at the |signed| field of loads if it is relevant (#1235)Alon Zakai2017-10-233-6/+53
|
* Emit binary function index in comment in text format, for convenience (#1232)Alon Zakai2017-10-204-30/+76
|