| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
* 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: 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)
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
* also fixes optimizing them in Precompute
|
|
|
|
| |
* support debug info without a filename in asm2wasm input (which can happen if llvm doesn't know the file, only the line)
|
|
|
|
| |
fixes for multiple segments, which we never really printed that prettily (#1316)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
(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).
|
|
|
|
| |
input values (#1303)
|
|
|
|
| |
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
|
|
|
|
| |
* 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
|
| |
|
|
|
| |
* Also other function utilities in C and JS APIs
|
| |
|
|
|
|
| |
* 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_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 - 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
|
| |
|
| |
|
|
|
|
|
|
| |
* add i64_atomics_* support to asm2wasm
* OptimizeInstructions: atomic loads can't be signed
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Function type gets its own element rather than being a part of the call_indirect
(see WebAssembly/spec#599)
|
|
|
| |
Now also includes a test.
|
| |
|
|
|
|
| |
* 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 wasm2asm in binaryen.js, the function locals may not all have names, so add them as necessary
|
| |
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
| |
los of extra inefficient variables. this is more similar to the output we had before the flatten rewrite (#1229)
|
|
|
|
| |
now that the type system has a proper unreachable, we don't need obviouslyDoesNotFlowOut
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
| |
them around, causing us to zero out the wrong thing in another place and ensuing hilarity (#1212)
|
|
|
|
| |
we are moving code out of the br_if's condition - the value executes before (#1213)
|
|
|
|
| |
blocks (#1214)
|
| |
|
|
|
|
| |
effect up. also add set_global support in dce (#1218)
|
| |
|
|
|
|
| |
may be unreachable (#1216)
|
|
|
|
| |
consistently handled regardless of whether we optimize in parallel or not (#1208)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rename flatten-control-flow to flatten, which now flattens everything, not just control flow, so e.g.
(i32.add
(call $x)
(call $y)
)
==>
(block
(set_local $temp_x (call $x))
(set_local $temp_y (call $y))
(i32.add
(get_local $x)
(get_local $y)
)
)
This uses more locals than before, but is much simpler and avoids a bunch of corner cases and fuzz bugs the old one hit. We can optimize later if necessary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Extract Asm2WasmBuilder::TrapMode to shared FloatTrapMode
* Extract makeTrappingI32Binary
* Extract makeTrappingI64Binary
* Extract asm2wasm test script into scripts/test/asm2wasm.py
This matches s2wasm.py, and makes iterating on asm2wasm slightly faster.
* Simplify callsites with an arg struct
* Combine func adding across i32 and i64
* Support f32-to-int in asm2wasm
* Add BinaryenTrapMode pass, run pass from s2wasm
* BinaryenTrapMode pass takes trap context as a parameter
* Pass fully supports non-trapping binary ops
* Defer adding functions until after iteration (hackily)
* Update asm2wasm to work with deferred function adding, rebuild tests
* Extract makeTrappingFloatToInt32
* Extract makeTrappingFloatToInt64
* Add unary conversions to trap pass
* Add functions in the pass itself
* Set s2wasm trap mode with command-line arguments
* Print BINARYEN_PASS_DEBUG state when testing
* Get asm2wasm using the BinaryenTrapMode pass instead of handling it inline
* Also handle f32 to int in asm2wasm
* Make BinaryenTrapMode only need a FloatTrapMode from the caller
* Just pass the current binary Expression directly
* Combine makeTrappingI32Binary with makeTrappingI64Binary
* Pass Unary expr to makeTrappingFloatToInt32
* Unify makeTrappingFloatToInt32 & 64
* Move makeTrapping* functions inside BinaryenTrapMode, make addedFunctions non-static
* Remove FloatTrapContext
* Minor cleanups
* Extract some smaller subfunctions
* Emit name switch/casing, rename is32Bit to isI64 for consistency
* Rename BinaryenTrapMode to FloatTrap, make trap mode a nested enum
* Add some comments explaining why FloatTrap is non-parallel
* Rename addedFunctions to generatedFunctions for precision
* Rename move and split float-clamp.h to passes/FloatTrap.(h|cpp)
* Use builder instead of allocator
* Instantiate trap handling passes via the pass manager
* Move passes/FloatTrap.h to ast/trapping.h
* Add helper function to add trap-handling passes
* Add trap mode pass tests
* Rename FloatTrap.cpp to TrapMode.cpp
* Add s2wasm trap mode tests. Force float->int conversion to be signed
* Add trapping_sint_div_s test to unit.asm.js
* Fix flake8 issues with test scripts
* Update pass description comment
* Extract building functions methods
* Make generate functions into top-level functions
* Add GeneratedTrappingFunctions class to manage function/import additions
* Move ensure/makeTrapping functions outside class scope
* Use GeneratedTrappingFunctions to add immediately in asm2wasm mode
* Remove trapping_sint_div_s test
We only added it to test that trapping divisions would get
constant-folded at the correct time. Now that we're not changing the
timing of trapping modes, the test is unneeded (and problematic).
* Review feedback, add validator/*.wasm to .gitignore
* Add support for unsigned float-to-int conversion
* Use opcode directly instead of bools
* Update s2wasm clamp test for unsigned ftoi
|
|
|
|
| |
exist, need to return curr->left, after that change (#1207)
|
|
|
|
| |
combining added constants (#1206)
|