summaryrefslogtreecommitdiff
path: root/scripts
Commit message (Collapse)AuthorAgeFilesLines
* [EH][test] Split EH tests into old and new spec (#6178)Heejin Ahn2023-12-131-0/+2
| | | | | | | | | This moves tests for the old EH spec to `exception-handling-old.wast` and moves the new `exnref` test into `exception-handling.wast`, onto which I plan to add more tests for the new EH spec. The primary reason for splitting the files is I plan to exclude the new EH test from the fuzzing while the new spec's implementation is in progress, and I don't want to exclude the old EH tests altogether.
* [test] Port tests in test/ to test/lit/basic/ (#6160)Heejin Ahn2023-12-132-63/+8
| | | | | | | | | | | | | | | | | | | | | This ports all tests from `test/` to `test/lit/basic/`. The set of commands and `CHECK` lines used are the same as the ones in #6159. Now we use `lit` to test these, this also deletes all `.wast`, `.wast.from-wast`, `.wast.fromBinary`, and `.wast.fromBinary.noDebugInfo` files from `test/` and all related test routines from the python scripts. All `CHECK` lines are generated by `update_lit_checks.py --all-items`. This also deletes these three multi-memory tests in `test/lit/`, because they seem to contain the same code with the ones in `test/`, which have been ported to `test/lit/basic/` along with other tests. - `test/lit/multi-memories-atomics64.wast` - `test/lit/multi-memories-basics.wast` - `test/lit/multi-memories-simd.wast` This also adds newlines between `(func`s in case there are none to make `CHECK` lines easy to view, and removes some extra existing newlines here and there.
* Add an arity immediate to tuple.extract (#6172)Thomas Lively2023-12-121-1/+1
| | | | | | | | Once support for tuple.extract lands in the new WAT parser, this arity immediate will let the parser determine how many values it should pop off the stack to serve as the tuple operand to `tuple.extract`. This will usually coincide with the arity of a tuple-producing instruction on top of the stack, but in the spirit of treating the input as a proper stack machine, it will not have to and the parser will still work correctly.
* Add a `tuple.drop` text pseudoinstruction (#6170)Thomas Lively2023-12-121-0/+1
| | | | | | | | | | | | | | | | | We previously overloaded `drop` to mean both normal drops of single values and also drops of tuple values. That works fine in the legacy text parser since it can infer parent-child relationships directly from the s-expression structure of the input, so it knows that a drop should drop an entire tuple if the tuple-producing instruction is a child of the drop. The new text parser, however, is much more like the binary parser in that it uses instruction types to create parent-child instructions. The new parser always assumes that `drop` is meant to drop just a single value because that's what it does in WebAssembly. Since we want to continue to let `Drop` IR expressions consume tuples, and since we will need a way to write tests for that IR pattern that work with the new parser, introduce a new pseudoinstruction, `tuple.drop`, to represent drops of tuples. This pseudoinstruction only exists in the text format and it parses to normal `Drop` expressions. `tuple.drop` takes the arity of its operand as an immediate, which will let the new parser parse it correctly in the future.
* Update `tuple.make` text format to include arity (#6169)Thomas Lively2023-12-121-1/+1
| | | | | | | | | | Previously, the number of tuple elements was inferred from the number of s-expression children of the `tuple.make` expression, but that scheme would not work in the new wat parser, where s-expressions are optional and cannot be semantically meaningful. Update the text format to take the number of tuple elements (i.e. the tuple arity) as an immediate. This new format will be able to be implemented in the new parser as follow-on work.
* [test] Fix wasm2js stale check failure (#6168)Heejin Ahn2023-12-111-2/+2
| | | | | | | I tried to exclude wasm2js asserts tests from `check_for_stale_files` in #6164, but ended up doing it incorrectly. The file I checked for was `wasm2js.wast.asserts`, while the output I should have excluded was `wasm2js.asserts.js`. This fixes the code so we now check the prefix and not the filename.
* [test] Remove asm2wasm tests from scripts (#6162)Heejin Ahn2023-12-112-24/+0
| | | | We don't have `*.fromasm` files anymore. Also `BIN_DIR` and `WATERFALL_BUILD_DIR` variables don't seem to be used as well.
* [test] Remove / move *.js tests from test/ (#6163)Heejin Ahn2023-12-111-4/+4
| | | | | | | | | | | | | `wasm2js.asserts.js` and `wasm2js.traps.js` seem to be used in wasm2js asserts test: https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28 https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L126-L127 But other `*.js` tests in `test/` don't seem to be used anywhere. Please let me know if they are actually being used. This moves `wasm2js.asserts.js` and `wasm2js.traps.js`, which are only used in wasmjs tests, to `test/wasm2js/`, and deletes all other `*.js` tests in `test/`.
* [test] Make get_tests return only files (#6164)Heejin Ahn2023-12-112-0/+3
| | | | | | | | | | | | | | | | | | | | Currently `get_tests` returns files and directories, especially when the extension is not given. This makes `get_tests` return a directory like `test/wasm2js/` as a test. `wasm2js.py`'s `check_for_stale_files` errors out when there are files within `test/wasm2js/` whose basenames don't match any files within any of `test/`, `test/spec/`, `test/wasm2js/`. https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L33-L46 `wasm2js.wast.asserts` is apparently a special case for asserts test: https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28 and this doesn't seem to have the matching `wast` tests in the three test directories. But it just happened to not error out because `get_tests` returns directory names too and one of them was `wasm2js` (`test/wasm2js/` directory). This makes `get_tests` return only files, and make files in `assert_tests` not error out additionally.
* [Parser] Parse try/catch/catch_all/delegate (#6128)Thomas Lively2023-11-291-6/+4
| | | | | | | | | | | | | | Parse the legacy v3 syntax for try/catch/catch_all/delegate in both its folded and unfolded forms. The first sources of significant complexity is the optional IDs after `catch` and `catch_all` in the unfolded form, which can be confused for tag indices and require backtracking to parse correctly. The second source of complexity is the handling of delegate labels, which are relative to the try's parent scope despite being parsed after the try's scope has already started. Handling this correctly requires punching a whole big enough to drive a truck through through both the parser and IRBuilder abstractions.
* [wasm-emscripten-finalize] Remove --separate-data-segments (#6091)Sam Clegg2023-11-271-37/+12
| | | See #6088
* Remove various testing spam (#6109)Alon Zakai2023-11-143-6/+7
| | | | | Avoid some common warnings and stop printing various stdout/stderr stuff. Helps #6104
* [Parser][NFC] Filter out unused instructions in gen-s-parser.py (#6095)Thomas Lively2023-11-091-0/+5
| | | | | | The new wat parser parses block, if, loop, then, and else keywords directly rather than depending on code generated from gen-s-parser.py. Filter these keywords out in gen-s-parser.py when generating the new wat parser and delete the stub functions that the removed generated code used to depend on.
* Implement table.copy (#6078)Alon Zakai2023-11-061-2/+1
| | | Helps #5951
* Support '%S' placeholder in update_lit_checks.py (#6075)Alexander Guryanov2023-11-021-0/+1
|
* Typed Continuations: Add cont type (#5998)Frank Emrich2023-10-241-0/+2
| | | | | | | | | This PR is part of a series that adds basic support for the [typed continuations proposal](https://github.com/wasmfx/specfx). This PR adds continuation types, of the form `(cont $foo)` for some function type `$foo`. The only notable changes affecting existing code are the following: - This is the first `HeapType` which has another `HeapType` (rather than, say, a `Type`) as its immediate child. This required fixes to certain traversals that have a flag for being at the toplevel of a type. - Some shared logic for parsing `HeapType`s has been factored out.
* [analysis][NFC] Use C++20 concepts for Lattice (#6027)Thomas Lively2023-10-181-3/+6
| | | | | | | | | | | | | Replace the static assertions ensuring that Lattice types have the necessary operations with a C++20 concept called `Lattice`. To avoid name conflicts with the new concept, rename existing type parameters named `Lattice` to `L`. When not building with C++20, `Lattice` is a macro that resolves to `typename` so the code continues compiling and has the same behavior, but without any eager checks of the requirements on lattices. Add a new C++20 builder to CI to ensure that future changes compile with both C++17 and C++20. Once we switch to C++20 by default, the new builder can be removed. Update the lint builder to use a recent clang-format that understands concepts.
* Fuzzer: Add missing simplify-globals* passes (#6025)Alon Zakai2023-10-181-0/+2
|
* Fuzzer: Mark runs where over 50% of functions trap as ignored (#6007)Alon Zakai2023-10-131-3/+18
| | | | | | | | The number of ignored functions is logged out, so this can help us avoid getting into a situation where many testcases just trap most of the time rather than doing anything useful. 50% seems a reasonable cutoff. Even if 50% of functions trap, at least we are getting 50% that don't, so lots of useful work.
* Add an "unsubtyping" optimization (#5982)Thomas Lively2023-10-101-0/+1
| | | | | | | | | | | | | | Add a new pass that analyzes the module to find the minimal subtyping relation that is necessary to maintain the validity and semantics of the program and rewrites the types to use this minimal relation. Besides eliminating references to otherwise-unused intermediate types, this optimization should unlock significant additional optimizing power in other type optimizations that are constrained by having to maintain supertype validity, since after this new optimization there are fewer and more general supertypes. The analysis works by visiting each expression and module element to collect the subtypings that are required to maintain its validity, then, using that as a starting point, iteratively adding new subtypings required by type definitions and casts until reaching a fixed point.
* [NFC][Parser] Simplify instruction handling (#5964)Thomas Lively2023-09-211-3/+2
| | | | | | | | | | | The new wat parser previously returned InstrT types when parsing individual instructions and collected InstrsT types when parsing sequences of instructions. However, instructions were always actually tracked in the internal state of the parsing context, so these types never held any interesting or necessary data. Simplify the parser by removing these types and leaning into the pattern that the parser context will keep track of parsed instructions. This allows for a much cleaner separation between the `instrs` and `foldedinstrs` parser functions.
* [Parser] Parse if-else in the new wat parser and IRBuilder (#5963)Thomas Lively2023-09-211-0/+3
| | | | | | Parse both the straight-line and folded versions of if, including the abbreviations that allow omitting the else clause. In the IRBuilder, generalize the scope stack to be able to track scopes other than blocks and add methods for visiting the beginnings of ifs and elses.
* Add passes to finalize or unfinalize types (#5944)Alon Zakai2023-09-181-0/+2
| | | | | | | | | TypeFinalization finalizes all types that we can, that is, all private types that have no children. TypeUnFinalization unfinalizes (opens) all (private) types. These could be used by first opening all types, optimizing, and then finalizing, as that might find more opportunities. Fixes #5933
* Implement table.fill (#5949)Thomas Lively2023-09-181-0/+1
| | | | | | | | This instruction was standardized as part of the bulk memory proposal, but we never implemented it until now. Leave similar instructions like table.copy as future work. Fixes #5939.
* Enable auto_initial_contents by default in fuzz_opt.py (#5943)Thomas Lively2023-09-142-5/+6
| | | | This setting is useful enough that there is basically no reason not to use it. Turn it on by default to save some typing when running the fuzzer.
* Add a simple tuple optimization pass (#5937)Alon Zakai2023-09-141-0/+1
| | | | | | | | | | | In some cases tuples are obviously not needed, such as when they are only used in local operations and make/extract. Such tuples are not used as return values or in control flow structures, so we might as well lower them to individual locals per lane, which other passes can optimize a lot better. I believe LLVM does the same with its own tuples: it lowers them as much as possible, leaving only necessary ones. Fixes #5923
* Replace i31.new with ref.i31 everywhere (#5931)Thomas Lively2023-09-131-1/+2
| | | | | Replace i31.new with ref.i31 in the printer, tests, and source code. Continue parsing i31.new for the time being to allow a graceful transition. Also update the JS API to reflect the new instruction name.
* Replace I31New with RefI31 everywhere (#5930)Thomas Lively2023-09-131-1/+1
| | | | | | | | Globally replace the source string "I31New" with "RefI31" in preparation for renaming the instruction from "i31.new" to "ref.i31", as implemented in the spec in https://github.com/WebAssembly/gc/pull/422. This would be NFC, except that it also changes the string in the external-facing C APIs. A follow-up PR will make the corresponding behavioral change.
* Remove legacy GC text syntax (#5929)Thomas Lively2023-09-121-1/+0
| | | | Remove the old forms of ref.test and ref.cast that took heap types instead of ref types and remove the old array.init_static name for array.new_fixed.
* Do not prompt user on fuzz_opt.py --auto-initial-contents (#5907)Thomas Lively2023-08-291-8/+0
| | | | | Remove the prompt for user confirmation when using the --auto-initial-contents option with the fuzzer. It is not actionable, and it prevents me from going off and doing something else when I build and start the fuzzer in the same command.
* Update stringref text format (#5891)Jérôme Vouillon2023-08-221-0/+9
| | | | | | | | | | | * Allow new syntax for some stringref opcodes Fixes #5607 * Update stringref text output * Update tests with new syntax for stringref opcodes Except in test/lit/strings.wat, to check that the legacy syntax still works.
* Rename multimemory flag (#5890)Ashley Nelson2023-08-211-4/+4
| | | Renaming the multimemory flag in Binaryen to match its naming in LLVM.
* Remove legacy WasmGC instructions (#5861)Thomas Lively2023-08-091-16/+2
| | | | | Remove old, experimental instructions and type encodings that will not be shipped as part of WasmGC. Updating the encodings and text format to match the final spec is left as future work.
* GUFA: Add a version that casts all of our inferences (#5846)Alon Zakai2023-07-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GUFA refines existing casts, but does not add new casts for fear of increasing code size and adding more cast operations at runtime. This PR adds a version that does add all those casts, and it looks like at least code size improves rather than regresses, at least on J2Wasm and Kotlin. That is, this pass adds a lot more casts, but subsequent optimizations benefit enough to shrink overall code size. However, this may still not be worthwhile, as even if code size decreases we may end up doing more casts at runtime, and those casts might be hard to remove, e.g.: (call $foo (x) ;; inferred to be non-null ) (func $foo (param (ref null $A) => (call $foo (ref.cast $A (x) ;; add a cast here ) (func $foo (param (ref $A) ;; later pass refines here That new cast cannot be removed after we refine the function parameter. If the function never benefits from the fact that the input is non-null, then the cast is wasted work (e.g. if the function only compares the input to another value). To use this new pass, try --gufa-cast-all rather than --gufa. As with normal GUFA, running the full optimizer afterwards is important, and even more important in order to get rid of as many of the new casts as possible.
* [NFC] Port passes remove-unused-brs_all-features.wast to lit (#5843)Thomas Lively2023-07-271-1/+1
| | | | Port the test automatically using the port_passes_tests_to_lit.py script. As a drive-by, fix a typo in the script as well.
* Add new V8 flag for final types and remove old removed ones (#5807)Alon Zakai2023-07-101-2/+1
|
* CtorEval Fuzzer: Generalize export regex (#5778)Alon Zakai2023-06-221-1/+1
| | | | | | Just look for export names as "" with some other stuff in the middle. Missing from the old regex: spaces, parens, and probably more. Spaces and parens are used in the test suite, which is how this was noticed by the fuzzer.
* StackIR: Remove nops (#5746)Alon Zakai2023-05-301-0/+2
| | | | | | | No nop instruction is necessary in wasm, so in StackIR we can simply remove them all. Fixes #5745
* Fuzzer: Ignore testcases that V8 OOMs on (#5733)Alon Zakai2023-05-181-0/+3
| | | | We already ignore OOMs in the interpreter. This adds the syntax for V8, which I saw an error on now (on an array.new of a massive size).
* Reintroduce wasm-merge (#5709)Alon Zakai2023-05-162-5/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to have a wasm-merge tool but removed it for a lack of use cases. Recently use cases have been showing up in the wasm GC space and elsewhere, as people are using more diverse toolchains together, for example a project might build some C++ code alongside some wasm GC code. Merging those wasm files together can allow for nice optimizations like inlining and better DCE etc., so it makes sense to have a tool for merging. Background: * Removal: #1969 * Requests: * wasm-merge - why it has been deleted #2174 * Compiling and linking wat files #2276 * wasm-link? #2767 This PR is a compete rewrite of wasm-merge, not a restoration of the original codebase. The original code was quite messy (my fault), and also, since then we've added multi-memory and multi-table which makes things a lot simpler. The linking semantics are as described in the "wasm-link" issue #2767 : all we do is merge normal wasm files together and connect imports and export. That is, we have a graph of modules and their names, and each import to a module name can be resolved to that module. Basically, like a JS bundler would do for JS, or, in other words, we do the same operations as JS code would do to glue wasm modules together at runtime, but at compile time. See the README update in this PR for a concrete example. There are no plans to do more than that simple bundling, so this should not really overlap with wasm-ld's use cases. This should be fairly fast as it works in linear time on the total input code. However, it won't be as fast as wasm-ld, of course, as it does build Binaryen IR for each module. An advantage to working on Binaryen IR is that we can easily do some global DCE after merging, and further optimizations are possible later.
* Prune trapping code during TrapsNeverHappen fuzzing (#5717)Alon Zakai2023-05-121-25/+68
| | | | | | | | | This removes the trapping export and all others after it. This avoids a potential infinite loop that can happen when fuzzing TNH, as if TNH is set and a trap happens then the optimizer can cause an iloop, and while that is valid, it would hang the fuzzer. We could check for a timeout, but it is faster and more robust to just remove the code we can't compare anyhow. This uses wasm-metadce to remove the exports from the failing one.
* [NFC] Refactor each of ArrayNewSeg and ArrayInit into subclasses for ↵Alon Zakai2023-05-041-4/+4
| | | | | | | | | | | Data/Elem (#5692) ArrayNewSeg => ArrayNewSegData, ArrayNewSegElem ArrayInit => ArrayInitData, ArrayInitElem Basically we remove the opcode and use the class type to differentiate them. This adds some code but it makes the representation simpler and more compact in memory, and it will help with #5690
* Fuzzer: Run --dce when GC is enabled (#5677)Alon Zakai2023-04-191-0/+9
| | | | | | | | | | | DCE at the end avoids issues with non-nullable local operations in unreachable code, which is still being discussed. This PR avoids fuzzer errors for now, but we should revert it when we have a proper fix. See * #5599 * #5665 * https://github.com/WebAssembly/function-references/issues/98
* Remove the --hybrid and --nominal command line options (#5669)Thomas Lively2023-04-141-5/+0
| | | | | After this change, the only type system usable from the tools will be the standard isorecursive type system. The nominal type system is still usable via the API, but it will be removed entirely in a follow-on PR.
* Implement array.fill, array.init_data, and array.init_elem (#5637)Thomas Lively2023-04-061-0/+3
| | | | | These complement array.copy, which we already supported, as an initial complete set of bulk array operations. Replace the WIP spec tests with the upstream spec tests, lightly edited for compatibility with Binaryen.
* Adjust fuzzer frequencies (#5612)Alon Zakai2023-03-311-6/+5
| | | | | | | | | | I ran CheckDeterminism at full throttle overnight (set to 1, and disabled all other things) and it found a bug, so we should focus on that more. Also ctor-eval as there is ongoing work there. I reduced a few other priorities of things that haven't seen bugs in a very long time and are not high priority.
* Switch fuzzer to hybrid typing (#5609)Alon Zakai2023-03-311-1/+1
| | | This is the default, and also used by J2Wasm.
* Fuzz partial-inlining-ifs (#5600)Alon Zakai2023-03-291-0/+4
|
* Use more than a single wasm page in Asyncify fuzzing (#5597)Alon Zakai2023-03-221-1/+3
| | | | | I saw a testcase fail on the internal assertion of the buffer being too small. Enlarge it to use as much of the memory we have anyhow to reduce that risk (we can use 15 pages instead of 1, without changing anything else).
* Fuzzer: Ignore infinite recursion in Asyncify handler (#5596)Alon Zakai2023-03-221-0/+17
|