summaryrefslogtreecommitdiff
path: root/scripts
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Port test/passes/O* to lit (#3969)Thomas Lively2021-07-071-0/+3
|
* 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.
* Add a script for porting passes tests to lit (#3963)Thomas Lively2021-07-031-0/+110
| | | And use it to port the very simple untee test.
* Support generating checks for multiple modules (#3962)Thomas Lively2021-07-021-52/+94
| | | | | | 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.
* Add option to add checks for all items (#3961)Thomas Lively2021-07-021-14/+44
| | | | | | | | 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.
* Generate FileCheck checks for all module items (#3957)Thomas Lively2021-06-281-31/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 (...)) ```
* Add a `foreach` script for use in lit testsThomas Lively2021-06-171-0/+46
| | | | | | | The major drawback of lit tests is that so far they have only supported a single module per test file. This commit adds a new utility script that splits an input file into multiple files and runs a command on each of them, giving lit tests a simple way to test multiple modules per file.
* [Wasm GC] rtt.fresh_sub (#3936)Alon Zakai2021-06-171-0/+1
| | | | | | | | | | This is the same as rtt.sub, but creates a "new" rtt each time. See https://docs.google.com/document/d/1DklC3qVuOdLHSXB5UXghM_syCh-4cMinQ50ICiXnK3Q/edit# The old Literal implementation of rtts becomes a little more complex here, as it was designed for the original spec where only structure matters. It may be worth a complete redesign there, but for now as the spec is in flux I think the approach here is good enough.
* Properly handle comparisons of 64-bit ints in wasm2c in the fuzzer. (#3918)Alon Zakai2021-06-081-0/+16
| | | | | | | The support code there emits "low high" as the result, for example, 25 0 would be 25 (as the high bits are all 0). This is different than how numbers are reported in other things we fuzz, so this caused an error. Fixes #3915
* [Wasm GC] Add negated BrOn* operations (#3913)Alon Zakai2021-06-021-0/+5
| | | | | | They are basically the flip versions. The only interesting part in the impl is that their returned typed and sent types are different. Spec: https://docs.google.com/document/d/1DklC3qVuOdLHSXB5UXghM_syCh-4cMinQ50ICiXnK3Q/edit
* [Wasm GC] Add experimental array.copy (#3911)Alon Zakai2021-05-271-0/+1
| | | | | | | | Spec for it is here: https://docs.google.com/document/d/1DklC3qVuOdLHSXB5UXghM_syCh-4cMinQ50ICiXnK3Q/edit# Also reorder some things in wasm.h that were not in the canonical order (that has no effect, but it is confusing to read).
* Heap2Local: Use escape analysis to turn heap allocations into local data (#3866)Alon Zakai2021-05-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we allocate some GC data, and do not let the reference escape, then we can replace the allocation with locals, one local for each field in the allocation basically. This avoids the allocation, and also allows us to optimize the locals further. On the Dart DeltaBlue benchmark, this is a 24% speedup (making it faster than the JS version, incidentially), and also a 6% reduction in code size. The tests are not the best way to show what this does, as the pass assumes other passes will clean up after. Here is an example to clarify. First, in pseudocode: ref = new Int(42) do { ref.set(ref.get() + 1) } while (import(ref.get()) That is, we allocate an int on the heap and use it as a counter. Unnecessarily, as it could be a normal int on the stack. Wat: (module ;; A boxed integer: an entire struct just to hold an int. (type $boxed-int (struct (field (mut i32)))) (import "env" "import" (func $import (param i32) (result i32))) (func "example" (local $ref (ref null $boxed-int)) ;; Allocate a boxed integer of 42 and save the reference to it. (local.set $ref (struct.new_with_rtt $boxed-int (i32.const 42) (rtt.canon $boxed-int) ) ) ;; Increment the integer in a loop, looking for some condition. (loop $loop (struct.set $boxed-int 0 (local.get $ref) (i32.add (struct.get $boxed-int 0 (local.get $ref) ) (i32.const 1) ) ) (br_if $loop (call $import (struct.get $boxed-int 0 (local.get $ref) ) ) ) ) ) ) Before this pass, the optimizer could do essentially nothing with this. Even with this pass, running -O1 has no effect, as the pass is only used in -O2+. However, running --heap2local -O1 leads to this: (func $0 (local $0 i32) (local.set $0 (i32.const 42) ) (loop $loop (br_if $loop (call $import (local.tee $0 (i32.add (local.get $0) (i32.const 1) ) ) ) ) ) ) All the GC heap operations have been removed, and we just have a plain int now, allowing a bunch of other opts to run. That output is basically the optimal code, I think.
* Fuzz with maximal inlining some of the time (#3871)Alon Zakai2021-05-101-0/+8
|
* Fuzzer: Ignore things we should ignore even if the process succeeded (#3864)Alon Zakai2021-05-061-16/+22
| | | | | | | | | | | | | We only ignored known issues if the process failed. However, some things do not bring the process down, but are still necessary to ignore, which this fixes. Another approach might be to make all the things we need to ignore fail the entire process. However, that could be annoying for other debugging: we don't want a host limit on say hitting a VM limit on recursion to bring down the entire process, as those limits manifest as traps, and we can still run after them (and do need to test that). The specific host limit that made me fix this was the trap on OOM when trying to allocate an array of size 4GB.
* Run spec test all at once after binary transform (#3817)Abbas Mashayekh2021-04-202-2/+1
| | | | | | | | | | | | | | | | | | #3792 added support for module linking and (register command to wasm-shell, but forgot about three problems: - Splitting spec tests prevents linking test modules together. - Registered modules may still be used in assertions or an invoke - Modules may re-export imported objects This PR appends transformed modules after binary checks to a spec.wast file, plus assertion tests and register commands. Then runs wasm-shell on the whole file. It also keeps both the module name and its registered name available in wasm-shell for use in shell commands and linked modules. Furthermore, it correctly finds the module where an object is defined even if it is imported and re-exported several times. The updated version of imports.wast spec test is enabled to verify the fixes.
* Fuzzer: Do not fuzz multivalue testcases in initial contents (#3809)Alon Zakai2021-04-151-0/+21
| | | | | | | | | | There is a conflict between multivalue and GC, see the details in the comment. There isn't a good way to get the fuzzer to avoid the combination of them, and GC is more urgent, so disable multivalue in that area for now. (This does not disable all multivalue fuzzing - the fuzzer can still emit stuff. This just disables initial content from test suite having multivalue, which is enough for now, until the fuzzer can emit more GC things, and then we'll need to do more.)
* Fuzzer: Distinguish traps from host limitations (#3801)Alon Zakai2021-04-121-1/+7
| | | | | | | | | Host limitations are arbitrary and can be modified by optimizations, so ignore them. For example, if the optimizer removes allocations then a host limit on an allocation error may vanish. Or, an optimization that removes recursion and replaces it with a loop may avoid a host limit on call depth (that is not done currently, but might some day). This removes a class of annoying false positives in the fuzzer.
* Rename SIMD extending load instructions (#3798)Daniel Wirtz2021-04-121-6/+6
| | | | | | | | | Renames the SIMD instructions * LoadExtSVec8x8ToVecI16x8 -> Load8x8SVec128 * LoadExtUVec8x8ToVecI16x8 -> Load8x8UVec128 * LoadExtSVec16x4ToVecI32x4 -> Load16x4SVec128 * LoadExtUVec16x4ToVecI32x4 -> Load16x4UVec128 * LoadExtSVec32x2ToVecI64x2 -> Load32x2SVec128 * LoadExtUVec32x2ToVecI64x2 -> Load32x2UVec128
* Rename various SIMD load instructions (#3795)Daniel Wirtz2021-04-111-6/+6
| | | | | | | | | Renames the SIMD instructions * LoadSplatVec8x16 -> Load8SplatVec128 * LoadSplatVec16x8 -> Load16SplatVec128 * LoadSplatVec32x4 -> Load32SplatVec128 * LoadSplatVec64x2 -> Load64SplatVec128 * Load32Zero -> Load32ZeroVec128 * Load64Zero -> Load64ZeroVec128
* [Wasm GC] Enable more GC fuzzing (#3788)Alon Zakai2021-04-081-6/+7
| | | | | | The fuzzer doesn't generate much GC code yet, but it does fuzz things in the test suite and adds fuzz to them. This PR allows GC when using initial content, and also in CompareVMs, both of which have been fuzzed for days locally for me with no issues.
* Fuzz --converge (#3789)Alon Zakai2021-04-081-0/+3
|
* Add v128.load/storeN_lane SIMD instructions to C/JS API (#3784)Daniel Wirtz2021-04-081-8/+8
| | | | | | | | | | | Adds C/JS APIs for the SIMD instructions * Load8LaneVec128 (was LoadLaneVec8x16) * Load16LaneVec128 (was LoadLaneVec16x8) * Load32LaneVec128 (was LoadLaneVec32x4) * Load64LaneVec128 (was LoadLaneVec64x2) * Store8LaneVec128 (was StoreLaneVec8x16) * Store16LaneVec128 (was StoreLaneVec16x8) * Store32LaneVec128 (was StoreLaneVec32x4) * Store64LaneVec128 (was StoreLaneVec64x2)
* Fuzzer: Ignore our current bug with the type of br_if (#3775)Alon Zakai2021-04-061-1/+6
| | | | | | We give br_if a too specific type: #3767 This is only noticeable with GC, and in rare cases where the type of br_if is actually used - which realistically it never is, so really just fuzzer testcases.
* Update SIMD names and opcodes (#3771)Thomas Lively2021-04-051-55/+42
| | | | Also removes experimental SIMD instructions that were not included in the final spec proposal.
* Disallow flatten + GC in the fuzzer due to RTTs (#3768)Alon Zakai2021-04-011-0/+3
| | | RTTs are not defaultable, and we cannot spill them to locals.
* Avoid flatten + multivalue + reference types in the fuzzer (#3760)Alon Zakai2021-03-311-0/+3
| | | | | | | | | The problem is that a tuple with a non-nullable element cannot be stored to a local. We'd need to split up the tuple, but that raises questions about what should be allowed in flat IR (we'd need to allow nested tuple ops in more places). That combination doesn't seem urgent, so add a clear error for now, and avoid it in the fuzzer. Avoids #3759 in the fuzzer
* Allow clang-format-diff/clang-tidy-diff to take branch as argument (#3711)Sam Clegg2021-03-222-11/+8
| | | | | Also update clang-format-diff.sh to match recent changes to branch name and CI system (these changes mirror those already made to clang-tidy-diff.sh).
* Add `-o pipefail` to shell scripts (#3706)Sam Clegg2021-03-193-1/+4
| | | | This means that if any command in a pipelines fails the whole pipeline will also fail.
* Regenerate lld tests (#3684)Sam Clegg2021-03-121-0/+2
| | | | | | | | | | | This change as automatically generated by: $ ./scripts/test/generate_lld_tests.py $ ./auto_update_tests.py --binaryen-bin=../binaryen-out/bin lld The changes here are mostly due to: - llvm now emits names for globals and segments - emscripten now packs EM_ASM consts into a single contiguous segment
* Stop emitting features section in fuzzer (#3652)Alon Zakai2021-03-041-1/+1
|
* Make the reduction script more robust, and document text reduction (#3640)Alon Zakai2021-03-031-5/+17
| | | | | The check for a valid wasm file must be different if the wasm has a feature section or not, so just try both ways, with --detect-features and --all-features. If the wasm is valid, at least one will work.
* Update clang-tidy-diff.sh for GH Actions (#3619)Thomas Lively2021-02-261-10/+3
|
* Update V8 feature flags for the fuzzer (#3569)Heejin Ahn2021-02-181-3/+3
| | | | | | This removes feature flags that are now included in `--wasm-staging` and adds new experimental flags. Does not change the fuzzer's behavior at the moment because the fuzzer does not seem to be currently enabled for GC or typed funcref yet.
* Add feature options to wasm-dis (#3548)Abbas Mashayekh2021-02-082-2/+2
| | | | | | This will allow .fromBinary tests be executed with the desired featurs so there will be no difference between those tests and .from-wast tests. Fixes #3545
* Prototype i32x4.widen_i8x16_{s,u} (#3535)Thomas Lively2021-02-011-0/+2
| | | | | | | | As proposed in https://github.com/WebAssembly/simd/pull/395. Note that the other instructions in the proposal have not been implemented in LLVM or in V8, so there is no need to implement them in Binaryen right now either. This PR introduces a new expression class for the new instructions because they uniquely take an immediate argument identifying which portion of the input vector to widen.
* [GC] br_on_null (#3528)Alon Zakai2021-02-011-0/+1
| | | | | | | | | | | This is only partial support, as br_on_null also has an extra optional value in the spec. Implementing that is cumbersome in binaryen, and there is ongoing spec discussions about it (see https://github.com/WebAssembly/function-references/issues/45 ), so for now we only support the simple case without the default value. Also fix prefixed opcodes to be LEBs in RefAs, which was noticed here as the change here made it noticeable whether the values were int8 or LEBs.
* [GC] ref.as_non_null (#3527)Alon Zakai2021-01-281-0/+1
| | | | | | This is different than the other RefAs variants in that it is part of the typed functions proposal, and not GC. But it is part of GC prototype 3. Note: This is not useful to us yet as we don't support non-nullable types.
* [GC] Add br_on_func/data/i31 (#3525)Alon Zakai2021-01-281-1/+4
| | | | | | | | This expands the existing BrOnCast into BrOn that can also handle the func/data/i31 variants. This is not as elegant as RefIs / RefAs in that BrOnCast has an extra rtt field, but I think it is still the best option. We already have optional fields on Break (the value and condition), so making rtt optional is not odd. And it allows us to share all the behavior of br_on_* which aside from the cast or the check itself, is identical - returning the value if the branch is not taken, etc.
* Remove test suite's assumption of minify_check roundtripping perfectly (#3524)Alon Zakai2021-01-271-13/+2
| | | | | | | | | | | | minify_check checks that we can print and read minified wast. The test also, however, assumed that we round-trip such things perfectly. That's never been true, and only by chance did this go unnoticed until now, in #3523 The specific issue happening there is that we create a block without a name. Then we write that as text, then read it. When we read it, we give all such blocks a name (and we rely on optimizations to remove it later when possible - this avoids optimizing in the parser). The extra name looks like a bug to minify_check.
* [GC] ref.as_* (#3520)Alon Zakai2021-01-271-0/+3
| | | | | | | | These are similar to is, but instead of returning an i32 answer, they trap on an invalid value, and return it otherwise. These could in theory be in a single RefDoThing, with opcodes for both As and Is, but as the return values are different, that would be a little odd, and the name would be less clear.
* [GC] ref.is_func/data/i31 (#3519)Alon Zakai2021-01-261-2/+5
|
* [GC] RefIsNull => RefIs. (#3516)Alon Zakai2021-01-261-1/+1
| | | | | | | | This internal refactoring prepares us for ref.is_func/data/i31, by renaming the node and adding an "op" field. For now that field must always be "Null" which means it is a ref.is_null. This adjusts the C API to match the new IR shape. The high-level JS API is unchanged.
* Warn when running a pass not compatible with DWARF (#3506)Alon Zakai2021-01-261-1/+2
| | | | | | | | | | | | Previously the addDefault* methods would avoid adding opt passes that we know are incompatible with DWARF. However, that didn't handle the case of passes that are added in other ways. For example, when running Asyncify, emcc will run --flatten before, and that pass is not compatible with DWARF. This PR lets us warn on that by annotating the passes themselves. Then we use those annotation to either not run a pass at all (matching the previous behavior) or to show a warning when necessary. Fixes emscripten-core/emscripten#13288 . That is, concretely after this PR running asyncify + DWARF will show a warning to the user.
* Remove exnref and br_on_exn (#3505)Heejin Ahn2021-01-222-9/+0
| | | This removes `exnref` type and `br_on_exn` instruction.
* Introduce a script for updating lit tests (#3503)Thomas Lively2021-01-213-5/+186
| | | | And demonstrate its capabilities by porting all tests of the optimize-instructions pass to use lit and FileCheck.
* Prototype additional f64x2 conversions (#3501)Thomas Lively2021-01-191-0/+7
| | | | As proposed in https://github.com/WebAssembly/simd/pull/383, with opcodes coordinated with the WIP V8 prototype.
* Replace "master" with "main" in scripts and docs (#3502)Thomas Lively2021-01-192-2/+2
| | | | We have updated the default branch name from "master" to "main." This PR updates scripts, configurations, and docs to reflect this change.
* Prototype prefetch instructions (#3467)Thomas Lively2021-01-061-0/+3
| | | | As proposed in https://github.com/WebAssembly/simd/pull/352, using the opcodes used in the LLVM and V8 implementations.