diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-02-25 16:21:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-25 16:21:35 -0800 |
commit | b89b601a36e9cfe17dc1f09c641266ac2a715299 (patch) | |
tree | 950ff11ff513bef4bf87678043461cb572d9564a /test/binaryen.js/expressions.js | |
parent | 142d5f32ce792327de62b62f09f25528dcd86950 (diff) | |
download | binaryen-b89b601a36e9cfe17dc1f09c641266ac2a715299.tar.gz binaryen-b89b601a36e9cfe17dc1f09c641266ac2a715299.tar.bz2 binaryen-b89b601a36e9cfe17dc1f09c641266ac2a715299.zip |
Support comparing, subtyping, and naming recursive types (#3610)
When the type section is emitted, types with an equal amount of references are
ordered by an arbitrary measure of simplicity, which previously would infinitely
recurse on structurally equivalent recursive types. Similarly, calculating
whether an recursive type was a subtype of another recursive type could have
infinitely recursed. This PR avoids infinite recursions in both cases by
switching the algorithms from using normal inductive recursion to using
coinductive recursion. The difference is that while the inductive algorithms
assume the relations do not hold for a pair of HeapTypes until they have been
exhaustively shown to hold, the coinductive algorithms assume the relations hold
unless a counterexample can be found.
In addition to those two algorithms, this PR also implement name generation for
recursive types, using de Bruijn indices to stand in for inner uses of the
recursive types.
There are additional algorithms that will need to be switched from inductive to
coinductive recursion, such as least upper bound generation, but these presented
a good starting point and are sufficient to get some interesting programs
working end-to-end.
Diffstat (limited to 'test/binaryen.js/expressions.js')
0 files changed, 0 insertions, 0 deletions