Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class HeapType {
constexpr HeapType with(Exactness exactness) const {
assert((!isBasic() || exactness == Inexact) &&
"abstract types cannot be exact");
return HeapType(exactness == Exact ? (id | ExactMask) : (id & ~ExactMask));
return isBasic() ? *this
: HeapType(exactness == Exact ? (id | ExactMask)
: (id & ~ExactMask));
}

// The ID is the numeric representation of the heap type and can be used in
Expand Down
11 changes: 9 additions & 2 deletions src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ Type Type::getLeastUpperBound(Type a, Type b) {
}
}
return Type::none;
WASM_UNREACHABLE("unexpected type");
}

Type Type::getGreatestLowerBound(Type a, Type b) {
Expand Down Expand Up @@ -1195,6 +1194,9 @@ std::optional<HeapType> HeapType::getLeastUpperBound(HeapType a, HeapType b) {
return getBasicHeapTypeLUB(getBasicHeapSupertype(a),
getBasicHeapSupertype(b));
}
if (a.with(Inexact) == b.with(Inexact)) {
return a.with(Inexact);
}

auto* infoA = getHeapTypeInfo(a);
auto* infoB = getHeapTypeInfo(b);
Expand Down Expand Up @@ -1505,7 +1507,7 @@ bool SubTyper::isSubType(HeapType a, HeapType b) {
// See:
// https://github.com/WebAssembly/function-references/blob/master/proposals/function-references/Overview.md#subtyping
// https://github.com/WebAssembly/gc/blob/master/proposals/gc/MVP.md#defined-types
if (a == b) {
if (a == b || a.with(Inexact) == b) {
return true;
}
if (a.isShared() != b.isShared()) {
Expand Down Expand Up @@ -1550,6 +1552,11 @@ bool SubTyper::isSubType(HeapType a, HeapType b) {
// bottom types.
return a == b.getBottom();
}
if (b.isExact()) {
// The only subtypes of an exact type are itself and bottom, both of which
// we have ruled out.
return false;
}
// Subtyping must be declared rather than derived from structure, so we will
// not recurse. TODO: optimize this search with some form of caching.
HeapTypeInfo* curr = getHeapTypeInfo(a);
Expand Down
Loading