summaryrefslogtreecommitdiff
path: root/src/passes/SignatureRefining.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make `GlobalTypeRewriter` work for isorecursive types (#4829)Thomas Lively2022-07-261-2/+3
| | | | | | | | | | | | | | | | | | | There are two new potential problems that `GlobalTypeRewriter` can run into when working with isorecursive types instead of nominal types. First, the refined types may have replaced generic references with references to specific other types, potentially creating new recursions and making the existing recursion groups insufficient. Second, distinct types may be refined to structurally identical types and those distinct input types may map the same output type, potentially changing cast behavior. Both of these problems are solved by putting all the new types in a single large recursion group. We do not currently account for the fact that types may be used in the external interface of the module, but when we do, externalized types will be excluded from optimizations and will not be affected by the creation of this single large rec group. Fixes #4816.
* Disallow --nominal with GC (#4758)Thomas Lively2022-06-281-0/+3
| | | | | | | | | | | Nominal types don't make much sense without GC, and in particular trying to emit them with typed function references but not GC enabled can result in invalid binaries because nominal types do not respect the type ordering constraints required by the typed function references proposal. Making this change was mostly straightforward, but required fixing the fuzzer to use --nominal only when GC is enabled and required exiting early from nominal-only optimizations when GC was not enabled. Fixes #4756.
* SignatureRefining: Do not refine types of imported functions (#4727)Alon Zakai2022-06-141-0/+9
| | | | Spec and VM support for that is not yet stable (atm VMs do not allow complex user- defined types to be passed around).
* [Nominal Fuzzing] Fix SignatureRefining by updating types fully at once (#4665)Alon Zakai2022-05-231-1/+9
| | | | | | | | | | Optionally avoid updating types in TypeUpdating::updateParamTypes(). That update is incomplete if the function signature is also changing, which is the case in SignatureRefining (but not DeadArgumentElimination). "Incomplete" means that we updated the local.get type, but the function signature does not match yet. That incomplete state can hit an internal error in GlobalTypeRewriter::updateSignatures where it updates types. To avoid that, do the entire full update only there (in GlobalTypeRewriter::updateSignatures).
* [NominalFuzzing] SignatureRefining can modify the IR while running a ↵Alon Zakai2022-04-281-1/+3
| | | | | | | | | parallel analysis (#4620) Normally ParallelFunctionAnalysis is just an analysis, and has no effects. However, in SignatureRefining we actually do have side effects, due to an internal limitation of the helper code it runs. This adds a template parameter to the class so users can note that they do modify the IR. The parameter is added in the middle as it is easier to add this param than to add the last one (the map).
* [NominalFuzzing] SignatureRefining: Ignore exported functions (#4601)Alon Zakai2022-04-221-1/+24
| | | This hits the fuzzer when it tries to call reference exports with a null.
* [Wasm GC] Signature Pruning (#4545)Alon Zakai2022-03-251-19/+1
| | | | | | | | | | | | | 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.
* [Wasm GC] Refine results in SignatureRefining (#4380)Alon Zakai2021-12-141-17/+70
| | | | | | Similar to what DeadArgumentElimination does for individual functions, this can refine the results of a set of functions all using the same heap type, when they all return something more specific. After this PR SignatureRefining can refine both params and results and is basically complete.
* [Wasm GC] Signature Refining pass (#4326)Alon Zakai2021-11-191-0/+207
This is fairly short and simple after the recent refactorings. This basically just finds all uses of each signature/function type, and then sees if it receives more specific types as params. It then rewrites the types if so. This just handles arguments so far, and not return types. This differs from DeadArgumentElimination's refineArguments() in that that pass modifies each function by itself, changing the type of the function as needed. That is only valid if the type is not observable, that is, if the function is called indirectly then DAE ignores it. This pass will work on the types themselves, so it considers all functions sharing a type as a whole, and when it upgrades that type it ends up affecting them all. This finds optimization opportunities on 4% of the total signature types in j2wasm. Those lead to some benefits in later opts, but the effect is not huge.