summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* wasm2js: optimize away unneeded load coercions (#2107)Alon Zakai2019-05-152-13/+40
|
* wasm2js: Emit table in a way that is friendly to emscripten minification (#2102)Alon Zakai2019-05-131-2/+9
| | | Set it to a local in the asmFunc scope, so that minifiers can easily see it's a simple local value (instead of using it as an upvar from the parameters higher up, which was how the emscripten glue was emitting it).
* wasm2js: precompute bitwise operations (#2101)Alon Zakai2019-05-131-0/+30
| | | This happens on e.g. an i32 load of a constant offset, then we have constant >> 2.
* Add missing methods for globals to binaryen.js (#2099)Heejin Ahn2019-05-133-10/+69
| | | | | - Print `globals` array in the tracing mode like other arrays (`functions`, `exports`, `imports`, ...) - Add accessor functions for globals
* Delete WasmBinaryBuilder::mappedGlobals (NFC) (#2098)Heejin Ahn2019-05-122-37/+18
| | | | | | It doesn't seem to be used anywhere and I don't know why the implementation for `WasmBinaryBuilder::getGlobalName` and `WasmBinaryBuilder::getFunctionIndexName` are different. Renamed `getFunctionIndexName` to `getFunctionName` for consistency.
* Generate `dynCall` function for all signature used by `invoke` functions. ↵Sam Clegg2019-05-102-29/+41
| | | | | | | | | (#2095) Previously we were only creating `dynCall` functions for signatures that we have statically in the table. However for dynamic linking we may need to invoke functions that we don't have table entries for (e.g. table entries from a different module).
* Look through fallthrough values in precompute-propagate (#2093)Alon Zakai2019-05-101-1/+3
| | | This helps quite a lot on wasm2js.
* wasm2js: avoid reinterprets (#2094)Alon Zakai2019-05-107-2/+219
| | | | | In JS a reinterpret is especially expensive, as we implement it as a write to a temp buffer and a read using another view. This finds places where we load a value from memory, then reinterpret it later - in that case, we can load it using another view, at the cost of another load and another local. This is helpful on things like Box2D, where there are many reinterprets due to the main 2D vector class being an union over two floats/ints, and LLVM likes to do a single i64 load of them.
* Emit process ID in the filenames of byn* tempfiles (#1916)Alon Zakai2019-05-101-1/+10
| | | Helps to avoid trampling each other when binaryen is called multiple times from emcc, for example.
* Add except_ref type (#2081)Heejin Ahn2019-05-0724-7/+121
| | | | This adds except_ref type, which is a part of the exception handling proposal.
* wasm2js: optimize booleans (#2090)Alon Zakai2019-05-071-26/+52
|
* Make sexp instruction parser pass clang-tidy (#2088)Heejin Ahn2019-05-061-395/+395
| | | | | | Our current clang-tidy setting requires {} after ifs. Unlike clang-format, I couldn't find any directives or options that allow us to exclude the generated inc file from clang-tidy. Anyway adding a pair of braces is all it takes to make it pass.
* Fix formatting of some comments (NFC) (#2091)Heejin Ahn2019-05-062-5/+6
| | | A few things that were missing in #2048.
* wasm2js: 'handle' saturating float to int conversions - we don't handle any ↵Alon Zakai2019-05-061-5/+12
| | | | of them precisely anyhow (#2087)
* Add exception handling feature (#2083)Heejin Ahn2019-05-034-2/+16
| | | This only adds the feature and its flag and not the instructions yet.
* wasm2js: optimize loads (#2085)Alon Zakai2019-05-032-3/+19
| | | | When loading a boolean, prefer the signed heap (which is more commonly used, and may be faster). We never use HEAPU32 (HEAP32 is always enough), just remove it.
* wasm2js: avoid some slow operations when not optimizing (#2082)Alon Zakai2019-05-031-4/+6
| | | Without this PR, wasm2js0.test_printf in emscripten took an extremely long time to compile.
* wasm2js: don't emit obviously unnecessary parens (#2080)Alon Zakai2019-05-021-12/+26
| | | A minifier would probably remove them later anyhow, but they make reading the code annoying and hard.
* wasm2js: ignore implicit traps (#2079)Alon Zakai2019-05-022-2/+10
| | | | | We don't actually try to emit traps for loads, stores, invalid float to ints, etc., so when optimizing we may as well do so under the assumption those traps do not exist. This lets us emit nice code for a select whose operands are loads, for example - otherwise, the values seem to have side effects.
* Optimize mutable globals (#2066)Alon Zakai2019-05-025-4/+149
| | | | | | | If a global is marked mutable but not assigned to, make it immutable. If an immutable global is a copy of another, use the original, so we can remove the duplicates. Fixes #2011
* Add a pass to lower unaligned loads and stores (#2078)Alon Zakai2019-05-025-97/+224
| | | | | This replaces the wasm2js code that lowered them to pessimistic (1-byte aligned) loads and stores. The new pass will do the optimal thing, keeping 2-byte alignment where possible. This is also nicer as a standalone pass, which has the simple property that after it runs all loads and stores are aligned, instead of some code scattered inside wasm2js.
* wasm2js: don't run coalesce-locals if not optimizing (#2076)Alon Zakai2019-05-011-1/+5
| | | That pass is very slow on unoptimized code (super-linear on the number of locals, which if unoptimized can be massive due to flatten).
* clang-tidy braces changes (#2075)Alon Zakai2019-05-01116-1508/+2945
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* wasm2js: run more optimizations (#2073)Alon Zakai2019-05-011-2/+3
| | | In particular, coalesce-locals is useful even if closure is run later (apparently it finds stuff closure can't).
* Proper errors on unsupported segment types in ↵Alon Zakai2019-05-011-1/+6
| | | | EmscriptenGlueGenerator::separateDataSegments (#2068)
* wasm2js: run full optimizations during the pipeline (#2071)Alon Zakai2019-04-301-23/+34
| | | | | We flatten for the i64 lowering etc. passes, and it is worth optimizing afterwards, to clean up stuff they created. That is run if the user ran wasm2js with an optimization level (like wasm2js -O3). Split the test files to check both optimized and unoptimized code.
* wasm2js: optimize away casts going into a suitable store (#2069)Alon Zakai2019-04-301-9/+97
|
* I64ToI32Lowering: don't use alignment 1 everywhere (#2070)Alon Zakai2019-04-301-2/+2
| | | If an i64 load/store that is being broken up has higher alignment, use that.
* wasm2js: optimize switches (#2067)Alon Zakai2019-04-301-3/+22
| | | | | | | | | | Don't emit unneeded breaks in switch cases, instead do case X: case Y: .. case W: break .. for each group. Also, the group with the default doesn't need any cases but the default itself.
* Properly handle optimizing out a set from inside the value of another set in ↵Alon Zakai2019-04-291-3/+56
| | | | | | | SimplifyLocals (#2064) Details in lengthy comment in the source. Fixes #2063
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-26198-13655/+22447
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* Add clang-format-diff hook (#2057)Heejin Ahn2019-04-261-0/+4
| | | | | | | This adds a commit hook to Travis CI that errors out if incoming PRs' diffs are not clang-formatted. Turns out clang-format is also capable of formatting JavaScript, but we haven't agreed on a style for JS yet, this PR disables JavaScript formatting for now. This also adds clang-format exempt header/footer to a generated source file.
* wasm2js: remove unneeded break/continue labels (#2058)Alon Zakai2019-04-263-70/+125
|
* wasm2js2: optimize call_indirect and select operands (#2056)Alon Zakai2019-04-252-49/+96
| | | Don't use temp vars to reorder them unless we need to.
* wasm2js: support non-constant indexes for memory and table segments (#2055)Alon Zakai2019-04-251-37/+45
| | | Mostly what we need for dynamic linking, at least on the binaryen side.
* wasm2js: optimize loops and eqz (#2051)Alon Zakai2019-04-251-7/+10
|
* Remove f32 legalization from LegalizeJSInterface (#2052)Sam Clegg2019-04-252-18/+5
| | | | | As well as i64 splitting this pass was also converting f32 to f64 at the wasm boundry. However it appears this is not actually useful and makes somethings (such as dynamic linking) harder.
* wasm2js: more js optimization (#2050)Alon Zakai2019-04-244-34/+119
| | | | | | * Emit ints as signed, so -1 isn't a big unsigned number. * x - -c (where c is a constant) is larger than x + c in js (but not wasm) * +(+x) => +x * Avoid unnecessary coercions on calls, return, load, etc. - we just need coercions when entering or exiting "wasm" (not internally), and on actual operations that need them.
* Fix typo in C API: BinaryeGlobalImportGetModule -> ↵Bastian Müller2019-04-241-1/+1
| | | | BinaryenGlobalImportGetModule (#2047)
* wasm2js: start to optionally optimize the JS (#2046)Alon Zakai2019-04-244-197/+108
| | | Removes redundant | 0s and similar things. (Apparently closure compiler doesn't do that, so makes sense to do here.)
* wasm2js: emit quoted properties for the exports, to support closure compiler ↵Alon Zakai2019-04-232-8/+23
| | | | (#2043)
* wasm2js: emit calls for memory growth helper only if memory growth is used ↵Alon Zakai2019-04-231-9/+10
| | | | (#2042)
* wasm2js: avoid non-ES5 stuff like "let" (#2041)Alon Zakai2019-04-231-10/+10
| | | Also fix the fuzzer's handling of feature flags so that wasm2js can work.
* wasm2js: remove more code we don't need since we have flat IR (#2039)Alon Zakai2019-04-222-157/+13
| | | Also run remove-unused-names which became more noticeably necessary after this change.
* Finish bulk memory support (#2030)Thomas Lively2019-04-226-25/+96
| | | | | | | Implement interpretation of remaining bulk memory ops, add bulk memory spec tests with light modifications, fix bugs preventing the fuzzer from running correctly with bulk memory, and fix bugs found by the fuzzer.
* wasm2js: get rid of some non-flat code assumptions (#2036)Alon Zakai2019-04-222-382/+111
| | | We run flatten there, which lets us simplify things a lot. Turns out that for assertions we didn't run it, which is why we still needed the old non-flat code paths. This adds flatten there and removes that old code and assumptions.
* wasm2js: unreachability fixes (#2037)Alon Zakai2019-04-221-25/+19
| | | Also test in pass-debug mode, for better coverage.
* wasm-emscripten-finalize: Handle relocatable code in AsmConstWalker (#2035)Sam Clegg2019-04-221-21/+28
| | | | | | | | | When replacing the first argument to an asm call, allow more complex expressions for expressing the address. This fixes the case where the first argument might be the result of adding a constant to __memory_base.
* wasm2js: fix printing of negated negative constants (#2034)Alon Zakai2019-04-221-0/+3
| | | It is invalid to print --5, we need to add a space - -5 so that it is valid JS to parse.
* wasm2js: remove some unneeded code, which also has some risks of ↵Alon Zakai2019-04-221-13/+4
| | | | | incorrectness (#2032) The risk is that the children's type may be unreachable, in which case we may have forgotten the signing, and could get incorrect results.