summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* Optimize mutable globals (#2066)Alon Zakai2019-05-0215-65/+146
| | | | | | | 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-51/+711
| | | | | 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-0151-16963/+22097
| | | That pass is very slow on unoptimized code (super-linear on the number of locals, which if unoptimized can be massive due to flatten).
* wasm2js: run more optimizations (#2073)Alon Zakai2019-05-0162-22433/+17246
| | | In particular, coalesce-locals is useful even if closure is run later (apparently it finds stuff closure can't).
* wasm2js: run full optimizations during the pipeline (#2071)Alon Zakai2019-04-3078-5965/+22887
| | | | | 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-303-6/+31
|
* I64ToI32Lowering: don't use alignment 1 everywhere (#2070)Alon Zakai2019-04-305-8/+296
| | | If an i64 load/store that is being broken up has higher alignment, use that.
* wasm2js: optimize switches (#2067)Alon Zakai2019-04-306-73950/+12
| | | | | | | | | | 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-292-0/+51
| | | | | | | SimplifyLocals (#2064) Details in lengthy comment in the source. Fixes #2063
* Fix CI (#2061)Alon Zakai2019-04-261-1/+1
| | | | | | | We had CI breakage that prevented this from being noticed before. * Make binaryen.js not use NO_FILESYSTEM - need to investigate why recent emscripten changes broke our usage of that flag. * Update a binaryen.js test.
* wasm2js: remove unneeded break/continue labels (#2058)Alon Zakai2019-04-2612-56/+56
|
* wasm2js2: optimize call_indirect and select operands (#2056)Alon Zakai2019-04-2513-95/+231
| | | 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-252-0/+87
| | | Mostly what we need for dynamic linking, at least on the binaryen side.
* wasm2js: optimize loops and eqz (#2051)Alon Zakai2019-04-2518-206/+178
|
* Remove f32 legalization from LegalizeJSInterface (#2052)Sam Clegg2019-04-2540-1248/+484
| | | | | 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-2448-2431/+1449
| | | | | | * 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.
* wasm2js: start to optionally optimize the JS (#2046)Alon Zakai2019-04-2448-4989/+5011
| | | 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-2357-998/+998
| | | | (#2043)
* wasm2js: emit calls for memory growth helper only if memory growth is used ↵Alon Zakai2019-04-231-1/+1
| | | | (#2042)
* wasm2js: avoid non-ES5 stuff like "let" (#2041)Alon Zakai2019-04-2364-1164/+1164
| | | 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-2215-480/+256
| | | Also run remove-unused-names which became more noticeably necessary after this change.
* Finish bulk memory support (#2030)Thomas Lively2019-04-221-0/+183
| | | | | | | 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-2214-445/+163
| | | 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-2214-1857/+2451
| | | Also test in pass-debug mode, for better coverage.
* wasm-emscripten-finalize: Handle relocatable code in AsmConstWalker (#2035)Sam Clegg2019-04-222-18/+7
| | | | | | | | | 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-222-0/+58
| | | It is invalid to print --5, we need to add a space - -5 so that it is valid JS to parse.
* wasm2js: use scratch memory properly (#2033)Alon Zakai2019-04-2213-2156/+2439
| | | | | | | 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-1961-1017/+11252
| | | | | | * 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-188-11/+174
|
* Reland emitting of DataCount section (#2027)Thomas Lively2019-04-181-0/+15
| | | | | | 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.
* wasm2js: do not try to be smart with not emitting if braces, the corner ↵Alon Zakai2019-04-1838-4002/+6288
| | | | | cases are tricky (#2026) leave them for later optimizers/minifiers
* wasm2js: remove "use asm", we are not asm.js anymore (#2020)Alon Zakai2019-04-1860-107/+281
| | | 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-184-1/+127
| | | Split them into two i32 globals.
* Do not precompute bulk memory operations (#2023)Thomas Lively2019-04-172-2/+53
| | | Fixes #1984
* wasm2js: fix br_table to loop (#2018)Alon Zakai2019-04-172-0/+83
|
* Improve log-execution pass to also log around returns (#2019)Alon Zakai2019-04-171-18/+28
|
* Fix if else JS printing when if body is a labelled block (#2017)Alon Zakai2019-04-1723-571/+637
| | | | | | | | | | | | 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.
* Change default feature set to MVP (#1993)Thomas Lively2019-04-1652-143/+60
| | | | | 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-234/+384
| | | | | * 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-162-2/+41
| | | | | * 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-164-39/+80
| | | | | | | | 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-1613-928/+1585
| | | Fixes #2007 #2008
* Do not emit the DataCount section (#2010)Thomas Lively2019-04-153-18/+2
| | | | | Its presence was causing validation errors in the Emscripten test suite. This should be reverted once the default feature set is no longer All.
* Use a single table in wasm2js (#2005)Alon Zakai2019-04-1558-65/+121
| | | | | This replaces the multiple asm.js tables (of power-of-2 size) with a single simple table. Also supports importing the table.
* DataCount section (#2006)Thomas Lively2019-04-157-24/+45
| | | | | | | | * DataCount section Read the DataCount section and verify that it agrees with the data section. Also emit the DataCount section when bulk-memory is enabled and there are a nonzero number of segments. Factor out some shared unit test code.
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-1220-62/+56
| | | | | This allows us to emit a (potentially modified) target features section and conditionally emit other sections such as the DataCount section based on the presence of features.
* Wasm2js memory fixes (#2003)Alon Zakai2019-04-1218-409/+8869
| | | | | | | | * I64ToI32Lowering - don't assume address 0 is a hardcoded location for scratch memory. Import __tempMemory__ for that. * RemoveNonJSOps - also use __tempMemory__. Oddly here the address was a hardcoded 1024 (perhaps where the rust program put a static global?). * Support imported ints in wasm2js, coercing them as needed. * Add "env" import support in the tests, since now we emit imports from there. * Make wasm2js tests split out multi-module tests using split_wast which is more robust and avoids emitting multiple outputs in one file (which makes no sense for ES6 modules)
* wasm2js memory improvements (#2002)Alon Zakai2019-04-123-26/+44
| | | | | * Refactor memory code to share it between the two emitting modes. * Get memory emitting set up in the emscripten mode.
* wasm2js: emscripten glue option (#2000)Alon Zakai2019-04-112-0/+110
| | | | | | Add a wasm2js option for the glue to be in emscripten-compatible format (as opposed to ES6). This does a few things so far: * Emit START_FUNCTIONS, END_FUNCTIONS markers in the code, for future use in the optimizer. * Emit the glue as a function to be called from emscripten.
* Wasm2js refactoring (#1997)Alon Zakai2019-04-1157-84/+137
| | | | | | | | | | | | | Early work for #1929 * Leave core wasm module - the "asm.js function" - to Wasm2JSBuilder, and add Wasm2JSGlue which emits the code before and after that. Currently that's some ES6 code, but we may want to change that later. * Add add AssertionEmitter class for the sole purpose of emitting modules + assertions for testing. This avoids some hacks from before like starting from index 1 (assuming the module at first position was already parsed and printed) and printing of the f32Equal etc. functions not at the very top (which was due to technical limitations before). Logic-wise, there should be no visible change, except some whitespace and reodering, and that I made the exceptions print out the source of the assertion that failed from the wast: -if (!check2()) fail2(); +if (!check2()) throw 'assertion failed: ( assert_return ( call add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; (fail2 etc. did not exist, and seems to just have given a unique number for each assertion?)