summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* SpillPointers pass (#1339)Alon Zakai2017-12-302-0/+812
| | | | | | | | | | | | | This is an experiment to help with Boehm-style GC. It will spill things that could be pointers to the C stack, so that they can be seen by conservative garbage collection. The spills add code size and runtime overhead, but actually less than I thought: 10% slower (smaller than the difference between VMs), 15% gzip size larger. We can do even better with more optimizations for this, like a dead store elimination pass. This PR does the following: * Add the new pass. * Create an abi/ dir, with info about the pointer size and stack manipulation utilities. * Separates out the liveness analysis from CoalesceLocals, so that other passes can use it (like SpillPointers). * Refactor out the SortedVector class from the liveness analysis to a separate file (just seems nicer that way).
* Add getters for various specific expression fields to C/JS (#1332)Daniel Wirtz2017-12-2011-229/+258
|
* merge-locals pass (#1334)Alon Zakai2017-12-173-142/+2059
| | | | | | | | | This optimizes the situation described in #1331. Namely, when x is copied into y, then on subsequent gets of x we could use y instead, and vice versa, as their value is equal. Specifically, this seems to get rid of the definite overlap in the live ranges of x and y, as removing it allows coalesce-locals to merge them. The pass therefore does nothing if the live range of y ends there anyhow. The danger here is that we may extend the live range so that it causes more conflicts with other things, so this is a heuristic, but I've tested it on every codebase I can find and it always produces a net win, even on one I saw a 0.4% reduction of code size, which surprised me. This is a fairly slow pass, because it uses LocalGraph which isn't much optimized. This PR includes a minor optimization for it, but we should rewrite it. Meanwhile this is just enabled in -O3 and -Oz. This PR also includes some fuzzing improvements, to better test stuff like this.
* Fix 2 binary fuzz bugs (#1323)Alon Zakai2017-12-142-0/+0
| | | | | | * Check if there is a currFunction before using it (we need it for some stacky code; a valid wasm wouldn't need a function in that location anyhow, as what can be put in a memory/table offset is very limited). * Huge alignment led us to do a power of 2 shift that is undefined behavior. Also adds a test facility to check we don't crash on testcases.
* allow exporting an import (#1326)Alon Zakai2017-12-084-0/+37
|
* metadce fixes (#1329)Alon Zakai2017-12-079-28/+79
| | | | | | | | | | | | * 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-073-5/+187
| | | | * 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-0640-0/+587
| | | | | | | 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-063-346/+274
| | | * also fixes optimizing them in Precompute
* Handle debug info without a filename in asm2wasm (#1249)Alon Zakai2017-12-0513-7/+40
| | | | * 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-0526-16/+406
| | | | fixes for multiple segments, which we never really printed that prettily (#1316)
* br_if-to-table (#1313)Alon Zakai2017-12-042-0/+797
| | | | | | | | | | | | | | | 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.
* De-morgan's "and" law (#1297)Alon Zakai2017-11-3011-267/+266
| | | | | (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-776/+349
| | | | input values (#1303)
* make sure we do not fold out code from blocks with a fallthrough value, and ↵Alon Zakai2017-11-302-0/+35
| | | | 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)
* Provide AddImport/AddExport for each element in the C-API (#1292)Daniel Wirtz2017-11-2211-38/+38
| | | | * Provide AddImport/AddExport for each element in the C-API
* Fix reading breaks to the function exit (#1304)Alon Zakai2017-11-212-0/+10
| | | | * 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-216-10/+10
|
* Running passes on a single function in binaryen-c/.js (#1295)Daniel Wirtz2017-11-212-0/+39
| | | * Also other function utilities in C and JS APIs
* Add atomic load/store to binaryen-c/.js (#1298)Daniel Wirtz2017-11-202-0/+112
|
* Fix a code-folding fuzz bug (#1282)Alon Zakai2017-11-172-0/+119
| | | | * 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-176-41/+95
| | | | | * 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-0/+60
| | | | * 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-1579-315/+315
|
* Add const expression utilities to binaryen-c/.js (#1288)Daniel Wirtz2017-11-152-14/+35
|
* add i64_atomics_* support to asm2wasm (#1262)Alon Zakai2017-11-149-0/+560
| | | | | | * add i64_atomics_* support to asm2wasm * OptimizeInstructions: atomic loads can't be signed
* Run binaryen.js tests using node, and on travis (#1275)Alon Zakai2017-11-141-1/+1
|
* accept overlapping segments (#1289)Alon Zakai2017-11-144-0/+23
|
* fix some tests that broke due to recent merges (#1287)Alon Zakai2017-11-143-20/+6
|
* a stacky value in the middle of a block may be consumed (#1267)Alon Zakai2017-11-132-0/+16
|
* Update call_indirect text syntax to match spec update (#1281)Derek Schuff2017-11-1375-354/+354
| | | | 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-133-4/+19
| | | Now also includes a test.
* Added expression utility functions to binaryen-c/.js (#1269)Daniel Wirtz2017-11-112-1/+65
|
* Rereloop fuzz fix (#1259)Alon Zakai2017-11-093-18/+127
| | | | * 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.
* Fix binaryen.js's wasm2asm (#1257)Alon Zakai2017-11-014-53/+57
| | | | * 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-302-0/+9
|
* Improve constant fuzzing (#1244)Alon Zakai2017-10-241-825/+705
| | | | | 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 safe-heap regression with handling of existing imports (#1237)Alon Zakai2017-10-242-0/+4048
|
* Emit binary function index in comment in text format, for convenience (#1232)Alon Zakai2017-10-20349-4048/+4048
|
* Atomics support in interpreter + optimizer + fuzz fixes for that (#1227)Alon Zakai2017-10-204-821/+791
|
* use simplify-locals in wasm2asm, so the output is not horribly verbose with ↵Alon Zakai2017-10-209-1224/+379
| | | | los of extra inefficient variables. this is more similar to the output we had before the flatten rewrite (#1229)
* Use the type system to check if something is flowed out of (#1224)Alon Zakai2017-10-162-12/+50
| | | | now that the type system has a proper unreachable, we don't need obviouslyDoesNotFlowOut
* Fixed parseFile() skipping every other line (#1223)Alexander Meißner2017-10-161-0/+1
| | | | | | | | * Fixed parseFile() skipping every other line Was caused by "s = strchr(s, '\n')" Also replaced recordFile() by parseFile() as they do exactly the same * Added parseFile() to process() in s2wasm.h
* fix ssaify bug where we failed to update the location of values as we moved ↵Alon Zakai2017-10-112-0/+64
| | | | them around, causing us to zero out the wrong thing in another place and ensuing hilarity (#1212)
* fix simplify-locals bug where we create a br_if value, which is dangerous if ↵Alon Zakai2017-10-112-0/+96
| | | | we are moving code out of the br_if's condition - the value executes before (#1213)
* fix re-reloop fuzz bug, we need to ensure a terminator in all relooper ↵Alon Zakai2017-10-113-2/+85
| | | | blocks (#1214)
* fix test breakage from colliding PRs landing too quickly (#1220)Alon Zakai2017-10-101-24/+15
|
* fix a dce fuzz bug where if changed to unreachable but didn't propagate that ↵Alon Zakai2017-10-102-19/+60
| | | | effect up. also add set_global support in dce (#1218)
* Fuzzer: create and use globals in fuzz programs (#1217)Alon Zakai2017-10-101-368/+930
|
* fix wasm-builder set_global creation - we must call finalize, as the value ↵Alon Zakai2017-10-102-0/+82
| | | | may be unreachable (#1216)