summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor stack IR / binary writer (NFC) (#2250)Heejin Ahn2019-07-236-1974/+2004
| | | | | | | | | | | | | | | | Previously `StackWriter` and its subclasses had routines for all three modes (`Binaryen2Binary`, `Binaryen2Stack`, and `Stack2Binary`) within a single class. This splits routines for each in a separate class and also factors out binary writing into a separate class (`BinaryInstWriter`) so other classes can make use of it. The new classes are: - `BinaryInstWriter`: Binary instruction writer. Only responsible for emitting binary contents and no other logic - `BinaryenIRWriter`: Converts binaryen IR into something else - `BinaryenIRToBinaryWriter`: Writes binaryen IR to binary - `StackIRGenerator`: Converts binaryen IR to stack IR - `StackIRToBinaryWriter`: Writes stack IR to binary
* wasm-emscripten-finalize: Add mainReadsParams metadata (#2247)Alon Zakai2019-07-2215-15/+45
| | | | | | | The new flag indicates whether main reads the argc/argv parameters. If it does not, we can avoid emitting code to generate those arguments in the JS, which is not trivial in small programs - it requires some string conversion code. Nicely the existing test inputs were enough for testing this (see outputs). This depends on an emscripten change to land first, as emscripten.py asserts on metadata fields it doesn't recognize.
* SimplifyGlobals: Propagate constants in global initializers (#2238)Alon Zakai2019-07-202-13/+60
| | | | | | | | | | | (global $g1 (mut i32) (i32.const 42)) (global $g2 i32 (global.get $g1)) can be optimized to (global $g1 (mut i32) (i32.const 42)) (global $g2 i32 (i32.const 42)) even though $g1 is mutable - because it can't be mutated during module instantiation.
* Re-land #2235 with fixes (#2245)Thomas Lively2019-07-205-13/+108
| | | | #2242 had exposed the bug that the `Trapper` pass was defining `walkFunction` when it should have been defining `doWalkFunction`.
* Revert "Remove bulk memory instructions refering to active segments (#2235)" ↵Thomas Lively2019-07-195-106/+13
| | | | | (#2244) This reverts commit 72c52ea7d4eb61b95cf8a5164947cb760fe42e9c, which was causing test failures after it merged.
* Remove bulk memory instructions refering to active segments (#2235)Thomas Lively2019-07-195-13/+106
| | | | This prevents those instructions from becoming invalid due to memory packing optimizations and is also a code size win. Fixes #2227.
* Simpify PassRunner.add() and automatically parallelize parallel functions ↵Alon Zakai2019-07-1921-116/+63
| | | | | | | | | (#2242) Main change here is in pass.h, everything else is changes to work with the new API. The add("name") remains as before, while the weird variadic add(..) which constructed the pass now just gets a std::unique_ptr of a pass. This also makes the memory management internally fully automatic. And it makes it trivial to parallelize WalkerPass::run on parallel passes. As a benefit, this allows removing a lot of code since in many cases there is no need to create a new pass runner, and running a pass can be just a single line.
* Add more cmake files to gitignore (#2239)Thomas Lively2019-07-191-3/+3
|
* Fuzzing: Emit BINARYEN_PASS_DEBUG in the autoreducer scripts - that env var ↵Alon Zakai2019-07-191-1/+2
| | | | is the one piece of global state we use (#2237)
* SimplifyGlobals: Constant-propagate constant values of immutable globals (#2234)Alon Zakai2019-07-189-12/+138
|
* Auto-reduce testcases from the FuzzExec handler in the fuzzer (#2232)Alon Zakai2019-07-181-26/+126
| | | | | | | When it finds a failing testcase, it reduces the list of optimizations, and then runs wasm-reduce to reduce the wasm itself. This refactors the testcase handlers into two kinds: one returns a list of commands to run (get_commands()), and we can auto-reduce them. The others get all the parameters and do whatever they want internally, and we can't auto-reduce them yet. If it is useful, auto-reducing could be added to the other handlers (CompareVMs, Wasm2JS, etc.) by modifying them to the new form. Tested manually by breaking stuff.
* Generalize EM_JS parsing code. (#2233)Alon Zakai2019-07-181-27/+6
| | | | | The key thing is that there is a single constant, which may or may not be saved/loaded from a local, and may or may not get an added global if in relocatable code. Fixes emscripten-core/emscripten#8993
* Cleanups after renaming Bysyncify to Asyncify (#2228)Alon Zakai2019-07-162-8/+7
| | | | | * Clarify the difference between old and new Asyncify. * Remove the old --bysyncify pass option.
* Tail call C/JS API (#2223)Thomas Lively2019-07-1510-73/+261
|
* [fuzzing] Give each testcase handler a list of feature flags it requires. ↵Alon Zakai2019-07-151-3/+37
| | | | | (#2225) That way we can still test new flags on modes that do support them (e.g. FuzzExec runs on everything)
* Bysyncify => Asyncify (#2226)Alon Zakai2019-07-1525-1240/+1242
| | | | | | | After some discussion this seems like a less confusing name: what the pass does is "asyncify" code, after all. The one downside is the name overlaps with the old emscripten "Asyncify" utility, which we'll need to clarify in the docs there. This keeps the old --bysyncify flag around for now, which is helpful for avoiding temporary breakage on CI as we move the emscripten side as well.
* Rename except_ref type to exnref (#2224)Heejin Ahn2019-07-1434-101/+101
| | | | In WebAssembly/exception-handling#79 we agreed to rename `except_ref` type to `exnref`.
* Stop emitting "almost asm" in wasm2js output (#2221)Alon Zakai2019-07-12104-129/+0
| | | We don't ever emit "use asm" anymore, so this similar annotation is not really useful, it just increases size.
* Handle passive segments in wasm-emscripten-finalize (#2217)Thomas Lively2019-07-114-5/+198
|
* Optimize select fallthrough values (#2220)Alon Zakai2019-07-116-21/+33
| | | This became noticeable after #2216 which led to some eqz eqz pairs in the test suite.
* Add an option to emit a symbols file from wasm2js. (#2214)Alon Zakai2019-07-112-0/+18
| | | This can't use the normal wasm-opt mechanism because we modify the discard the wasm as part of running wasm2js, so we need to emit it in the proper place in the middle.
* Fix FuzzExec fuzzer, which forgot to run the opts (#2215) [ci skip]Alon Zakai2019-07-111-1/+1
|
* Optimize if of br_if (#2216)Alon Zakai2019-07-1114-90/+250
| | | | | | | An if whose body is a br_if can be turned into a br_if of a combined condition (if side effects allow it). The naive size in bytes is identical between the patterns, but the select may avoid a hardware branch, and also the select may be further optimized. On the benchmark suite this helps every single benchmark, but by quite small amounts (e.g. 100 bytes on sqlite, which is 1MB). This was noticed in emscripten-core/emscripten#8941
* Don't minify __stack_pointer import (#2219)Sam Clegg2019-07-114-2/+4
| | | This is core import like __memory_base and __table_base.
* Fix comparison signedness errors in optimizeMemoryAccess() (#2211)Sean Stangl2019-07-101-3/+3
|
* wasm-emscripten-finalize: Internalize mutable __stack_pointer import (#2213)Sam Clegg2019-07-104-0/+34
| | | | | | | | | | | I'm working on a change to lld that will cause `-pie` binaries to import __stack_pointer, just like -shared do already. Because we don't yet support mutable globals everywhere this change will internalize the import and create a new immutable import that is used to initialize the internal one. This change is part of the fix for: https://github.com/emscripten-core/emscripten/issues/8915
* Create version_86Sam Clegg2019-07-101-1/+4
|
* Ignore --initial-stack-pointer arg to wasm-emscripten-finalize (#2201)Sam Clegg2019-07-1016-31/+22
| | | | | | | | | | | | | We were passing bad value in --initial-stack-pointer which did not include the STATIC_BUMP (since STATIC_BUMP is determinted by the output of finalize). If emscripten wants to set the stack pointer position it can do so by calling the stackRestore() function at startup. This argument will be removed completely once we stop passing it on the emscripten side. See https://github.com/emscripten-core/emscripten/issues/8905
* Support wasm files without exported memory in scripts/fuzz_shell.js (#2210)Alon Zakai2019-07-091-1/+3
|
* Allows multiple arguments to be passed to PassRunner::add<T>() (#2208)Ryoga2019-07-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | struct FooPass : public wasm::Pass { FooPass(int a, int b); }; PassRunner runner {module}; runner.add<FooPass>(1, 2); // To allow this This change avoids unnecessary copying and allows us to pass the reference without reference_wrapper. struct BarPass : public wasm::Pass { BarPass(std::ostream& s); }; runner.add<BarPass>(std::cout); // Error (cout is uncopyable) runner.add<BarPass>(std::ref(std::cout)); // OK ↓ runner.add<BarPass>(std::cout); // OK (passed by reference) runner.add<BarPass>(std::ref(std::cout)); // OK
* fix wasm2js compilation after conflicting landings (#2209)Alon Zakai2019-07-081-0/+8
|
* update fuzzer to use all features that pass fuzzing in all modes (which is ↵Alon Zakai2019-07-081-5/+10
| | | | currently just sign-ext...) (#2200)
* wasm2js: use OverriddenVisitor, so we show a clear error on unsupported ↵Alon Zakai2019-07-081-2/+62
| | | | instructions (#2199)
* Initial tail call implementation (#2197)Thomas Lively2019-07-0322-35/+182
| | | | | | | | | | | Including parsing, printing, assembling, disassembling. TODO: - interpreting - effects - finalization and typing - fuzzing - JS/C API
* Use v8 to test wasm binaries are valid in test suite binary checks (#2206)Alon Zakai2019-07-037-362/+74
|
* Loosen conditions on MemoryPacking (#2205)Thomas Lively2019-07-033-4/+12
| | | | Allow MemoryPacking to run when there are no passive segments, even if bulk memory is enabled.
* Clean up loose ends in feature handling (#2203)Thomas Lively2019-07-038-9/+44
| | | | | Fix and test mutable globals support, replace string literals with constants, and add a pass to emit the target features section.
* Minimal Push/Pop support (#2207)Alon Zakai2019-07-0324-14/+419
| | | | | | | This is the first stage of adding support for stacky/multivaluey things. It adds new push/pop instructions, and so far just shows that they can be read and written, and that the optimizer doesn't do anything immediately wrong on them. No fuzzer support, since there isn't a "correct" way to use these yet. The current test shows some "incorrect" usages of them, which is nice to see that we can parse/emit them, but we should replace them with proper usages of push/pop once we actually have those (see comments in the tests). This should be enough to unblock exceptions (which needs a pop in try-catches). It is also a step towards multivalue (I added some docs about that), but most of multivalue is left to be done.
* wasm2js: export memory growth function only if memory growth is enabled (#2194)Alon Zakai2019-07-037-2/+388
| | | Previously we tried to export it if the memory was exported, even if growth was not on, which caused an error.
* Fix event section order (#2202)Heejin Ahn2019-07-021-1/+1
| | | | | | The event section should be between the global section and the export section, if present. Here tests are missing, but we don't have a very good way of testing validity of binary anyway. We are planning to add d8 tests in a separate PR.
* Bysyncify: Assertion improvements (#2193)Alon Zakai2019-07-019-132/+375
| | | | | Add assertions on stack overflow in all 4 Bysyncify API calls (previously only 2 did it). Also add a check that those assertions are hit.
* Limit interpreter depth in precompute, but not when running whole modules ↵Alon Zakai2019-07-012-17/+33
| | | | | | | (#2191) Keep limiting in precompute as before: that is useful since that pass is run as part of normal compilation, and we want to avoid native stack limits on all platforms. Also that pass is not likely to find any pattern of size 50 of higher that it can't precompute as a sum of smaller pieces. Restore the 250 limit from before for interpreting entire modules, as without that the fuzzer will sometimes hit the limit and cause a false positive.
* Bysyncify: Fuzzing (#2192)Alon Zakai2019-07-017-22/+273
| | | | | | | | Gets fuzzing support for Bysyncify working. * Add the python to run the fuzzing on bysyncify. * Add a JS script to load and run a testcase with bysyncify support. The code has all the runtime support for sleep/resume etc., which it does on calls to imports at random in a deterministic manner. * Export memory from fuzzer so JS can access it. * Fix tiny builder bug with makeExport.
* Workaround for wasm2js output minification issue with emscripten (#2185)Brion Vibber2019-07-016-12/+18
| | | | | | | | | | | | | | * Workaround for wasm2js output minification issue with emscripten When using emscripten with -O2 and --memory-init-file 0, the JS minification breaks on this function for memory initialization setup, causing an exception to be thrown during module setup. Moving from two 'var' declarations for the same variable to one should avoid hitting this with no change in functionality (the var gets hoisted anyway). https://github.com/emscripten-core/emscripten/issues/8886
* Relax bulk memory rules (#2186)Thomas Lively2019-06-302-43/+14
| | | As decided in the recent in-person CG meeting.
* Bysyncify: allow wildcard endings in import list (#2190)Alon Zakai2019-06-303-9/+82
| | | This allows us to do things in emscripten like note that all env.invoke_* functions are important.
* Bysyncify: fix skipping of flattened if condition (#2187)Alon Zakai2019-06-304-51/+142
| | | | | We assigned it to a local, but didn't run maybeSkip on it. As a result, it was executed during rewinding, which broke restoring the saved value. Found by the fuzzer.
* wip (#2189)Alon Zakai2019-06-301-1/+1
|
* Bysyncify: ensure memory exists (#2188)Alon Zakai2019-06-303-0/+65
| | | | | We need memory in order to read and write rewinding info, so add it if the module didn't have any memory at all. Found by the fuzzer.
* binaryen.js building: don' t assume the intermediate form is bitcode (#2184)Alon Zakai2019-06-261-3/+3
| | | (which it isn't when using the wasm backend with object files)