summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Duplicate Import Elimination (#2292)Alon Zakai2019-08-099-46/+158
| | | | | | | | | | | | | This is both an optimization and a workaround for the problem that emscripten-core/emscripten#7641 uncovered and had to be reverted because of. What's going on there is that wasm-emscripten-finalize turns emscripten_longjmp_jmpbuf into emscripten_longjmp (for some LLVM internal reason - there's a long comment in the source that I didn't fully follow). There are two such imports already, one for each name, and before that PR, we ended up with just one. After that PR, we end up with two. And with two, the minification of import names gets confused - we have two imports with the same name, and the code there ends up ignoring one of them. I'm not sure why that PR changed things - I guess the wasm-emscripten-finalize code looks at the name, and that PR changed what name appears? @sbc100 maybe #2285 is related? Anyhow, it's not trivial to make import minification code support two identical imports, but I don't think we should - we should avoid having such duplication anyhow. And we should add an assert that they don't exist (I'll open a PR for that later when it's possible). This fixes the duplication by adding a useful pass to remove duplicate imports (just functions, for now). Pretty simple, but we didn't do it yet. Even if there is a wasm-emscripten-finalize bug we need to fix with those duplicate imports, I think this pass is still a good thing to add. I confirmed that this fixes the issue caused by that PR.
* Fix EM_ASM not working with setjmp/longjmp (#2283)Guanzhong Chen2019-08-093-53/+187
|
* Copying fixes (#2289)Alon Zakai2019-08-071-2/+4
| | | | | We didn't have an OverriddenVisitor in the copying code, and sadly unimplemented visitors just return null. That explains the crash in #2288 The missing visitors were push and pop.
* Make auto_update_tests.py support selective updates (#2287)Guanzhong Chen2019-08-071-12/+24
|
* Allow running a portion of binaryen test suite (#2286)Guanzhong Chen2019-08-073-35/+53
|
* wasm-emscripten-finalize: Remove reliance on name section (#2285)Sam Clegg2019-08-063-4/+16
| | | | | | | | There were a couple of places where we were relying on internal names and therefore a name section. After this change wasm-emscripten-finalize works correctly on binaries without a name section at all and only relies on the names of imports and exports.
* Remove trailing whitespaces after 'else' in stack IR (#2284)Heejin Ahn2019-08-063-8/+7
|
* Implement --check-stack-overflow flag for wasm-emscripten-finalize (#2278)Guanzhong Chen2019-08-026-8/+475
|
* Remove `-no-pie` since clang doesn't like it (#2279)Alex Crichton2019-08-021-2/+2
| | | | | | | It appears that the previous PR I had for `clang` didn't actually run on the PR and I forgot to include the removal of `-no-pie` in the PR. Sorry about that! This should fix the CI issues seen [here] [here]: https://travis-ci.org/WebAssembly/binaryen/jobs/566546589
* Revert "Fix EM_ASM not working with setjmp/longjmp (#2271)" (#2277)Alon Zakai2019-08-013-180/+53
| | | | | This reverts commit 692f4666fd116fb7827b53348978f29bba253d47. See details in the reverted PR.
* Compile Linux release binaries with Clang (#2274)Alex Crichton2019-08-011-1/+3
| | | | | | This fixes #2273 for... unknown reasons. The tl;dr; is that the current release binaries built in this Alpine container seem to segfault when run over some wasm files when an exception is thrown, but clang-built binaries magically seems to not segfault!
* Proper Asyncify list name handling (#2275)Alon Zakai2019-07-314-0/+50
| | | | | The lists are comma separated, but the names can have internal commas since they are human-readable. This adds awareness of bracketing things, so void foo(int, double) is parsed as a single function name, properly. Helps emscripten-core/emscripten#9128
* Python3-ify check.py and auto_update_tests.py (#2270)Alon Zakai2019-07-3121-271/+233
| | | | | I fixed flatten.bin.txt which seems to have just had some corrupted data, and I removed some fancy unicode from the spec comments tests, which I'm not sure it's important enough to figure out how to fix. Fixes #1691
* Fix EM_ASM not working with setjmp/longjmp (#2271)Guanzhong Chen2019-07-313-53/+180
| | | | | This fix does not handle dynamic linking, which requires additional work. Refs https://github.com/emscripten-core/emscripten/issues/8894.
* Make sure binaryen.js tests validate (#2269)Heejin Ahn2019-07-2911-12/+61
| | | | | | Without `assert`, even if a test does not validate, the errors will only show up in its corresponding `.txt` file while the test will succeed. This makes sure it errors out when a test fails to validate. This also adds validation checks if there is none.
* Fix stack pointer identification for wasm::ABI::getStackSpace(). (#2243)William Maddox2019-07-283-0/+851
| | | | | | | | * Fix stack pointer identification for wasm::ABI::getStackSpace(). Recent stack pointer simplification in Emscripten broke the --spill-pointers pass. This fix for #2229 restores this functionality by recognizing an alternative coding idiom in Emscripten-generated WASM code.
* wasm2js: Mangle import names for JS (#2267)Alon Zakai2019-07-287-10/+114
| | | | | | | This fixes names that would be invalid in JS, like a.b. Turns out the Go compiler emits wasm with such imports. Also add some docs on how to use wasm2js. Fixes #2263
* Fix extra unreachable generation (#2266)Heejin Ahn2019-07-277-46/+412
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently various expressions handle this differently, and now we consistently follow this rules: --- For all non-control-flow value-returning instructions, if a type of an expression is unreachable, we emit an unreachable and don't emit the instruction itself. If we don't emit an unreachable, instructions that follow can have validation failure in wasm binary format. For example: ``` [unreachable] (f32.add [unreachable] (i32.eqz [unreachable] (unreachable) ) ... ) ``` This is a valid prgram in binaryen IR, because the unreachable type propagates out of an expression, making both i32.eqz and f32.add unreachable. But in binary format, this becomes: ``` unreachable i32.eqz f32.add ;; validation failure; it expects f32 but takes an i32! ``` And here f32.add causes validation failure in wasm validation. So in this case we add an unreachable to prevent following instructions to consume the current value (here i32.eqz). In actual tests, I used `global.get` to an f32 global, which does not return a value, instead of `f32.add`, because `f32.add` itself will not be emitted if one of argument is unreachable. --- So the changes are: - For instructions that don't return a value, removes unreachable emitting code if it exists. - Add the unreachable emitting code for value-returning instructions if there isn't one. - Check for unreachability only once after emitting all children for atomic instructions. Currently only atomic instructions check unreachability after visiting each children and bail out right after, which is valid, but not consistent with others. - Don't emit an extra unreachable after a return (and return_call). I guess it is unnecessary.
* Fix unreachable prefix in instruction printing (#2265)Heejin Ahn2019-07-268-11/+86
| | | | | | | | | When a memory instruction's type is unreachable, i.e., one of its child expressions is unreachable, the instruction will be printed like `unreachable.load`, which is invalid text format. This prints unreachable prefix instruction types as `i32` to just make them pass the parser. It is OK because they are not reachable anyway. Also this removes printing of `?` in atomic.rmw instruction printing.
* Asyncify: whitelist and blacklist support (#2264)Alon Zakai2019-07-268-20/+733
| | | | | | | | | The blacklist means "functions here are to be ignored and not instrumented, we can assume they never unwind." The whitelist means "only these functions, and no others, can unwind." I had hoped such lists would not be necessary, since Asyncify's overhead is much smaller than the old Asyncify and Emterpreter, but as projects have noticed, the overhead to size and speed is still significant. The lists give power users a way to reduce any unnecessary overhead. A slightly tricky thing is escaping of names: we escape names from the names section (see #2261 #1646). The lists arrive in human-readable format, so we escape them before comparing to the internal escaped names. To enable that I refactored wasm-binary a little bit to provide the escaping logic, cc @yurydelendik If both lists are specified, an error is shown (since that is meaningless). If a name appears in a list that is not in the module, we show a warning, which will hopefully help people debug typos etc. I had hoped to make this an error, but the problem is that due to inlining etc. a single list will not always work for both unoptimized and optimized builds (a function may vanish when optimizing, due to duplicate function elimination or inlining). Fixes #2218.
* Enable all features in wasm-shell assert failure tests (#2254)Heejin Ahn2019-07-251-0/+1
| | | | | | | If we don't enable features in assertion failure tests, new feature tests fail not because they are malformed but because they have unsupported features. It's hard to add tests because existing `assert_invalid` tests were already failing because they have unsupported features.
* More push/pop support (#2260)Heejin Ahn2019-07-2410-38/+255
| | | | | | | This adds - `push`/`pop` support for other types: v128 and exnref - `push`/`pop` support for binaryen.js Because binaryen.js follows Binaryen's AST structure, without `pop` in binaryen.js, EH instructions cannot be represented in binaryen.js.
* Remove extra parens from binaryen-c.cpp (NFC) (#2262)Heejin Ahn2019-07-241-21/+21
|
* Fuzz all feature flags, and fix another SignExt issue in the fuzzer (#2259)Alon Zakai2019-07-242-5/+8
|
* Put Extend* opcodes behind SignExt feature. fixes #2257 (#2258)Alon Zakai2019-07-241-1/+1
|
* Add tail-call to the change log (#2253)Thomas Lively2019-07-241-0/+2
|
* Print events in color (#2255)Heejin Ahn2019-07-241-7/+21
| | | | | This prints events in color like other module elements such as globals. This also splits `visitEvent` into two functions to be consistent with `visitGlobals` or `visitFunctions`.
* Allow 0-value events (#2256)Heejin Ahn2019-07-246-12/+11
| | | | Before I disallowed events with no values, but spec does not say anything about it, so I think that restriction is not necessary.
* Finalize tail call support (#2246)Thomas Lively2019-07-2328-139/+758
| | | | Adds tail call support to fuzzer and makes small changes to handle return calls in multiple utilities and passes. Makes larger changes to DAE and inlining passes to properly handle tail calls.
* Upgrade Travis CI system (#2252)Heejin Ahn2019-07-232-5/+9
| | | | | | | This upgrades the OS in the Travis CI to Bionic and GCC version to 7. This also fixes a bug that COMPILER_FLAGS was not correctly added at build time in gcc tests. Somehow this bug hasn't manifested so far, but after upgrading, this failed thread sanitizer tests because -fsanitize=thread was added only at link time and not in build time.
* 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.