diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2022-08-17 22:51:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 22:51:27 -0700 |
commit | 2d86d1f8fb217456d8bcc4b401ce7d143aa36ee9 (patch) | |
tree | ec852da20ed85c7e5f9be7a5e3fb0632d7caf949 /src/ir | |
parent | 3aff4c6e85623c970280219c6699a66bc9de5f9b (diff) | |
download | binaryen-2d86d1f8fb217456d8bcc4b401ce7d143aa36ee9.tar.gz binaryen-2d86d1f8fb217456d8bcc4b401ce7d143aa36ee9.tar.bz2 binaryen-2d86d1f8fb217456d8bcc4b401ce7d143aa36ee9.zip |
Restore the `extern` heap type (#4898)
The GC proposal has split `any` and `extern` back into two separate types, so
reintroduce `HeapType::ext` to represent `extern`. Before it was originally
removed in #4633, externref was a subtype of anyref, but now it is not. Now that
we have separate heaptype type hierarchies, make `HeapType::getLeastUpperBound`
fallible as well.
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/possible-constant.h | 10 | ||||
-rw-r--r-- | src/ir/possible-contents.cpp | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/ir/possible-constant.h b/src/ir/possible-constant.h index b3272461d..21f1cfa65 100644 --- a/src/ir/possible-constant.h +++ b/src/ir/possible-constant.h @@ -114,8 +114,14 @@ public: auto type = getConstantLiteral().type.getHeapType(); auto otherType = other.getConstantLiteral().type.getHeapType(); auto lub = HeapType::getLeastUpperBound(type, otherType); - if (lub != type) { - value = Literal::makeNull(lub); + if (!lub) { + // TODO: Remove this workaround once we have bottom types to assign to + // null literals. + value = Many(); + return true; + } + if (*lub != type) { + value = Literal::makeNull(*lub); return true; } return false; diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 7079a9446..d9c608bda 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -56,7 +56,13 @@ void PossibleContents::combine(const PossibleContents& other) { assert(other.isNull()); auto lub = HeapType::getLeastUpperBound(type.getHeapType(), otherType.getHeapType()); - value = Literal::makeNull(lub); + if (!lub) { + // TODO: Remove this workaround once we have bottom types to assign to + // null literals. + value = Many(); + return; + } + value = Literal::makeNull(*lub); } return; } |