Skip to content

Commit acd3ed3

Browse files
authored
[NFC] Simplify interpretation of casts (#7549)
The interpreter previously inspected subtyping for nullability and heap types separately when executing casts. Simplify this to just check subtyping on the combined type. This is NFC for now, but will have the happy side effect of handling exactness correctly once we type allocations as exact and interpret exact casts.
1 parent 456e573 commit acd3ed3

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/wasm-interpreter.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,14 +1642,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
16421642
}
16431643
Literal val = ref.getSingleValue();
16441644
Type castType = curr->getCastType();
1645-
if (val.isNull()) {
1646-
if (castType.isNullable()) {
1647-
return typename Cast::Success{val};
1648-
} else {
1649-
return typename Cast::Failure{val};
1650-
}
1651-
}
1652-
if (HeapType::isSubType(val.type.getHeapType(), castType.getHeapType())) {
1645+
if (Type::isSubType(val.type, castType)) {
16531646
return typename Cast::Success{val};
16541647
} else {
16551648
return typename Cast::Failure{val};

0 commit comments

Comments
 (0)