summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Fix fuzzer's choosing of reference types (#4642)Alon Zakai2022-05-051-32/+37
| | | | | | * Don't emit "i31" or "data" if GC is not enabled, as only the GC feature adds those. * Don't emit "any" without GC either. While it is allowed, fuzzer limitations prevent this atm (see details in comment - it's fixable).
* Parse the prototype nominal binary format (#4644)Thomas Lively2022-05-042-0/+27
| | | | | | In f124a11ca3 we removed support for the prototype nominal binary format entirely, but that means that we can no longer parse older binary modules that used that format. Fix this regression by restoring the ability to parse the prototype binary format.
* Update StackCheck for memory64 (#4636)Sam Clegg2022-05-042-1/+94
|
* Remove externref (#4633)Thomas Lively2022-05-0432-425/+380
| | | | | | Remove `Type::externref` and `HeapType::ext` and replace them with uses of anyref and any, respectively, now that we have unified these types in the GC proposal. For backwards compatibility, continue to parse `extern` and `externref` and maintain their relevant C API functions.
* Replace 64K sparse matrix testcase with 8K (#4635)Alon Zakai2022-05-033-2/+2
| | | | Helps #4632: This makes it take 4 seconds instead of 5 minutes.
* Update nominal type ordering (#4631)Thomas Lively2022-05-0312-54/+86
| | | | | | V8 requires that supertypes come before subtypes when it parses isorecursive (i.e. standards-track) type definitions. Since 2268f2a we are emitting nominal types using the standard isorecursive format, so respect the ordering requirement.
* Handle call.without.effects in RemoveUnusedModuleElements (#4624)Alon Zakai2022-05-021-0/+112
| | | | | | | | | | | | | | | | | We assume a closed world atm in the GC space, but the call.without.effects intrinsic sort of breaks that: that intrinsic looks like an import, but we really need to care about what is sent to it even in a closed world: (call $call-without-effects (ref.func $target-keep) ) That reference cannot be ignored, as logically it is called just as if there were a call_ref there. This adds support for that, fixing the combination of #4621 and using call.without.effects. Also flip the vector of ref.func names to a set. I realized that in a very large program we might see the same name many times.
* Update the type section binary format (#4625)Thomas Lively2022-05-021-0/+36
| | | | | | | | | | Print subtype declarations using the standards-track format with a vector of supertypes followed by a normal type declaration rather than our interim nominal format that used alternative versions of the func, struct, and array forms. Desugar the nominal format to additionally emit all the types into a single large recursion group. Currently V8 is performing this desugaring, but after this change and a future change that fixes the order of nominal types to ensure supertypes precede subtypes, it will no longer need to.
* Lift the restriction in liveness-traversal.h that supported max 65535 locals ↵juj2022-04-285-1/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in a function. (#4567) * Lift the restriction in liveness-traversal.h that supported max 65535 locals in a function. * Lint * Fix typo * Fix static * Lint * Lint * Lint * Add needed canRun function * lint * Use either a sparse or a dense matrix for tracking liveness copies, depending on the locals count. * Lint * Fix lint * Lint * Implement sparse_square_matrix class and use that as a backing. * Lint * Lint * Lint #includes * Lint * Lint includes * Remove unnecessary code * Fix canonical accesses to copies matrix * Lint * Add missing variable update * Remove canRun() function * Address review * Update expected test results * Update test name * Add asserts to sparse_square_matrix set and get functions that they are not out of bound. * Lint includes * Update test expectation * Use .clear() + .resize() to reset totalCopies vector
* RemoveUnusedModuleElements: Track CallRef/RefFunc more precisely (#4621)Alon Zakai2022-04-283-22/+226
| | | | | | | | | | | | | | | | | | If we see (ref.func $foo) that does not mean that $foo is reachable - we must also see a (call_ref ..) of the proper type. Only after seeing both should we mark the function as reachable, which this PR does. This adds some complexity as we need to track intermediate state as we go, since we could see the RefFunc before the CallRef or vice versa. We also need to handle the case of a RefFunc without a CallRef properly: We cannot remove the function, as the RefFunc must refer to it, but at least we can empty out the body since we know it is never reached. This removes an old wasm-opt test which is now superseded by a new lit test. On J2Wasm output this removes 3% of all functions, which account for 2.5% of total code size.
* OptimizeInstructions: Refinalize after a cast removal (#4611)Alon Zakai2022-04-251-3/+55
| | | | | | | | | Casts can replace a type with a subtype, which normally has no downsides, but in a corner case of struct types it can lead to us needing to refinalize higher up too, see details in the comment. We have avoided any Refinalize calls in OptimizeInstructions, but the case handled here requires it sadly. I considered moving it to another pass, but this is a peephole optimization so there isn't really a better place.
* [NominalFuzzing] SignatureRefining: Ignore exported functions (#4601)Alon Zakai2022-04-221-0/+31
| | | This hits the fuzzer when it tries to call reference exports with a null.
* [NominalFuzzing] Fix getHeapTypeCounts() on unreachable casts (#4609)Alon Zakai2022-04-221-0/+24
| | | | | | | | | | | The cast instruction may be unreachable but the intended type for the cast still needs to be collected. Otherwise we end up with problems both during optimizations that look at heap types and in printing (which will use the heap type in code but not declare it). Diff without whitespace is much smaller: this just moves code around so that we can use a template to avoid code duplication. The actual change is just to scan ->intendedType unconditionally, and not ignore it if the cast is unreachable.
* [NominalFuzzing] GTO: trap on null ref in removed struct.set (#4607)Alon Zakai2022-04-211-3/+9
| | | | | | | | | | | | | | When a field has no reads, we remove all its writes, but we did this: (struct.set $foo A B) => (drop A) (drop B) We also need to trap if A, the reference, is null, which this PR fixes, (struct.set $foo A B) => (drop (ref.as_non_null A)) (drop B)
* [NominalFuzzing] MergeSimilarFunctions: handle nominal types properly (#4602)Alon Zakai2022-04-211-0/+323
| | | | | | This fixes two bugs: First, we need to compare the nominal types of function constants when looking for constants to "merge", not just their structure. Second, when creating the new function we must use the proper type of those constants, and not just another type.
* Rename asyncify-side-module to asyncify-relocatable (#4596)かめのこにょこにょこ2022-04-181-1/+1
| | | | | | | Related: emscripten-core/emscripten#15893 (comment) --pass-arg=asyncify-side-module option will be used not only from side modules, but also from main modules.
* Revert "Re-enable a previously flaky type test (#4582)" (#4591)Thomas Lively2022-04-111-1/+1
| | | This reverts commit 40a998c00eb42b65ddc1d42c1c009690bbd05cca.
* Implement relaxed SIMD dot product instructions (#4586)Thomas Lively2022-04-111-0/+112
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/52.
* [Inlining] Preserve return_calls when possible (#4589)Thomas Lively2022-04-111-0/+62
| | | | | | | | | We can preserve return_calls in inlined functions when the inlined call site is itself a return_call, since the call result types must transitively match in that case. This solves a problem where the previous inlining logic could introduce stack exhaustion by downgrading recursive return_calls to normal calls. Fixes #4587.
* [SIMD] Make swizzle's opcode name consistent (NFC) (#4585)Heejin Ahn2022-04-091-1/+1
| | | | Other opcode ends with `Inxm` or `Fnxm` (where n and m are integers), while `i8x16.swizzle`'s opcode name doesn't have an `I` in there.
* Implement i16x8.relaxed_q15mulr_s (#4583)Thomas Lively2022-04-071-0/+26
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/40.
* Re-enable a previously flaky type test (#4582)Thomas Lively2022-04-051-1/+1
| | | | | I don't know what exactly was causing this test to flake, but since it was disabled we added the type fuzzer and fixed a lot of bugs, so I hope it is no longer flaky. If that turns out to be wrong, I can dig deeper.
* Fix MemoryPacking bug (#4579)Thomas Lively2022-04-051-0/+26
| | | | | | | | 247f4c20a1 introduced a bug that caused expressions that refer to data segments to be associated with the wrong segments in the presence of other segments that have no referring expressions at all. Fixes #4569. Fixes #4571.
* [Wasm GC] Fix unreachable local.gets of non-nullable locals in ↵Alon Zakai2022-04-052-1/+26
| | | | | | | | CoalesceLocals (#4574) Normally we just replace unreachable local.gets with a constant (0, or null), but if the local is non-nullable we can't do that. Fixes #4573
* Use LiteralUtils::canMakeZero before calling makeZero (#4568)Alon Zakai2022-04-012-4/+91
| | | | | Fixes #4562 Fixes #4564
* Port memory-packing tests to lit (#4559)Thomas Lively2022-04-016-2146/+2286
|
* [NFC] Refactor Feature::All to match FeatureSet.setAll() (#4557)Alon Zakai2022-03-312-2/+2
| | | | | | | | | | | As we recently noted in #4555, that Feature::All and FeatureSet.setAll() are different is potentially confusing... I think the best thing is to make them identical. This does that, and adds a new Feature::AllPossible which is everything possible and not just the set of all features that are enabled by -all. This undoes part of #4555 as now the old/simpler code works properly.
* [Wasm GC] Fix stacky non-nullable tuples (#4561)Alon Zakai2022-03-312-0/+112
| | | | | #4555 fixed validation for such tuples, but we also did not handle them in "stacky" code using pops etc., due to a logic bug in the binary reading code.
* [MemoryPacking] Remove workaround for old V8 bug (#4558)Thomas Lively2022-03-311-1/+5
| | | | | | | V8 used to incorrectly parse the segment index on bulk memory instructions as a signed LEB rather than an unsigned LEB, which meant it only worked correctly with up to 63 data segments. That bug has been fixed for over two years now, so lift the maximum number of segments generated by memory packing from 63 to the specified max, 100k.
* [Wasm GC] Fix non-nullable tuples (#4555)Alon Zakai2022-03-301-0/+17
| | | | | | Apply the same logic to tuple fields as we do for all other fields, when checking whether a non-nullable value is valid. Fixes #4554
* [Wasm GC] GlobalTypeOptimization: Remove fields from end based on subtypes ↵Alon Zakai2022-03-301-0/+154
| | | | | | | | | | | | | | (#4553) Previously we'd remove a field from a type if that field has no uses in any sub- or super-type. In that case we'd remove it from all the types at once. However, there is a case where we can remove a field only from a parent but not from its children, if the field is at the end: if A has fields {x, y, z} and its subtype B has fields {x, y, z, w}, and A pointers only access field y while B pointers access all the fields, then we can remove z from A. Removing it from the end is safe, and then B will not only add w as it did before but also add z. Note that we cannot remove x, because it is not at the end: removing it from just A but not B would shift the indexes, making them incompatible.
* [Wasm GC] Signature Pruning: Remove params passed constant values (#4551)Alon Zakai2022-03-281-2/+193
| | | | | This basically just adds a call to ParamUtils::applyConstantValues, however, we also need to be careful to not optimize in the presence of imports or exports, so this adds a boolean that indicates unoptimizability.
* Generalize PossibleConstantValues for immutable globals (#4549)Alon Zakai2022-03-283-15/+314
| | | | | | | | | | | | This moves more logic from ConstantFieldPropagation into PossibleConstantValues, that is, instead of handling the two cases of a Literal or a Name before calling PossibleConstantValues, move that code into the helper class. That way all users of PossibleConstantValues can benefit from it. In particular, this makes DeadArgumentElimination now support optimizing immutable globals, as well as ref.func and ref.null. (Changes to test/lit/passes/dae-gc-refine-params.wast are to avoid the new optimizations from kicking in, so that it still tests what it tested before.)
* [Wasm GC] Signature Pruning (#4545)Alon Zakai2022-03-253-0/+603
| | | | | | | | | | | | | This adds a new signature-pruning pass that prunes parameters from signature types where those parameters are never used in any function that has that type. This is similar to DeadArgumentElimination but works on a set of functions, and it can handle indirect calls. Also move a little code from SignatureRefining into a shared place to avoid duplication of logic to update signature types. This pattern happens in j2wasm code, for example if all method functions for some virtual method just return a constant and do not use the this pointer.
* Change `TypeTest` to use isorecursive types (#4540)Thomas Lively2022-03-222-5/+6
| | | | Isorecursive typing is the future standard type system, so change generic type tests to use it.
* [NFC] Move type system test fixture to its own header (#4539)Thomas Lively2022-03-222-31/+41
| | | | Allow the fixture to be shared with other test .cpp files we might add in the future.
* Update filecheck to 0.0.22 (#4537)Thomas Lively2022-03-211-1/+1
| | | | | | | | | | | | This update includes a [fix](https://github.com/mull-project/FileCheck.py/pull/188) to how the filecheck Python package matches whitespace to more closely match the behavior of upstream filecheck in LLVM. We have one test affected by this change, so all users who run the test suite will have to update their installed filecheck. This can be done via ``` pip3 install -r requirements-dev.txt ```
* Fix merge-similar-functions test expections (#4534)Alon Zakai2022-03-211-119/+169
|
* Add support for extended-const proposal (#4529)Sam Clegg2022-03-1916-2/+72
| | | See https://github.com/WebAssembly/extended-const
* [wasm2js] Support exports of Globals (#4523)magic-akari2022-03-173-0/+80
| | | | | | Export an object with a `.value` property like the wasm JS API does in browsers, and implement them with a getter and setter. Fixes #4522
* [memory64] Keep type of memory.size and memory.grow on copy (#4531)Clemens Backes2022-03-171-0/+44
| | | | | | | When copying a MemorySize or MemoryGrow instruction (e.g. for inlining), transfer the memory type also to the copy. Otherwise it will always be i32, even if memory64 should be used. This fixes issue #4530.
* MergeSimilarFunctions optimization pass (#4414)Yuta Saito2022-03-034-0/+543
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge similar functions that only differs constant values (like immediate operand of const and call insts) by parameterization. Performing this pass at post-link time can merge more functions across objects. Inspired by Swift compiler's optimization which is derived from LLVM's one: https://github.com/apple/swift/blob/main/lib/LLVMPasses/LLVMMergeFunctions.cpp https://github.com/llvm/llvm-project/blob/main/llvm/docs/MergeFunctions.rst The basic ideas here are constant value parameterization and direct callee parameterization by indirection. Constant value parameterization is like below: ;; Before (func $big-const-42 (result i32) [[many instr 1]] (i32.const 44) [[many instr 2]] ) (func $big-const-43 (result i32) [[many instr 1]] (i32.const 45) [[many instr 2]] ) ;; After (func $byn$mgfn-shared$big-const-42 (result i32) [[many instr 1]] (local.get $0) ;; parameterized!! [[many instr 2]] ) (func $big-const-42 (result i32) (call $byn$mgfn-shared$big-const-42 (i32.const 42) ) ) (func $big-const-43 (result i32) (call $byn$mgfn-shared$big-const-42 (i32.const 43) ) ) Direct callee parameterization is similar to the constant value parameterization, but it parameterizes callee function i by ref.func instead. Therefore it is enabled only when reference-types and typed-function-references features are enabled. I saw 1 ~ 2 % reduction for SwiftWasm binary and Ruby's wasm port using wasi-sdk, and 3 ~ 4.5% reduction for Unity WebGL binary when -Oz.
* [Wasm GC] Optimize static casts in br_on_cast* (#4520)Alon Zakai2022-02-251-1/+104
| | | | We were missing this particular case, which we can in fact handle when the cast is static.
* Include type names in error messages from building (#4517)Thomas Lively2022-02-181-0/+9
| | | | Instead of just reporting the type index that causes an error when building types, report the name of the responsible type when parsing the text format.
* Clarify in tools help message that -O == -Os. (#4516)t4lz2022-02-162-2/+2
| | | | | Introduce static consts with PassOptions Defaults. Add assertion to verify that the default options are the Os options. Also update the text in relevant tests.
* DeadArgumentElimination: Remove removable effects (#4514)Alon Zakai2022-02-101-0/+34
|
* Make IndexedTypeNameGenerator more powerful (#4511)Thomas Lively2022-02-092-33/+81
| | | | | Allow IndexedTypeNameGenerator to be configured with a custom prefix and also allow it to be parameterized with an explicit fallback generator. This allows multiple IndexedTypeNameGenerators to be composed together, for example.
* [wasm-split] Add an --asyncify option (#4513)Thomas Lively2022-02-092-0/+179
| | | | | | | Add an option for running the asyncify transformation on the primary module emitted by wasm-split. The idea is that the placeholder functions should be able to unwind the stack while the secondary module is asynchronously loaded, then once the placeholder functions have been patched out by the secondary module the stack should be rewound and end up in the correct secondary function.
* Add missing check prefixes after #4509 (#4512)Thomas Lively2022-02-091-2/+2
|
* Print recursion groups in wasm-fuzz-types (#4509)Thomas Lively2022-02-081-22/+24
|