Skip to content

Commit e3798b4

Browse files
authored
[NFC] Simplify abstract heap type LUB (#7749)
There was some complexity left over from when we modeled `string` as being a subtype of `any` but not of `eq`.
1 parent 4844d90 commit e3798b4

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

src/wasm/wasm-type.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,9 @@ std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a,
403403
if (unsigned(a) > unsigned(b)) {
404404
std::swap(a, b);
405405
}
406-
auto bUnshared = HeapType(b).getBasic(Unshared);
407406
HeapType lubUnshared;
408407
switch (HeapType(a).getBasic(Unshared)) {
409408
case HeapType::ext:
410-
assert(bUnshared == HeapType::string);
411409
lubUnshared = HeapType::ext;
412410
break;
413411
case HeapType::func:
@@ -418,36 +416,16 @@ std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a,
418416
lubUnshared = HeapType::any;
419417
break;
420418
case HeapType::eq:
421-
if (bUnshared == HeapType::i31 || bUnshared == HeapType::struct_ ||
422-
bUnshared == HeapType::array) {
423-
lubUnshared = HeapType::eq;
424-
} else {
425-
lubUnshared = HeapType::any;
426-
}
427-
break;
428419
case HeapType::i31:
429-
if (bUnshared == HeapType::struct_ || bUnshared == HeapType::array) {
430-
lubUnshared = HeapType::eq;
431-
} else {
432-
lubUnshared = HeapType::any;
433-
}
434-
break;
435420
case HeapType::struct_:
436-
if (bUnshared == HeapType::array) {
437-
lubUnshared = HeapType::eq;
438-
} else {
439-
lubUnshared = HeapType::any;
440-
}
421+
lubUnshared = HeapType::eq;
441422
break;
442423
case HeapType::array:
443-
lubUnshared = HeapType::any;
444-
break;
445424
case HeapType::string:
446-
// String has already been handled: we sorted before in a way that ensures
447-
// the type the string is compared to is of a higher index, which means it
448-
// is a bottom type (string is the last type that is not a bottom type),
449-
// but we have handled the case of either a or b being a bottom type
450-
// earlier already.
425+
// As the last non-bottom types in their hierarchies, it should not be
426+
// possible for `a` to be array or string. We know that `b` != `a` and
427+
// that `b` is not bottom, but that `b` and `a` are in the same hierarchy,
428+
// so there are no possible value for `b`.
451429
case HeapType::none:
452430
case HeapType::noext:
453431
case HeapType::nofunc:

0 commit comments

Comments
 (0)