summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Minor simplifications in wasm-type.cpp (#5680)Thomas Lively2023-04-201-43/+12
| | | | | | | | | | | This capability was originally introduced to support calculating LUBs in the equirecursive type system, but has not been needed for anything except tests since the equirecursive type system was removed. Since building basic heap types is no longer useful and was a source of significant complexity, remove the APIs that allowed it and the tests that used those APIs. Also remove test/example/type-builder.cpp, since a significant portion of it tested the removed APIs and the rest is already better tested in test/gtest/type-builder.cpp.
* Remove the ability to construct basic types in a TypeBuilder (#5678)Thomas Lively2023-04-196-274/+35
| | | | | | | | | | | This capability was originally introduced to support calculating LUBs in the equirecursive type system, but has not been needed for anything except tests since the equirecursive type system was removed. Since building basic heap types is no longer useful and was a source of significant complexity, remove the APIs that allowed it and the tests that used those APIs. Also remove test/example/type-builder.cpp, since a significant portion of it tested the removed APIs and the rest is already better tested in test/gtest/type-builder.cpp.
* Disable the memory64 feature in Memory64Lowering.cpp (#5679)Thomas Lively2023-04-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Disable sign extension in SignExtLowering.cpp The sign extension lowering pass would previously lower away the sign extension instructions, but it wouldn't disable the sign extension feature, so follow-on passes such as optimize-instructions could reintroduce sign extension instructions. Fix the pass to disable the sign extension feature to prevent sign extension instructions from being reintroduced later. * update pass description * Disable the memory64 feature in Memory64Lowering.cpp For consistency with other feature lowering passes, disable memory64 in addition to lowering its use away. Although no other passes would introduce new uses of memory64 at the moment, this makes the lowering pass more robust against a future where memory64 might accidentally be reintroduced after being lowered away. * Update test/lit/passes/memory64-lowering-features.wast Co-authored-by: Alon Zakai <azakai@google.com> --------- Co-authored-by: Alon Zakai <azakai@google.com>
* Disable sign extension in SignExtLowering.cpp (#5676)Thomas Lively2023-04-192-1/+10
| | | | | | | | | | | | | * Disable sign extension in SignExtLowering.cpp The sign extension lowering pass would previously lower away the sign extension instructions, but it wouldn't disable the sign extension feature, so follow-on passes such as optimize-instructions could reintroduce sign extension instructions. Fix the pass to disable the sign extension feature to prevent sign extension instructions from being reintroduced later. * update pass description
* Fuzzer: Use subtype consistently in make() (#5674)Alon Zakai2023-04-191-4/+4
|
* [Wasm GC] Fix GUFA on array.init of a bottom type (#5675)Alon Zakai2023-04-191-2/+6
|
* [Wasm GC] Fuzz array.copy and array.fill (#5663)Alon Zakai2023-04-172-4/+88
|
* [Wasm GC] OptimizeInstructions: Don't turn ref.test into unreachable ↵Alon Zakai2023-04-171-2/+6
| | | | | | | | | | | | immediately (#5673) Emit an unreachable, but guarded by a block as we do in other cases in this pass, to avoid having unreachable code that is not fully propagated during the pass (as we only do a full refinalize at the end). See existing comments starting with "Make sure to emit a block with the same type as us" in the pass. This is mostly not a problem with other casts, but ref.test returns an i32 which we have lots of code that tries to optimize.
* Remove the nominal type system (#5672)Thomas Lively2023-04-179-290/+65
| | | | | And since the only type system left is the standard isorecursive type system, remove `TypeSystem` and its associated APIs entirely. Delete a few tests that only made sense under the isorecursive type system.
* [Wasm GC] Fix SignatureRefining on a call_ref to a bottom type (#5670)Alon Zakai2023-04-171-3/+10
| | | | | | | Before this PR we hit the assert on the type not being basic. We could also look into fixing the caller to skip bottom types, but as bottom types trivially have no subtypes, it is more future-facing to simply handle it.
* [Wasm GC] Improve GC operation coverage by using locals more (#5661)Alon Zakai2023-04-172-19/+60
| | | | | | | | | | | | When we emit e.g. a struct.get's reference, this PR makes us prefer a non-nullable value, and even to reuse an existing local if possible. By doing that we reduce the risk of a trap, and also by using locals we end up testing operations on the same data, like this: x = new A(); x.a = .. foo(x.a) In contrast, without this PR each of those x. uses might be new A().
* Remove the --hybrid and --nominal command line options (#5669)Thomas Lively2023-04-144-47/+2
| | | | | 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.
* wasm-reduce: Add more passes (#5667)Alon Zakai2023-04-141-0/+6
|
* [Wasm GC] Casts of a non-nullable bottom type to non-null fail (#5645)Alon Zakai2023-04-124-37/+88
| | | | | | | | | | | Casting (ref nofunc) to (ref func) seems like it can succeed based on the rule of "if it's a subtype, it can cast ok." But the fuzzer found a corner case where that leads to a validation error (see testcase). Refactor the cast evaluation logic to handle uninhabitable refs directly, and return Unreachable for them (since the cast cannot even be reached). Also reorder the rule checks there to always check for a non-nullable cast of a bottom type (which always fails).
* [NFC] Refactor some old fuzzer code (#5658)Alon Zakai2023-04-121-13/+8
| | | | A return value was unused, and we have BranchUtils::operateOnScopeNameDefs now which can replace old manual code.
* [NFC] Refactor fuzzer array check logic (#5659)Alon Zakai2023-04-121-20/+30
|
* Fuzzer: When nested under makeTrivial(), avoid normal make() (#5657)Alon Zakai2023-04-122-0/+16
| | | | | | | | Without this, in certain complex operations we could end up calling a nested make() operation that included nontrivial things, which could cause problems. The specific problem I encountered was in fixAfterChanges() we tried to fix up a duplicate label, but calling makeTrivial() emitted something very large that happened to include a new block with a new label nested under a struct.get, and that block's label conflicted with a label we'd already processed.
* [Wasm GC] Fuzz struct.set and array.set (#5655)Alon Zakai2023-04-122-1/+73
|
* Add a name hint to getValidName() (#5653)Alon Zakai2023-04-111-19/+45
| | | | | | | Without the hint, we always look for a valid name using name$0, $1, $2, etc., starting from 0, and in some cases that can lead to quadratic behavior. Noticed on a testcase in the fuzzer that runs for over 24 seconds (I gave up at that point) but takes only 2 seconds with this.
* [Wasm GC] Fuzz struct.get and array.get (#5651)Alon Zakai2023-04-104-4/+76
|
* [GUFA] Fix packed field filtering (#5652)Alon Zakai2023-04-101-6/+41
| | | | | | | | | | | | | | | | | | | | | | Technically we need to filter both before and after combining, that is, if a location's contents will be filtered by F() then if the new contents are x and old contents y then we need to end up with F(F(x) U F(y)). That is, filtering before is necessary to ensure the union of content does not end up unnecessarily large, and the filtering after is necessary to ensure the final result is properly filtered to fit. (If our representation were perfect then this would not be needed, but it is not, as the union of two exact types can end up as a very large cone, for example.) For efficiency we have been filtering afterwards. But that is not enough for packed fields, it turns out, where we must filter before. If we don't, then if inputs 0 and 0x100 arrive to an i8 field then combining them we get "unknown integer" (which is then filtered by 0xff, but it's too late). By filtering before, the actual values are both 0 and we end up with that as the only possible value. It turns out that filtering before is enough for such fields, so do only that.
* Do not flatten memory when array.new_data is present (#5650)Alon Zakai2023-04-101-12/+25
| | | Like data.drop etc., it notices data segment identity.
* binaryen.js: Use malloc/free instead of stackAlloc in setMemory (#5646)Mathias Nater2023-04-101-2/+6
| | | | | Memory data segments can be of large size, and might not fit in the stack. fixes #5595
* [Wasm GC] Update struct.get types in TypeRefining (#5649)Alon Zakai2023-04-101-1/+27
| | | | | We depended on ReFinalize doing it for us, and that usually works, but there is a corner case that depends on knowing all the type changes being done. So use our complete information to update those types in the pass.
* Fix MemoryPacking handling of array.init_data (#5644)Thomas Lively2023-04-071-5/+7
| | | | | | | | Do not optimize out or split segments that are referred to array.init_data instructions. Fixes a bug where segments could get optimized out, producing invalid modules. Doing the work to actually split segments used by array.init_data is left for the future. Also fix a latent UBSan failure revealed by the new test case.
* [NFC] Use the new getField() in the heap type fuzzer (#5643)Alon Zakai2023-04-071-17/+10
|
* Fix and simplify refinalization in OptimizeInstructions (#5642)Alon Zakai2023-04-071-23/+7
| | | | | The fuzzer found another case we were missing. I realized that we can just check for this in replaceCurrent, at least for places that call that method, which is the common case. So this simplifies the code while fixing a bug.
* [Wasm GC] Handle packed fields in GUFA and CFP (#5640)Alon Zakai2023-04-072-0/+42
| | | | | The same bug was present in both: We ignored packing, so writing a larger value than fits in the field would lead to us propagating that original value.
* [GUFA] Refine global types during flow (#5639)Alon Zakai2023-04-072-12/+32
| | | | | | | | | | | | Previously (ref.as_non_null (global.get ..)) would return the global with no changes, and if the global was nullable then the type didn't match the output, which hit an assertion (where GUFA checks that the contents match the declared type in the wasm). To fix this, refine global types, that is, the type we track on GlobalInfo may be more refined than the global itself. In the above example, if the global is nullable then the GlobalInfo would point to that global but have a non-nullable type. In fact the code was already prepared for this, and few changes were needed.
* [Wasm GC] Fix an assertion in array.set processing in OptimizeInstructions ↵Alon Zakai2023-04-072-3/+26
| | | | (#5641)
* [Wasm GC] Fix GUFA on ArrayInit (#5638)Alon Zakai2023-04-071-3/+14
|
* Implement array.fill, array.init_data, and array.init_elem (#5637)Thomas Lively2023-04-0622-31/+629
| | | | | 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.
* [Wasm GC] OptimizeInstructions: ref.as_non_null of null will trap (#5635)Alon Zakai2023-04-061-0/+3
| | | | | | | Trivial peephole optimization. Some work was needed in the tests as some of them relied on that pattern for convenience, so I modified them to try to keep them testing the same thing as much as possible (for one, struct.set.null.fallthrough, I don't think we can actually keep testing the same, as the situation should not be possible any more).
* [Wasm GC] Handle another unreachability case in trapOnNull() (#5634)Alon Zakai2023-04-051-1/+2
| | | This is the flip case of #5630
* Fuzzer: Improve mutate() (#5631)Alon Zakai2023-04-051-9/+33
| | | Don't use a fixed 10% chance to mutate, but pick a mutation rate in each function.
* RemoveUnusedModuleElements: Add SIMD support for memory operations (#5632)Alon Zakai2023-04-051-0/+6
| | | | Fixes #5629
* Avoid imported memories in the fuzzer (#5626)Alon Zakai2023-04-051-12/+15
| | | | | | | We already did this for the first memory, and just needed to loop to handle initial content in the test suite that has multiple memories. Also clean up that code while I'm around, to avoid repeating wasm.memories[0] all the time.
* Wasm GC] Handle unreachability in a select child in trapOnNull() (#5630)Alon Zakai2023-04-051-1/+6
|
* Only update functions in optimizeAfterInlining() (#5624)Alon Zakai2023-04-053-6/+11
| | | | | This saves the work of freeing and allocating for all the other maps. This is a code path that is used by several passes so it showed up in profiling for #5561
* Fix a crash in MemoryPacking due to an unreachable pointer (#5623)Thomas Lively2023-04-051-1/+1
| | | | | | | | Previously, the pointer type for newly emitted instructions was determined by the type of the destination pointer on a memory.init instruction, but that did not take into account that the destination pointer may be unreachable. Properly look up the pointer type on the memory instead to fix the problem. Fixes #5620.
* [Wasm GC] Fuzz struct.new and array.new (#5622)Alon Zakai2023-04-042-29/+48
| | | | | | | | | Repurpose makeBasicRef, makeCompoundRef to generate not just "constant" refs but any reference, and use those to create StructNew/ArrayNew. The key changes are to add makeCompoundRef to make(), and to make the function call make() for children, where possible, instead of just makeTrivial(). We also replace the i31-specific path with a call to makeBasicRef which handles i31 among other things.
* Support multiple memories in RemoveUnusedModuleElements (#5604)Thomas Lively2023-04-042-107/+131
| | | | | | | | Add support for memory and data segment module elements and treat them uniformly with other module elements rather than as special cases. There is a cyclic dependency between memories (or tables) and their active segments because exported or accessed memories (or tables) keep their active segments alive, but active segments for imported memories (or tables) keep their memories (or tables) alive as well.
* [Wasm GC] Fix CoalesceLocals ineffective tee removal with type changes (#5621)Alon Zakai2023-04-041-1/+10
| | | When we remove a tee there, we must not change the type at all.
* Use Names instead of indices to identify segments (#5618)Thomas Lively2023-04-0423-182/+272
| | | | | | | | | | All top-level Module elements are identified and referred to by Name, but for historical reasons element and data segments were referred to by index instead. Fix this inconsistency by using Names to refer to segments from expressions that use them. Also parse and print segment names like we do for other elements. The C API is partially converted to use names instead of indices, but there are still many functions that refer to data segments by index. Finishing the conversion can be done in the future once it becomes necessary.
* [Wasm GC] Fix CoalesceLocals i31 local.get removal (#5619)Alon Zakai2023-04-041-1/+6
| | | | When removing a local.get we must replace it with something of the identical type, and not make it non-nullable.
* [Wasm GC] Fuzz RefCast (#5617)Alon Zakai2023-04-032-7/+86
|
* [Wasm GC] Avoid refining in TypeUpdating unreachability propagation (#5616)Alon Zakai2023-04-031-1/+17
| | | | | That code should only propagate unreachability, and not refine. If it refines when we call finalize() then other code around it might end up invalid (as it could be partially refined; see testcase).
* [Wasm GC] Parse (sub $super _) for array, func, and struct (#5515)Andy Wingo2023-04-031-23/+55
| | | | The pretty-printer will still serialize these using the old func_subtype, array_subtype, and struct_subtype syntax, though.
* Fix a call to make_unique without std (#5615)Alon Zakai2023-04-031-1/+1
| | | Followup to #5613
* [Wasm GC] Stop emitted deprecated cast etc. instructions (#5614)Alon Zakai2023-03-311-46/+0
| | | | | | | | | This is necessary to start fuzzing RefCast etc., as otherwise the fuzzer errors on V8 which has already removed support for the deprecated ones apparently. Do not remove read support for them yet, as perhaps some users still need that.