summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* DWARF: Fix sequence_end emitting (#2929)Alon Zakai2020-06-242-638/+644
| | | | | | | | | | | | | We must emit those, even if otherwise it looks like a line we can omit, as the ends of sequences have important meaning and dwarfdump will warn without them. Looks like fannkuch0 in the test suite already had an example of an incorrectly-omitted sequence_end, so no need for a new testcase. Verified that without this e.g. wasm2.test_exceptions with -g added will lead to a wasm that warns, but with this PR the debug_line section is reported as valid by dwarfdump.
* Wasm2js Atomics support (#2924)Alon Zakai2020-06-235-10/+543
| | | | | Atomic loads, stores, RMW, cmpXchg, wait, and notify. This is enough to get the asm.js atomics tests in the emscripten test suite to pass, at least (but they are a subset of the entire pthreads suite).
* wasm2js: Avoid 64-bit scratch memory helpers in wasm-intrinsics (#2926)Alon Zakai2020-06-2310-1024/+317
| | | | | | | | | | | | | | That code originally used memory location 1024 to save 64 bits of data (as that is what rust does apparently). We refactored it manually to instead use a scratch memory helper, which is safer. However, that 64-bit function ends up legalized, which actually changes the interface between the module and the outside, which is confusing and causes problems with optimizations that can remove the getTempRet0 imports, see emscripten-core/emscripten#11456 Instead, just use a global i64 to stash those bits. This requires adding support for copying globals from the intrinsics module, but otherwise seems simpler overall.
* Fix breakage on master from colliding landings (#2927)Alon Zakai2020-06-232-0/+2
|
* Asyncify liveness analysis (#2890)Alon Zakai2020-06-2311-854/+1453
| | | | | | | | | This finds out which locals are live at call sites that might pause/resume, which is the set of locals we need to actually save/load. That is, if a local is not alive at any call site in the function, then it's value doesn't need to stay alive while sleeping. This saves about 10% of locals that are saved/loaded, and about 1.5% in final code size.
* wasm2js: start function support (#2920)Alon Zakai2020-06-224-1/+138
|
* More optimizations for pow of two and pos/neg one const on the right (#2870)Max Graey2020-06-2211-318/+749
|
* wasm2js: Bulk memory support (#2923)Alon Zakai2020-06-2230-70/+1018
| | | | | | | | | | | | | | Adds a special helper functions for data.drop etc., as unlike most wasm instructions these are too big to emit inline. Track passive segments at runtime in var memorySegments whose indexes are the segment indexes. Emit var bufferView even if the memory exists even without memory segments, as we do still need the view in order to operate on it. Also adds a few constants for atomics that will be useful in future PRs (as this PR updates the constant lists anyhow).
* wasm2js testing improvements before bulk-memory (#2918)Alon Zakai2020-06-207-21/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Necessary preparations for a later PR that adds bulk memory support to wasm2js (splitting this out so the next PR is less big): * Fix logging of print functions in wasm2js spec tests, there was an extra space in the output (which console.log adds automatically between items). * Don't assume the output is always empty, as some tests (like bulk memory) do have expected output. * Rename test/bulk-memory.wast as it "conflicts" with test/spec/bulk-memory.wast - the problem is that we scan both places, and emit files in test/wasm2js/*, so those would collide if the names overlap. * Extend the parsing and emitting of JS for (assert.. ) lines such as (assert_return (invoke "foo" (i32.const 1)) (i32.const 2)) to also handle (invoke "foo" (i32.const 1)) (i32.const 2)) Without this, we skip (invoke ..) lines in spec tests, which normally is fine, but in bulk memory at least they have side effects we need - we must run them before the later assertions.
* Fuzzer: Ignore V8 warnings on removed flags when comparing VMs (#2916)Alon Zakai2020-06-181-3/+15
| | | fixes #2915
* Optimize bit count polyfills (#2914)Max Graey2020-06-172-26/+75
|
* Asyncify: Instrument indirect calls from functions in add-list or only-list ↵Alon Zakai2020-06-173-18/+262
| | | | | | | | | | | | | | | | | | | | | | (#2913) When doing manual tuning of calls using asyncify lists, we want it to be possible to write out all the functions that can be on the stack when pausing, and for that to work. This did not quite work right with the ignore-indirect option: that would ignore all indirect calls all the time, so that if foo() calls bar() indirectly, that indirect call was not instrumented (we didn't check for a pause around it), even if both foo() and bar() were listed. There was no way to make that work (except for not ignoring indirect calls at all). This PR makes the add-list and only-lists fully instrument the functions mentioned in them: both themselves, and indirect calls from them. (Note that direct calls need no special handling - we can just add the direct call target to the add-list or only-list.) This may add some overhead to existing users, but only in a function that is instrumented anyhow, and also indirect calls are slow anyhow, so it's probably fine. And it is simpler to do it this way instead of adding another list for indirect call handling.
* Add Expression::dump for use while debugging (#2912)Thomas Lively2020-06-152-0/+11
| | | | | I have found that similar dump functions have been extremely helpful while debugging LLVM. Rather than re-implement this locally whenever I need it, it would be better have this utility upstream.
* Asyncify: Add an "add list", rename old lists (#2910)Alon Zakai2020-06-129-64/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Asyncify does a whole-program analysis to figure out the list of functions to instrument. In emscripten-core/emscripten#10746 (comment) we realized that we need another type of list there, an "add list" which is a list of functions to add to the instrumented functions list, that is, that we should definitely instrument. The use case in that link is that we disable indirect calls, but there is one special indirect call that we do need to instrument. Being able to add just that one can be much more efficient than assuming all indirect calls in a big codebase need instrumentation. Similar issues can come up if we add a profile-guided option to asyncify, which we've discussed. The existing lists were not good enough to allow that, so a new option is needed. I took the opportunity to rename the old ones to something better and more consistent, so after this PR we have 3 lists as follows: * The old "remove list" (previously "blacklist") which removes functions from the list of functions to be instrumented. * The new "add list" which adds to that list (note how add/remove are clearly parallel). * The old "only list" (previously "whitelist") which simply replaces the entire list, and so only those functions are instrumented and no other. This PR temporarily still supports the old names in the commandline arguments, to avoid immediate breakage for our CI.
* Move optional metadata field so its not last (#2909)Sam Clegg2020-06-1135-75/+84
| | | | To avoid the conditional trailing comma.
* Version 94 (#2907)Sam Clegg2020-06-112-1/+4
|
* Default mainReadsParams to true in standalone mode (#2906)Sam Clegg2020-06-116-20/+21
| | | | | | | The process of DCE'ing the argument handling is already handled in a different way in standalone more. In standalone mode the entry point is `_start` which takes no args, and argv code is included on-demand via the presence or absence the wasi syscalls for argument processing (__wasi_args_get/__wasi_args_sizes_get).
* Support new clang mangling of main (__main_argc_argv) (#2671)Sam Clegg2020-06-103-1/+26
| | | | | | | | | The plan is that for standlone mode we can function just like wasi-sdk and call the correct main from crt1.c. For non-standalone mode we still want to export can call main directly so we rename __main_argc_argv back to main as part of finalize. See https://reviews.llvm.org/D70700
* Rename anyref to externref to match proposal change (#2900)Jay Phelps2020-06-1072-490/+499
| | | | | | | anyref future semantics were changed to only represent opaque host values, and thus renamed to externref. [Chromium](https://bugs.chromium.org/p/v8/issues/detail?id=7748#c360) was just updated to today (not yet released). I couldn't find a Mozilla bugzilla ticket mentioning externref so I don't immediately know if they've updated yet. https://github.com/WebAssembly/reference-types/pull/87
* Prevent calls from sinking into 'try' (#2899)Heejin Ahn2020-06-073-0/+84
| | | | Expressions that may throw cannot be sinked into 'try'. At the start of 'try', we drop all sinkables that may throw.
* Micro-optimize base64Decode (#2897)juj2020-06-069-63/+45
| | | | | * Micro-optimize base64Decode * Update test expectations
* Add prototype SIMD rounding instructions (#2895)Thomas Lively2020-06-0525-60/+669
| | | As specified in https://github.com/WebAssembly/simd/pull/232.
* Reland "Link binaryen tools against the dylib" (#2892)Derek Schuff2020-06-035-97/+62
| | | | | Reland of #2864 Also ensure a relative install rpath by adding setup to each tool config. The CMake code is cribbed from LLVM's implementation.
* DeNaN improvements (#2888)Alon Zakai2020-06-034-7/+212
| | | | | | | | | Instead of instrumenting every local.get, instrument parameters on arrival at a function once on entry. After that, every local will always contain a de-naned value (since we would denan on a local.set). This is more efficient and also less confusing I think. Also avoid doing anything to values that fall through as they have already been fixed up.
* Prevent pops from sinking in SimplifyLocals (#2885)Heejin Ahn2020-06-0310-13/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents `exnref.pop`s from being sinked and separated from `catch`. For example, ```wast (try (do) (catch (local.set $0 (exnref.pop)) (call $foo (i32.const 3) (local.get $0) ) ) ) ``` Here, if we sink `exnref.pop` to remove `local.set $0` and `local.get $0`, it becomes this: ```wast (try (do) (catch (nop) (call $foo (i32.const 3) (exnref.pop) ) ) ) ``` This move was possible because `i32.const 3` does not have any side effects. But this is incorrect because now `exnref.pop` does not follow right after `catch`. To prevent this, this patch checks this case in `canSink` in SimplifyLocals. When we encountered a similar case in CodeFolding, we prevented every expression that contains `Pop` anywhere in it from being moved, which was too conservative. This adds `danglingPop` property in `EffectAnalyzer`, so that only pops that are not enclosed within a `catch` count as 'dangling pops` and we only prevent those pops from being moved or sinked.
* Revert "Link binaryen tools against the dylib (#2864)" (#2891)Derek Schuff2020-06-025-37/+97
| | | This reverts commit f6b7f0018ca5ce604e94cc6cf50ee712bb7e9b27.
* Link binaryen tools against the dylib (#2864)Derek Schuff2020-06-025-97/+37
| | | When building the libbinaryen dynamic library, also link the binaryen tools against it. This reduces combined tool size on mac from 76M to 2.8M
* Fuzzing: Run --denan etc. even on a given wasm (#2887)Alon Zakai2020-06-021-1/+5
| | | | | | | | | When the fuzzer script is given a wasm we don't create a new one from scratch. But we should still apply --denan and other things so that we preserve those properties while reducing. Without this it's possible for reduction to start with a wasm with no nans but to lose the property eventually, and end up with a reduced testcase which is not quite what you want.
* When fuzzing asyncify, avoid optimizations with nans (#2881)Alon Zakai2020-06-021-4/+8
| | | | | We already avoid that in CompareVMs but Asyncify has the same issue, as it also can optimize in binaryen but run in another VM (with different nondeterministic NaN behavior).
* Fuzzer: Don't keep doing `--denan` etc. in testcase handlers (#2889)Alon Zakai2020-06-021-1/+1
| | | | | | | FUZZ_OPTS are things like --denan which affect generation of the original wasm. We were passing those to testcase handlers, which meant that in addition to the random optimizations we picked they were also running --denan etc. again. That can be confusing, so remove it.
* Fix SideEffect::Branches to only represent branches (#2886)Heejin Ahn2020-06-022-4/+4
| | | | | | After #2783 `SideEffects::Branches` includes possibly throwing expressions, which can be calls (when EH is enabled). This changes `SideEffects::Branches` back to only include branches, returns, and infinite loops as it was before #2783.
* Prevent calls from escaping try in CodeFolding (#2883)Heejin Ahn2020-06-013-11/+128
| | | | In CodeFolding, we should not take an expression that may throw out of a `try` scope. This patch adds this restriction in `canMove`.
* Put validator test outputs in out/test (#2882)Heejin Ahn2020-05-311-6/+6
| | | | | | | We now put outputs of all other tests in out/test in order not to pollute the test directory, but validator tests didn't have a output file specified so their output files were written in test/validator. This adds `-o a.wasm` to validator tests command lines, in the same way as other tests, to make them go into out/test directory.
* Refactor Effects (#2873)Alon Zakai2020-05-292-33/+52
| | | | | | | Avoid special work in analyze(). This lets breakTargets always reflect the breaks that we've seen and that might be external, and we check it in hasSideEffects etc. Also do some internal refactoring and renamings for clarity.
* Flat IR: local.set's value should not be a control flow (#2589)Alon Zakai2020-05-271-4/+10
|
* DeNaN pass (#2877)Alon Zakai2020-05-2711-1553/+211
| | | | | | This moves the fuzzer de-NaN logic out into a separate pass. This is cleaner and also better since the old way would de-NaN once, but then the reducer could generate code with nans. The new way lets us de-NaN while reducing.
* Improve fuzzer message when finding a bug (#2878)Alon Zakai2020-05-271-3/+15
|
* Fix DWARF location list updating with nonzero compilation unit base addr ↵Paolo Severini2020-05-276-3/+664
| | | | | | | | | | | | | | | | (#2862) In the .debug_loc section the Start/End address offsets in a location list are relative to the address of the compilation unit that refers that location list. There is a problem in function wasm::Debug:: updateLoc(), which compares these offsets with the actual module addresses of expressions and functions, causing the generation of invalid location lists. The fix is not trivial, because the DWARF debug_loc section does not specify which is the compilation unit associated to each location list entry. A simple workaround is to store, in LocationUpdater, a map of location list offsets to the base address of the compilation units referencing them, and that can be easily calculated in updateDIE().
* Flatten fuzz fix with unreachable special-casing (#2876)Alon Zakai2020-05-279-48/+237
| | | | | | | | | The special-casing of unreachable there could lead to bad behavior, where we did nothing to the unreachable and ended up moving something with side effects before it, see testcase in test/passes/flatten_all-features.wast. This emits less efficient code, but only if --dce was not run earlier, so probably not worth optimizing.
* Fuzz asyncify fuzzer: when no exported memory, skip (#2874)Alon Zakai2020-05-271-3/+4
| | | | We need the memory to be exported in order to read and write stuff for the asyncify data structure.
* Add link to Github Action tab for badge (#2875)Max Graey2020-05-261-1/+1
|
* Update filer actions for CI badge (#2866)Max Graey2020-05-261-1/+1
|
* Fix issues with cleanup dSYM in scripts for MacOS (#2871)Max Graey2020-05-262-9/+0
| | | | Remove rmtree call from check.py & auto_update_tests.py
* Remove `Push` (#2867)Thomas Lively2020-05-2236-547/+68
| | | | | | Push and Pop have been superseded by tuples for their original intended purpose of supporting multivalue. Pop is still used to represent block arguments for exception handling, but there are no plans to use Push for anything now or in the future.
* Update CI status badgeDerek Schuff2020-05-211-2/+1
|
* Rebaseline tests after stack_save update (#2865)Derek Schuff2020-05-211-6/+0
|
* Remove stackSave/stackAlloc/stackRestore code generation (#2852)Sam Clegg2020-05-2032-1069/+64
| | | | | | | These are now implemented in assembly as part of emscripten's compiler-rt. See: https://github.com/emscripten-core/emscripten/pull/11166
* Add EH support for SimplifyLocals (#2858)Heejin Ahn2020-05-194-5/+102
| | | | | | | - `br_on_exn`'s target block cannot be optimized to have a separate return value. This handles that in `SimplifyLocals`. - `br_on_exn` and `rethrow` can trap (when the arg is null). This handles that in `EffectAnalyzer`. - Fix a few nits
* Implement i64x2.mul (#2860)Thomas Lively2020-05-1924-57/+134
| | | | This is the only instruction in the current spec proposal that had not yet been implemnented in the tools.
* [dwarf] Handle a bad mapped base in debug_loc updating (#2859)Alon Zakai2020-05-182-5/+19
| | | | Turns out we had a testcase for this already, but were doing the wrong thing on it.