summaryrefslogtreecommitdiff
path: root/test/min.fromasm.imprecise
Commit message (Collapse)AuthorAgeFilesLines
* Optimize mutable globals (#2066)Alon Zakai2019-05-021-1/+1
| | | | | | | 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
* Remove f32 legalization from LegalizeJSInterface (#2052)Sam Clegg2019-04-251-27/+21
| | | | | 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.
* Massive renaming (#1855)Thomas Lively2019-01-071-8/+8
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-1/+1
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* Stack IR (#1623)Alon Zakai2018-07-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new IR, "Stack IR". This represents wasm at a very low level, as a simple stream of instructions, basically the same as wasm's binary format. This is unlike Binaryen IR which is structured and in a tree format. This gives some small wins on binary sizes, less than 1% in most cases, usually 0.25-0.50% or so. That's not much by itself, but looking forward this prepares us for multi-value, which we really need an IR like this to be able to optimize well. Also, it's possible there is more we can do already - currently there are just a few stack IR optimizations implemented, DCE local2stack - check if a set_local/get_local pair can be removed, which keeps the set's value on the stack, which if the stars align it can be popped instead of the get. Block removal - remove any blocks with no branches, as they are valid in wasm binary format. Implementation-wise, the IR is defined in wasm-stack.h. A new StackInst is defined, representing a single instruction. Most are simple reflections of Binaryen IR (an add, a load, etc.), and just pointers to them. Control flow constructs are expanded into multiple instructions, like a block turns into a block begin and end, and we may also emit extra unreachables to handle the fact Binaryen IR has unreachable blocks/ifs/loops but wasm does not. Overall, all the Binaryen IR differences with wasm vanish on the way to stack IR. Where this IR lives: Each Function now has a unique_ptr to stack IR, that is, a function may have stack IR alongside the main IR. If the stack IR is present, we write it out during binary writing; if not, we do the same binaryen IR => wasm binary process as before (this PR should not affect speed there). This design lets us use normal Passes on stack IR, in particular this PR defines 3 passes: Generate stack IR Optimize stack IR (might be worth splitting out into separate passes eventually) Print stack IR for debugging purposes Having these as normal passes is convenient as then they can run in parallel across functions and all the other conveniences of our current Pass system. However, a downside of keeping the second IR as an option on Functions, and using normal Passes to operate on it, means that we may get out of sync: if you generate stack IR, then modify binaryen IR, then the stack IR may no longer be valid (for example, maybe you removed locals or modified instructions in place etc.). To avoid that, Passes now define if they modify Binaryen IR or not; if they do, we throw away the stack IR. Miscellaneous notes: Just writing Stack IR, then writing to binary - no optimizations - is 20% slower than going directly to binary, which is one reason why we still support direct writing. This does lead to some "fun" C++ template code to make that convenient: there is a single StackWriter class, templated over the "mode", which is either Binaryen2Binary (direct writing), Binaryen2Stack, or Stack2Binary. This avoids a lot of boilerplate as the 3 modes share a lot of code in overlapping ways. Stack IR does not support source maps / debug info. We just don't use that IR if debug info is present. A tiny text format comment (if emitting non-minified text) indicates stack IR is present, if it is ((; has Stack IR ;)). This may help with debugging, just in case people forget. There is also a pass to print out the stack IR for debug purposes, as mentioned above. The sieve binaryen.js test was actually not validating all along - these new opts broke it in a more noticeable manner. Fixed. Added extra checks in pass-debug mode, to verify that if stack IR should have been thrown out, it was. This should help avoid any confusion with the IR being invalid. Added a comment about the possible future of stack IR as the main IR, depending on optimization results, following some discussion earlier today.
* Optimize equivalent locals (#1540)Alon Zakai2018-05-101-5/+2
| | | | | | | | | If locals are known to contain the same value, we can * Pick which local to use for a get_local of any of them. Makes sense to prefer the most common, to increase the chance of one dropping to zero uses. * Remove copies between a local and one that we know contains the same value. This is a consistent win, small though, around 0.1-0.2%.
* do more optimizations after inlining: precompute-propagate plus all regular ↵Alon Zakai2018-04-301-2/+5
| | | | opts (#1523)
* Global optimization fixes (#1360)Alon Zakai2018-01-171-36/+16
| | | | | | | | | | | | | | | | * run dfe at the very end, as it may be more effective after inlining * optimize reorder-functions * do a final dfe in asm2wasm after all other opts * make inlining deterministic: std::atomic<T> values are not zero-initialized * do global post opts at the end of asm2wasm, and don't also do them in the module builder * fix function type removing * don't inline+optimize when preserving debug info
* Optimize out memory and table when possible (#1352)Alon Zakai2018-01-101-3/+0
| | | We can remove the memory/table (itself, or an import if imported) if they are not used. This is pretty minor on a large wasm file, but when reading small wasts it's very noticeable to have an unused memory and table all the time.
* Emit binary function index in comment in text format, for convenience (#1232)Alon Zakai2017-10-201-8/+8
|
* use a single space for pretty printing of wasts, so massive wasts are less ↵Alon Zakai2017-03-091-57/+57
| | | | unruly (#928)
* make legalizeJSInterface handle f32s as well, which are not valid in asm.js ffisAlon Zakai2016-12-071-3/+28
|
* add a RemoveUnusedModuleElements pass, and make LegalizeJSInterface create ↵Alon Zakai2016-12-071-2/+0
| | | | TempRet0 if needed (otherwise we might remove it before we use it)
* run remove-unused-functions by defaultAlon Zakai2016-10-141-0/+3
|
* if we see no asm.js function tables, the table size is 0Alon Zakai2016-10-111-1/+1
|
* Change print order of top-level module components (#751)Derek Schuff2016-10-071-2/+2
| | | | | | | | In wast files, the spec and WABT require imports to appear before any non-import definitions (see also https://github.com/WebAssembly/wabt/issues/152). This patch re-orders visitModule in the wast printer to meet this requirement, and more or less match the order of the binary sections. Also remove extraneous whitespace around table definitions.
* Print the name of memory along with size (#720)Derek Schuff2016-09-281-1/+1
| | | | | Otherwise when we export it as "$0" it's an undefined name. The spec interpreter actually rejects this, although I think it's intended to work, given the tests in export.wast. wabt also accepts it.
* memory and table printing fixesAlon Zakai2016-09-201-3/+2
|
* globals mutability fixesAlon Zakai2016-09-191-2/+3
|
* handle getTempRet0 having extra code, which can happen in emterpreter ↵Alon Zakai2016-09-151-0/+8
| | | | assertions mode
* new export syntax in spec repoAlon Zakai2016-09-071-1/+1
|
* new import syntax in spec repoAlon Zakai2016-09-071-5/+5
|
* import memoryBase and tableBaseAlon Zakai2016-09-071-0/+2
|
* import tableAlon Zakai2016-09-071-0/+1
|
* import memory #684Alon Zakai2016-09-071-1/+1
|
* use globals in asm2wasmAlon Zakai2016-09-071-0/+1
|
* export kindsAlon Zakai2016-09-071-1/+1
|
* add a precompute passAlon Zakai2016-06-181-3/+1
|
* move blocks outside in merge-blocks so that they can be merged laterAlon Zakai2016-05-241-8/+6
|
* vacuum away everything not tied downAlon Zakai2016-05-191-11/+1
|
* add cfg-building traversal and a pass to coalesce locals using itAlon Zakai2016-05-151-12/+12
|
* optimize returns that flow outAlon Zakai2016-04-251-19/+13
|
* drop completely unused locals in ReorderLocalsAlon Zakai2016-04-111-1/+0
|
* remove set_locals with no remaining gets in SimplifyLocalsAlon Zakai2016-04-111-10/+8
|
* optimize llvm.cttz.i32 into i32.ctzAlon Zakai2016-04-081-0/+7
|
* update testsAlon Zakai2016-04-071-12/+11
|
* handle minified tempDoublePtrAlon Zakai2016-04-011-0/+13
|
* add option for imprecise asm2wasm optsAlon Zakai2016-03-201-0/+33