summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Exponentially empty out function bodies when reducing (#3997)Alon Zakai2021-07-201-45/+75
| | | | | | | | | This removes the code that did so one at a time, and instead adds it in a way that we can do it in an exponentially growing set of functions. On large testcases where other methods do not work, this is very useful. Also adjust the factor to do this 20x more often, which in practice is very useful too.
* [Optimize Instructions] Simplify sign extentions (#4004)Max Graey2021-07-203-12/+115
| | | | | | | | | | | | | | requiring sign-extension: ``` i64(x) << 56 >> 56 ==> i64.extend8_s(x) i64(x) << 48 >> 48 ==> i64.extend16_s(x) i64(x) << 32 >> 32 ==> i64.extend32_s(x) i64.extend_i32_s(i32.wrap_i64(x)) ==> i64.extend32_s(x) ``` general: ``` i32.wrap_i64(i64.extend_i32_s(x)) ==> x i32.wrap_i64(i64.extend_i32_u(x)) ==> x ```
* RemoveUnusedBrs: Do not create a select with a multivalue result (#4005)Alon Zakai2021-07-192-3/+60
| | | | | The spec disallows that. Fixes #3990
* Fix tiny typo (#3995)Alon Zakai2021-07-191-1/+1
|
* [clang-tidy-diff] Replace readlink -f to inline python script (#4001)Max Graey2021-07-191-1/+6
| | | fix #3985
* [Memory64] Fixed atomics / bulk memory support. (#3992)Wouter van Oortmerssen2021-07-194-5/+68
|
* Revert "Partially fix Precompute on SIMD (#3983)" (#4002)Alon Zakai2021-07-193-24/+10
| | | | | | | | | | | | | This reverts commit b68691e826a46d1b03b27c552b1f5b7f51f92665. Instead of applying the workaround to avoid precomputing SIMD in more places, which prevents things we could optimize before, we should probably focus on making the workaround not needed - that is, implement full SIMD support in the intepreter (the reason for that PR), and the other TODO in the comment here, // Until engines implement v128.const and we have SIMD-aware optimizations // that can break large v128.const instructions into smaller consts and // splats, do not try to precompute v128 expressions.
* [Optimize-Instructions] Simplify sign patterns like x < 0 ? -1 : 1 (#3756)Max Graey2021-07-162-0/+140
| | | | | | i32(x) < 0 ? i32(-1) : i32(1) -> x >> 31 | 1 i64(x) < 0 ? i64(-1) : i64(1) -> x >> 63 | 1 This shrinks 2 bytes.
* Add DS_Store to non-executable filter in check.py (#3999)Max Graey2021-07-161-1/+1
|
* [Wasm GC] Fix getSentType() of BrOn with an unreachable input (#3993)Alon Zakai2021-07-163-0/+29
| | | | Without this fix, DCE would end up calling getHeapType() on the unreachable input, which hits an assertion as it has no heap type.
* Port test/passes/da* to lit (#3991)Thomas Lively2021-07-166-633/+648
|
* [Wasm GC] Add Wasm GC support to InstrumentMemory (#3976)Alon Zakai2021-07-153-2/+373
| | | | | | | | This adds calls to imports around every struct load and store, to note their values, and also to arrays (where it also notes the index). This has been very useful in debugging LowerGC (lowering of Wasm GC to wasm MVP).
* Port test/passes/c* to lit (#3988)Thomas Lively2021-07-1515-6221/+6259
|
* Fuzzer: Fix handling of features with initial contents (#3981)Alon Zakai2021-07-151-1/+16
| | | | | | | Now that the features section adds on top of the commandline arguments, it means the way we test if initial contents are ok to use will not work if the wasm has a features section - as it will enable a feature, even if we wanted to see if the wasm can work without that feature. To fix this, strip the features section there.
* Port test/passes/a* to lit (#3987)Thomas Lively2021-07-1414-4606/+4624
|
* Fuzzer: Use NameTypes in RoundTrip (#3986)Alon Zakai2021-07-141-1/+5
| | | | | | This works around the issue with wasm gc types sometimes getting truncated (as the default names can be very long or even infinitely recursive). If the truncation leads to name collision, the wast is not valid.
* Implement q15MulrSatSI16x8 for interpreter (#3984)Max Graey2021-07-143-2/+19
|
* Partially fix Precompute on SIMD (#3983)Alon Zakai2021-07-133-10/+24
| | | We had the logic in only one place.
* Implement interpretation of i64x2.bitmask (#3982)Thomas Lively2021-07-134-2/+14
| | | | | | | Like a few other SIMD operations, this i64x2.bitmask had not been implemented in the interpreter yet. Unlike the others, i64x2.bitmask has type i32 rather than type v128, so Precompute was not skipping it, leading to a crash, as in https://github.com/emscripten-core/emscripten/issues/14629. Fix the problem by implementing i64x2.bitmask in the interpreter.
* Fix features section handling in the fuzzer (#3980)Alon Zakai2021-07-131-6/+26
| | | | | | | | | | The features section is additive since #3960. For the fuzzer to know which features are used, it therefore needs to also scan the features section. To do this, run --print-features to get the total features used from both flags + the features section. A result of this is that we now have a list of enabled features instead of "enable all, then disable". This is actually clearer I think, but it does require inverting the logic in some places.
* Port test/passes/inlin* to lit (#3972)Thomas Lively2021-07-1317-32328/+32359
|
* Port test/passes/flatten* to lit (#3971)Thomas Lively2021-07-1225-19582/+16797
|
* Improve NameTypes to keep reasonable names (#3977)Alon Zakai2021-07-122-7/+23
| | | | We only set a name now if there was no name, or the existing name was really really long.
* [Wasm GC] Add a isNonNullable() convenience method. NFC (#3978)Alon Zakai2021-07-128-10/+26
|
* Fix the fuzzer on wasm2c2wasm: emcc must request d8 support now (#3975)Alon Zakai2021-07-091-0/+1
| | | | | | Emscripten stopped emitting shell support code by default (as most users run node.js, but here we are literally fuzzing d8). Fixes #3967
* [Memory64] further memory limit fixes (#3865)Wouter van Oortmerssen2021-07-095-3/+29
| | | That were somehow missed.. triggered by emscripten tests
* Do not execute lit tests via an external shell (#3974)Thomas Lively2021-07-081-1/+1
| | | | | | We were previously configuring lit to execute test scripts via an external shell, which caused lit to look for a bash installation on Windows. To make lit tests work more "out of the box" on Windows, change the configuration to use lit's built in shell capabilities instead.
* Port test/passes/asyncify* to lit (#3970)Thomas Lively2021-07-0848-11191/+11522
|
* Port test/passes/O* to lit (#3969)Thomas Lively2021-07-0728-3718/+3804
|
* Filter more passes tests in porting script (#3968)Thomas Lively2021-07-071-8/+9
| | | | | | Filter out tests using --metrics, --emit-{js,spec}-wrapper, --fuzz-exec, --print-stack-ir, --dwarfdump, etc. because they have ouput that will not be captured in the automatically generated checks. Also filter based on the list of passes rather than the test file in case the test uses a .passes file.
* Lit tests for tool help messages (#3965)Thomas Lively2021-07-0714-107/+1092
| | | | | | Add list tests for the help messages of all tools, factoring out common options into shared tests. This is slightly brittle because the text wrapping depends on the length of the longest option, but that brittleness should be worth the benefit of being able to see the actual help text in the tests.
* Add a script for porting passes tests to lit (#3963)Thomas Lively2021-07-034-59/+173
| | | And use it to port the very simple untee test.
* Support generating checks for multiple modules (#3962)Thomas Lively2021-07-022-80/+135
| | | | | | In conjunction with the `foreach` tool, allows autogenerating checks for lit tests containing multiple modules. Supporting this will help automatically port existing bespoke wast tests to be lit tests, since many of those tests contain multiple modules per file.
* [NFC] Refactor update_lit_checks.py (#3964)Thomas Lively2021-07-021-111/+120
| | | | Decompose the code into more functions and make other simplifying changes to prepare for multi-module support introduced in #3962.
* [Wasm GC] Add support for non-nullable locals in binary reading (#3955)Alon Zakai2021-07-022-8/+14
| | | | | | | We only tested that feature on the text format. For binary support, the reader needs to know that the feature is enabled, so that it allows non-nullable locals in that case (i.e., does not apply the workarounds to remove them). Fixes #3953
* Apply features from the commandline first (#3960)Alon Zakai2021-07-0215-107/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | As suggested in https://github.com/WebAssembly/binaryen/pull/3955#issuecomment-871016647 This applies commandline features first. If the features section is present, and disallows some of them, then we warn. Otherwise, the features can combine (for example, a wasm may enable feature X because it has to use it, and a user can simply add the flag for feature Y if they want the optimizer to try to use it; both flags will then be enabled). This is important because in some cases we need to know the features before parsing the wasm, in the case that the wasm does not use the features section. In particular, non-nullable GC locals have an effect during parsing. (Typed function references also does, but we found a way to apply its effect all the time, that is, always use the refined type, and that happened to not break the case where the feature is disabled - but such a workaround is not possible with non-nullable locals.) To make this less error-prone, add a FeatureSet input as a parameter to WasmBinaryBuilder. That is, when building a module, we must give it the features to use while doing so. This will unblock #3955 . That PR will also add a test for the actual usage of a feature during loading (the test can only be added there, after that PR unbreaks things).
* Add option to add checks for all items (#3961)Thomas Lively2021-07-0213-45/+105
| | | | | | | | Add an --all-items flag to update_lit_checks.py to emit checks for all module items, not just those that match items in the input. Update two tests to use generated input with the new flag. Also, to improve readability, insert an empty line between consecutive checks for different items.
* Set an absolute maximum inlining limit (#3959)Alon Zakai2021-07-012-0/+27
| | | | | | | | | | | We have seen some cases in both Chrome and Firefox where extremely large modules cause overhead, #3730 (comment) (and link therein) emscripten-core/emscripten#13899 (comment) There is no "right" value to use as a limit here, but pick an arbitrary one that is very high. (This setting is verified to have no effect on the emscripten benchmark suite.)
* Preserve Function HeapTypes (#3952)Thomas Lively2021-06-3054-299/+295
| | | | | | | | | When using nominal types, func.ref of two functions with identical signatures but different HeapTypes will yield different types. To preserve these semantics, Functions need to track their HeapTypes, not just their Signatures. This PR replaces the Signature field in Function with a HeapType field and adds new utility methods to make it almost as simple to update and query the function HeapType as it was to update and query the Function Signature.
* [Wasm GC] Fix LinearExecutionWalker (#3954)Alon Zakai2021-06-293-3/+71
| | | | | | | | | | That traversal did not mention BrOn, which led to it doing incorrect work in SimplifyLocals. Also add assertions at the end, that aim to prevent future issues. The rest of the fix is to make SimplifyLocals not assume that things are a Switch if they are not an If/Block/etc., so that we don't crash on a BrOn.
* Only set `supertype` if nominal typing is enabled (#3958)Thomas Lively2021-06-292-28/+50
| | | | | | | | | | | | | The code for printing and emitting the experimental nominal type constructors added in #3933 assumes that supertypes were only returned from `getSuperType` when nominal typing was enabled. `getSuperType` in turn was assuming that the supertype field would only be set if nominal typing was enabled, but this was not the case. This bug caused use-after-free errors because equirecursive canonicalization left the supertype field pointing to a temporary HeapTypeInfo that would be freed at the end of parsing but then accessed during module writing. To fix the issue, only set `supertype` if nominal typing is enabled, as originally intended.
* Generate FileCheck checks for all module items (#3957)Thomas Lively2021-06-2838-57/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of only generating checks for functions, generate checks for all named top-level module items, such as types, tags, tables, and memories. Because module items can be in different orders in the input and the output but FileCheck checks must follow the order of the output, we need to be slightly clever about when we emit the checks. Consider these types in the input file: ``` (type $A (...)) (type $B (...)) ``` If their order is reversed in the output file, then the checks for $B need to be emitted before the checks for $A, so the resulting module will look like this: ``` ;; CHECK: (type $B (...)) ;; CHECK: (type $A (...)) (type $A (...)) (type $B (...)) ``` Rather than this, which looks nicer but would be incorrect: ``` ;; CHECK: (type $A (...)) (type $A (...)) ;; CHECK: (type $B (...)) (type $B (...)) ```
* Refactor LinearExecutionWalker to a separate file. NFC (#3956)Alon Zakai2021-06-286-113/+143
|
* Handle invokes of invalid function pointers. See #14174 (#3951)Alon Zakai2021-06-243-20/+50
| | | | | | | | | PostEmscripten will turn an invoke of a constant function pointer index into a direct call. However, due to UB it is possible to have invalid function pointers, and we should not crash on that (and do nothing to optimize, of course). Mostly whitespace; to avoid deep nesting, I added more early returns.
* [EH] Make tag attribute's encoding uint8 (#3949)Heejin Ahn2021-06-221-4/+4
| | | | | | | | | | | This changes the encoding of the `attribute` field, which currently only contains the value `0` denoting this tag is for an exception, from `varuint32` to `uint8`. This field is effectively unused at the moment and reserved for future use, and it is not likely to need `varuint32` even in future. See https://github.com/WebAssembly/exception-handling/pull/162. This does not change any encoded binaries because `0` is encoded in the same way both in `varuint32` and `uint8`.
* Revert accidental debugging changes from #3935 (#3950)Thomas Lively2021-06-222-7/+3
|
* Preserve function heap types during text parsing (#3935)Thomas Lively2021-06-225-37/+77
| | | | | | | | | | | | | | Previously, ref.func instructions would be assigned the canonical (i.e. first parsed) heap type for the referenced function signature rather than the HeapType actually specified in the type definition. In nominal mode, this could cause validation failures because the types assigned to ref.func instructions would not be correct. Fix the problem by tracking function HeapTypes rather than function Signatures when parsing the text format. There can still be validation failures when round-tripping modules because function HeapTypes are not properly preserved after parsing, but that will be addressed in a follow-up PR.
* [EH] Make tag's attribute encoding detail (#3947)Heejin Ahn2021-06-2115-46/+19
| | | | | | | | | This removes `attribute` field from `Tag` class, making the reserved and unused field known only to binary encoder and decoder. This also removes the `attribute` parameter from `makeTag` and `addTag` methods in wasm-builder.h, C API, and Binaryen JS API. Suggested in https://github.com/WebAssembly/binaryen/pull/3946#pullrequestreview-687756523.
* Remove (attr 0) from tag text format (#3946)Heejin Ahn2021-06-1956-166/+142
| | | | | | | | This attribute is always 0 and reserved for future use. In Binayren's unofficial text format we were writing this field as `(attr 0)`, but we have recently come to the conclusion that this is not necessary. Relevant discussion: https://github.com/WebAssembly/exception-handling/pull/160#discussion_r653254680
* [Wasm GC] Fix inlining + non-nullable locals (#3945)Alon Zakai2021-06-182-1/+53
| | | | | | We don't need to assign a zero value for such locals (and we can't, as no default value exists for them). Fixes #3944