summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Add out-of-tree build to travis (#1567)Sam Clegg2018-05-251-8/+15
|
* Cleanup scripts in scripts/test (#1566)Sam Clegg2018-05-2519-184/+236
| | | | | | | | | | Remove executable bit and #! from scripts that don't have entry point. Add missing licence test. Move arg parsing into a function. Remove legacy --only_prepare (with underscrore) argument.
* Fix embedwast.py for out-of-tree building (#1569)Sam Clegg2018-05-252-25/+39
|
* wasm2asm: Finish i64 lowering operations (#1563)Alex Crichton2018-05-2526-1284/+4915
| | | | | | | | | | | | | | | | | * wasm2asm: Finish i64 lowering operations This commit finishes out lowering i64 operations to JS with implementations of division and remainder for JS. The primary change here is to have these compiled from Rust to wasm and then have them "linked in" via intrinsics. The `RemoveNonJSOps` pass has been updated to include some of what `I64ToI32Lowering` was previously doing, basically replacing some instructions with calls to intrinsics. The intrinsics are now all tracked in one location. Hopefully the intrinsics don't need to be regenerated too much, but for posterity the source currently [lives in a gist][gist], although I suspect that gist won't continue to compile and work as-is for all of time. [gist]: https://gist.github.com/alexcrichton/e7ea67bcdd17ce4b6254e66f77165690
* Cleanup .gitignore (#1555)Sam Clegg2018-05-212-13/+11
| | | | As a followup I want to remove the test generated files from here by having the tests write elsewhere.
* wasm2asm: Finish f32/f64 operations (#1554)Alex Crichton2018-05-1941-1541/+2314
|
* Fix optimizing equivalent locals bug introduced in #1540 (#1556)Alon Zakai2018-05-173-7/+40
| | | Don't skip through flowing tee values, just drop the current outermost which we find is redundant. the child tees may still be necessary.
* wasm2asm: Implement float<->int conversions (#1550)Alex Crichton2018-05-1612-65/+1401
| | | | | | | | | This commit lifts the same conversion strategy that `emcc` takes to convert between floats point numbers and integers, and it should implement all the various matrices of i32/u32/i64/u64 to f32/f64 Some refactoring was performed in the i64->i32 pass to allow for temporary variables to get allocated which have types other than i32, but otherwise this contains a pretty direct translation of `emcc`'s operations to `wasm2asm`.
* Clean up printing code (#1548)Alon Zakai2018-05-153-36/+34
| | | | | * make the iostream overrides receive a reference, not a pointer (i.e., like e.g. LLVM IR printing works, and avoiding overriding printing of pointer addresses which is sort of odd) * move more code out of headers, especially unrelated headers.
* travis: Move flake8 to script phase (#1553)Sam Clegg2018-05-151-1/+1
| | | I mistakenly added to before_script.
* wasm-emscripten: Don't use debug names in implementedFunctions (#1537)Sam Clegg2018-05-1529-30/+32
| | | | | | | | | | | | | | implementFunctions should use the export names, not the internal/debug name for a function. This is especially imported with lld where the debug names are demanagled. implementFunctions should only contain functions that are accessible from outside the module. i.e. those that have been exported. There is no point in adding internal-only functions to this list as they won't be accessible from outside anyway. Tesed with emscripten using: ./tests/runner.py binaryen2.test_time
* Apply flake8 to remaining python code (#1542)Sam Clegg2018-05-154-362/+484
| | | | Also refactor auto_update_tests.py into functions to match check.py
* wasm2asm: Implement f32/f64.copysign (#1551)Alex Crichton2018-05-1510-0/+193
| | | | | | This commit implements the `copysign` instruction for the wasm2asm binary. The implementation here is a new pass which wholesale replaces `copysign` instructions with the equivalent bit ops and reinterpretation instructions. It's intended that this matches Emscripten's implementation of lowering here.
* In full-printing mode, print comments for control flow endings, to help ↵Alon Zakai2018-05-142-0/+25
| | | | | | | | | | | readability (#1552) Like this: (block $x .. ) ;; end block $x Also fix some current breakage on master.
* wasm2asm: Add math aliases for floor, ceil and sqrt (#1549)Daniel Wirtz2018-05-1422-40/+162
|
* Implement 64-bit rotation lowering for wasm2asm (#1545)Alex Crichton2018-05-143-2/+408
| | | | Not much fancy here, but rather each operation is naively lowered inline to the if/else chain to execute it.
* wasm2asm: Implement reinterpretation instructions (#1547)Alex Crichton2018-05-134-3/+159
| | | | | | | | | | | | | As mentioned in #1458 a naive implementation of these instructions is to round trip the value through address 0 in linear memory. Also pointed out in #1458 this isn't necessarily valid for all languages. For now, though, languages like Rust, C, and C++ would likely be horribly broken if valid data could be stored at low addresses, so this commit goes ahead and adds an implementation of the reinterpretation instructions by traveling data through address 0. This will likely need an update if a language comes a long which can validly store data in the first 8 bytes of linear memory, but it seems like that won't happen in the near future. Closes #1458
* Clean up wasm2asm testing (#1546)Alon Zakai2018-05-1317-10/+14
| | | | | * Move wasm2asm test outputs into their natural location, test/wasm2asm/ * Let people create new tests in there that ./auto_update_tests.py will auto-generate outputs for, just like all the other tests.
* Implement signed 64-bit shift right for wasm2asm (#1544)Alex Crichton2018-05-123-6/+268
| | | | Mostly piggy-back pon the previous 64-bit shift lowering code, just filling in a few gaps.
* Merge loop tails up (#1543)Alon Zakai2018-05-1019-7516/+8157
| | | | | | | | | | | | | | | E.g. ``` (block .. (loop $l .. (br_if $l (..)) .. code that does not branch to the loop top ) .. that code could be moved here .. ) ``` Moving the code out of the loop may help the loop body become a singleton expression, and is more readable anyhow.
* Move the renaming of llvm-generated __invoke_XX functions from s2wasm into ↵Sam Clegg2018-05-105-89/+147
| | | | | | | | | wasm-emscripten (#1539) This allows the same functionality to be used also in wasm-emscripten-finalize (i.e. the lld path).
* Optimize equivalent locals (#1540)Alon Zakai2018-05-1031-8040/+8367
| | | | | | | | | If locals are known to contain the same value, we can * Pick which local to use for a get_local of any of them. Makes sense to prefer the most common, to increase the chance of one dropping to zero uses. * Remove copies between a local and one that we know contains the same value. This is a consistent win, small though, around 0.1-0.2%.
* Fix MSVC warnings when compiling the binaryen target (#1535)Daniel Wirtz2018-05-098-24/+18
|
* A couple of fixes for out-of-tree builds (#1538)Sam Clegg2018-05-092-5/+5
|
* Add a way to remove function types to Binaryen-C/.js (#1536)Daniel Wirtz2018-05-084-0/+25
|
* More reducer improvements (#1533)Alon Zakai2018-05-088-264/+541
| | | | | | * Add a helper class to iterate over all a node's children, and use that when attempting to replace a node with its children. * If a child has a different type than the parent, try to replace the parent with a conversion + the child (for example, a call may receive two f32 inputs and return an i32; we can try to replace the call with one of those f32s and a conversion to an i32). * When possible, try to replace the function body with a child even if the child has a different type, by changing the function return value.
* Expose sign extension ops in Binaryen-C/.js (#1534)Daniel Wirtz2018-05-074-1/+36
|
* improve remove-unused-module-elements (#1532)Alon Zakai2018-05-048-13/+709
| | | | | Remove the entire memory/table when possible, in particular, when not imported, exported, or used. Previously we did not look at whether they were imported, so we assumed we could never remove them. Also add a variant that removes everything but functions, which can be useful when reducing a testcase that only cares about code in functions.
* reducer improvements: more if, block, loop and other node reduction attempts ↵Alon Zakai2018-05-041-0/+52
| | | | (#1530)
* misc minor cleanups in the codebase (#1531)Alon Zakai2018-05-043-2/+4
|
* add missing atomics to getExpressionName, which is used in --metrics (#1529)Alon Zakai2018-05-041-0/+4
|
* Fix some fuzz bugs (#1528)Alon Zakai2018-05-016-16/+150
| | | | | * remove-unused-brs: handle an if declared as returning a value despite having an unreachable condition * simplify-locals: don't work on loops while the main pass is making changes, as set_locals are being tracked and modified.
* Generate loop return values in optimizer (#1527)Alon Zakai2018-05-0113-2026/+2059
|
* More simplify-locals opts (#1526)Alon Zakai2018-05-0123-31714/+31855
| | | | | | * Use an if return value when one side is unreachable. * Undo an if return value if we can use a br_if instead
* --simplify-locals-nonesting (#1525)Alon Zakai2018-04-306-87/+578
| | | | | Add a version of simplify-locals which does not create nesting. This keeps the IR flat (in the sense of --flatten). Also refactor simpify-locals to be a template, so the various modes are all template parameters.
* Make generating atomics optional in translate-to-fuzz (#1513)Jonathan Foote2018-04-301-7/+8
|
* flatten improvement (#1522)Alon Zakai2018-04-303-115/+175
|
* do more optimizations after inlining: precompute-propagate plus all regular ↵Alon Zakai2018-04-3018-1981/+1530
| | | | opts (#1523)
* add --converge option to wasm-opt (#1524)Alon Zakai2018-04-304-28/+812
| | | | | The option keeps running the passes (that we were told to run) in cycles until we converge in terms of the binary size, that is, keep optimizing until we can't shrink any more. Also fix a --metrics bug this uncovered: we can't expect the Metrics object to still be around if running passes later in another PassRunner.
* optimize selects of constant conditions (#1516)Alon Zakai2018-04-273-14/+115
|
* improve --extract-function (#1517)Alon Zakai2018-04-271-4/+22
| | | Remove more of the unwanted stuff, and leave just an export to the function we are extracting. Then optimizations can do an effective cleanup.
* precompute-propagate may benefit from multiple passes (#1518)Alon Zakai2018-04-273-8/+42
| | | One pass may remove code that includes a tee which then makes more optimization possible. Found by the Souper investigations.
* code-folding improvements (#1512)Alon Zakai2018-04-2613-103/+174
| | | | | | | | Noticed by Souper. * We only folded identical code in an if-else when both arms were blocks, so we were missing the case of one arm being just a singleton expression. This PR will wraps that in a block so the rest of the optimization can work on it, if it sees it is going to be folded out. Turns out this is common for phis. * We only ran code-folding in -Os, because I assumed it was just good for code size, but as it may remove phis in the wasm VM later, seems like we should run it when not optimizing for size as well. Together, these two shrink lua -O3 by almost 1%.
* Improve precompute-propagate (#1514)Alon Zakai2018-04-265-41/+84
| | | Propagate constants through a tee_local. Found by Souper. Details in patch comments - basically we didn't differentiate precomputing a value and an expression.
* Mark prebuilt js files as not diffable (#1462)Sam Clegg2018-04-251-1/+3
| | | | Otherwise `git grep` is rendered rather useless.
* Refactor interpreter (#1508)Alon Zakai2018-04-133-199/+220
| | | | | | * Move more logic to the Literal class. We now leave all the work to there, except for handling traps. * Avoid switching on the type, then the opcode, then Literal method usually switches on the type again - instead, do one big switch for the opcodes (then the Literal method is unchanged) which is shorter and clearer, and avoids that first switching.
* Better binary error reporting (#1505)Alon Zakai2018-04-134-67/+79
| | | | | Report the offset with the error. Also fix a compiler warning about comparing signed/unsigned types in the LEB code.
* fix typo [ci skip]Alon Zakai (kripken)2018-04-111-1/+1
|
* More math opts (#1507)Alon Zakai2018-04-113-3/+89
| | | `xor` of 0, `and` and `or` of -1
* More simple math opts (#1506)Alon Zakai2018-04-114-6/+435
| | | | | * Optimize shifts of 0. * Optimize f(x, x) for various f (e.g., x & x => x).