summaryrefslogtreecommitdiff
path: root/src/ir/module-utils.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-01-28 16:53:12 -0800
committerGitHub <noreply@github.com>2022-01-29 00:53:12 +0000
commit019df9d734b463ad4d194f4241c5e4f077e07def (patch)
tree120702f8f2742eb3548205b179fe30be886ba390 /src/ir/module-utils.cpp
parentf2d53918155cfe6e7fc333be22f25ae3776b1438 (diff)
downloadbinaryen-019df9d734b463ad4d194f4241c5e4f077e07def.tar.gz
binaryen-019df9d734b463ad4d194f4241c5e4f077e07def.tar.bz2
binaryen-019df9d734b463ad4d194f4241c5e4f077e07def.zip
Isorecursive canonicalization (#4481)
Isorecursive canonicalization is similar to equirecursive canonicalization in that it deduplicates types based on their structure, but unlike equirecursive canonicalization, isorecursive canonicalization does not need to minimize the type definition first. Another difference is that structures are deduplicated at the level of recursion groups rather than individual types, so we cannot reuse the existing `FiniteShapeHasher` and `FiniteShapeEquator` utilities. Instead, introduce a new `RecGroupStructure` wrapper that provides equality comparison and hashing very similar to the former utilities. Another feature of the isorecursive type system is that its constraints on the order of recursion groups means that they are already topologically sorted and can be incrementally canonicalized in a bottom-up manner. This incremental canonicalization means that the `RecGroupStructure` utility can assume that all child `HeapTypes` have already been canonicalized and can avoid traversing anything but the top-level type definitions in the wrapped recursion group. The only exception is self-references into the wrapped recursion group itself, which may not be canonical. That special case is detected and handled without any nontrivial extra work. Overall, the canonicalization algorithm traverses each type definition once to canonicalize its `HeapType` use sites, then once to hash its recursion group structure, then finally once to canonicalize its `Type` use sites in `globallyCanonicalize`, giving only linear time complexity.
Diffstat (limited to 'src/ir/module-utils.cpp')
0 files changed, 0 insertions, 0 deletions