summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* wasm2js: use scratch memory properly (#2033)Alon Zakai2019-04-226-82/+237
| | | | | | | This replaces all uses of __tempMemory__, the old scratch space location, with calls to function imports for scratch memory access. This lets us then implement those in a way that does not use the same heap as main memory. This avoids possible bugs with scratch memory overwriting something, or just in general that it has observable side effects, which can confuse fuzzing etc. The intrinsics are currently implemented in the glue. We could perhaps emit them inline instead (but that might limit asm.js optimizations, so I wanted to keep our options open for now - easy to change later). Also fixes some places where we used 0 as the scratch space address.
* wasm2js2 import fixes (#2031)Alon Zakai2019-04-193-5/+9
| | | | | | * Don't assume function types exist in legalize-js-interface. * Properly handle (ignore) imports in RemoveNonJSOps - do not try to recurse into them. * Run legalize-js-interface and remove-unused-module-elements in wasm2js, the first is necessary, the last is nice to have.
* wasm2js: handle unreachable select and global.set (#2029)Alon Zakai2019-04-181-0/+21
|
* Reland emitting of DataCount section (#2027)Thomas Lively2019-04-182-11/+6
| | | | | | This reverts commit cb2d63586c08a3dd194d2b733ceb3f5051c081f8. The issues with feature validation were mostly resolved in #1993, and this PR finishes the job by adding feature flags to wasm-as to avoid emitting the DataCount section when bulk-memory is not enabled.
* Refactor interpreter initialization to use bulk memory (#2025)Thomas Lively2019-04-183-285/+357
| | | | | | | | | | This corresponds to changes made to the initialization procedure in the spec. It also removes all the heavy initialization work from the external interface of the interpreter, which is a nice encapsulation win. Implementation of the interpretation of the remaining bulk memory operations and more rigorous tests of that interpretation will come in a follow-up PR.
* wasm2js: do not try to be smart with not emitting if braces, the corner ↵Alon Zakai2019-04-181-33/+17
| | | | | cases are tricky (#2026) leave them for later optimizers/minifiers
* wasm2js: remove "use asm", we are not asm.js anymore (#2020)Alon Zakai2019-04-181-17/+2
| | | Also emit the memory growth code based on memory growth, and not whether we are "use asm" or not.
* Wasm2js: support i64 globals (#2021)Alon Zakai2019-04-183-12/+53
| | | Split them into two i32 globals.
* Use OverriddenVisitor in ExpressionRunner (#2024)Alon Zakai2019-04-171-16/+20
| | | Should prevent surprises in the future.
* Do not precompute bulk memory operations (#2023)Thomas Lively2019-04-171-0/+12
| | | Fixes #1984
* wasm2js: fix br_table to loop (#2018)Alon Zakai2019-04-171-9/+11
|
* Improve log-execution pass to also log around returns (#2019)Alon Zakai2019-04-171-1/+14
|
* Fix if else JS printing when if body is a labelled block (#2017)Alon Zakai2019-04-171-1/+4
| | | | | | | | | | | | Before, we'd print if (..) label: { .. }; else .. But that is wrong, as it ends the if too early. After this, we print if (..) label: { .. } else .. The bug was we checked if the if body was a block, but not if it was a labelled block.
* Demote a wasm2js warning on scopes (#2016)Alon Zakai2019-04-171-2/+6
| | | We do not actually analyze scopes properly there, see comment in the commit. For now, just demote it to a warning. Not sure if it's worth fixing it or just removing it.
* wasm2js: Fix unaligned loads and stores (#2015)Alon Zakai2019-04-171-0/+1
| | | We forgot to set them as unsigned, which meant that we were reading uninitialized memory when checking that field, which mostly worked, except if it previously contained something...
* Change default feature set to MVP (#1993)Thomas Lively2019-04-1610-11/+63
| | | | | In the absence of the target features section or command line flags. When there are command line flags, it is an error if they do not exactly match the target features section, except if --detect-features has been provided. Also adds a --print-features pass to print the command line flags for all enabled options and uses it to make the feature tests more rigorous.
* Improve instrumentation passes (#2012)Alon Zakai2019-04-162-52/+93
| | | | | * Make the memory instrumentation pass log both pointers and values. * Use "env" as the import module - simpler to support and get working.
* wasm2js: support memory imports properly, updating their buffer too (#2013)Alon Zakai2019-04-161-3/+29
| | | | | * Emit an import statement for the memory. * Update the imported memory's buffer when we grow.
* Make sure we always add signature to `fp$` functions (#1994)Sam Clegg2019-04-161-3/+13
| | | | | | | | Previously we were searching for the function by name but this doesn't work when the internal name for the function is different. In order to repro such a case the shared.c test was converted to C++ since then binaryen's internal name is different since it comes from the de-mangled name section.
* Verify flat IR where it is expected, and give a nice error (#2009)Alon Zakai2019-04-167-40/+136
| | | Fixes #2007 #2008
* Do not emit the DataCount section (#2010)Thomas Lively2019-04-151-3/+8
| | | | | Its presence was causing validation errors in the Emscripten test suite. This should be reverted once the default feature set is no longer All.