@@ -105,8 +105,8 @@ struct HeapTypeInfo {
105
105
// Otherwise, the type definition tree is still being constructed via the
106
106
// TypeBuilder interface, so hashing and equality use pointer identity.
107
107
bool isFinalized = true ;
108
- bool isNominal = false ;
109
- // In nominal mode, the supertype of this HeapType, if it exists.
108
+ // In nominal or isorecursive mode, the supertype of this HeapType, if it
109
+ // exists.
110
110
HeapTypeInfo* supertype = nullptr ;
111
111
enum Kind {
112
112
BasicKind,
@@ -581,7 +581,6 @@ bool TypeInfo::operator==(const TypeInfo& other) const {
581
581
HeapTypeInfo::HeapTypeInfo (const HeapTypeInfo& other) {
582
582
kind = other.kind ;
583
583
supertype = other.supertype ;
584
- isNominal = other.isNominal ;
585
584
switch (kind) {
586
585
case BasicKind:
587
586
new (&basic) auto (other.basic );
@@ -690,7 +689,7 @@ template<typename Info> struct Store {
690
689
std::lock_guard<std::recursive_mutex> lock (mutex);
691
690
// Nominal HeapTypes are always unique, so don't bother deduplicating them.
692
691
if constexpr (std::is_same_v<Info, HeapTypeInfo>) {
693
- if (info. isNominal || typeSystem == TypeSystem::Nominal) {
692
+ if (typeSystem == TypeSystem::Nominal) {
694
693
return insertNew ();
695
694
}
696
695
}
@@ -1215,14 +1214,6 @@ size_t HeapType::getDepth() const {
1215
1214
return depth;
1216
1215
}
1217
1216
1218
- bool HeapType::isNominal () const {
1219
- if (isBasic ()) {
1220
- return false ;
1221
- } else {
1222
- return getHeapTypeInfo (*this )->isNominal ;
1223
- }
1224
- }
1225
-
1226
1217
bool HeapType::isSubType (HeapType left, HeapType right) {
1227
1218
// As an optimization, in the common case do not even construct a SubTyper.
1228
1219
if (left == right) {
@@ -1342,11 +1333,7 @@ bool SubTyper::isSubType(HeapType a, HeapType b) {
1342
1333
// Basic HeapTypes are never subtypes of compound HeapTypes.
1343
1334
return false ;
1344
1335
}
1345
- // Nominal and structural types are never subtypes of each other.
1346
- if (a.isNominal () != b.isNominal ()) {
1347
- return false ;
1348
- }
1349
- if (a.isNominal () || typeSystem == TypeSystem::Nominal) {
1336
+ if (typeSystem == TypeSystem::Nominal) {
1350
1337
// Subtyping must be declared in a nominal system, not derived from
1351
1338
// structure, so we will not recurse. TODO: optimize this search with some
1352
1339
// form of caching.
@@ -1525,9 +1512,6 @@ HeapType TypeBounder::lub(HeapType a, HeapType b) {
1525
1512
if (a.isBasic () || b.isBasic ()) {
1526
1513
return getBasicLUB ();
1527
1514
}
1528
- if (a.isNominal () != b.isNominal ()) {
1529
- return getBasicLUB ();
1530
- }
1531
1515
1532
1516
HeapTypeInfo* infoA = getHeapTypeInfo (a);
1533
1517
HeapTypeInfo* infoB = getHeapTypeInfo (b);
@@ -1536,7 +1520,7 @@ HeapType TypeBounder::lub(HeapType a, HeapType b) {
1536
1520
return getBasicLUB ();
1537
1521
}
1538
1522
1539
- if (a. isNominal () || typeSystem == TypeSystem::Nominal) {
1523
+ if (typeSystem == TypeSystem::Nominal) {
1540
1524
// Walk up the subtype tree to find the LUB. Ascend the tree from both `a`
1541
1525
// and `b` in lockstep. The first type we see for a second time must be the
1542
1526
// LUB because there are no cycles and the only way to encounter a type
@@ -1971,15 +1955,13 @@ size_t FiniteShapeHasher::hash(const TypeInfo& info) {
1971
1955
}
1972
1956
1973
1957
size_t FiniteShapeHasher::hash (const HeapTypeInfo& info) {
1974
- size_t digest = wasm::hash (info.isNominal );
1975
- if (info.isNominal || getTypeSystem () == TypeSystem::Nominal) {
1976
- rehash (digest, uintptr_t (&info));
1977
- return digest;
1958
+ if (getTypeSystem () == TypeSystem::Nominal) {
1959
+ return wasm::hash (uintptr_t (&info));
1978
1960
}
1979
1961
// If the HeapTypeInfo is not finalized, then it is mutable and its shape
1980
1962
// might change in the future. In that case, fall back to pointer identity to
1981
1963
// keep the hash consistent until all the TypeBuilder's types are finalized.
1982
- digest = wasm::hash (info.isFinalized );
1964
+ size_t digest = wasm::hash (info.isFinalized );
1983
1965
if (!info.isFinalized ) {
1984
1966
rehash (digest, uintptr_t (&info));
1985
1967
return digest;
@@ -2094,9 +2076,7 @@ bool FiniteShapeEquator::eq(const TypeInfo& a, const TypeInfo& b) {
2094
2076
}
2095
2077
2096
2078
bool FiniteShapeEquator::eq (const HeapTypeInfo& a, const HeapTypeInfo& b) {
2097
- if (a.isNominal != b.isNominal ) {
2098
- return false ;
2099
- } else if (a.isNominal || getTypeSystem () == TypeSystem::Nominal) {
2079
+ if (getTypeSystem () == TypeSystem::Nominal) {
2100
2080
return &a == &b;
2101
2081
}
2102
2082
if (a.isFinalized != b.isFinalized ) {
@@ -2264,7 +2244,6 @@ struct TypeBuilder::Impl {
2264
2244
}
2265
2245
void set (HeapTypeInfo&& hti) {
2266
2246
hti.supertype = info->supertype ;
2267
- hti.isNominal = info->isNominal ;
2268
2247
*info = std::move (hti);
2269
2248
info->isTemp = true ;
2270
2249
info->isFinalized = false ;
@@ -2359,11 +2338,6 @@ void TypeBuilder::setSubType(size_t i, size_t j) {
2359
2338
sub->supertype = super;
2360
2339
}
2361
2340
2362
- void TypeBuilder::setNominal (size_t i) {
2363
- assert (i < size () && " index out of bounds" );
2364
- impl->entries [i].info ->isNominal = true ;
2365
- }
2366
-
2367
2341
namespace {
2368
2342
2369
2343
// Helper for TypeBuilder::build() that keeps track of temporary types and
@@ -3036,9 +3010,7 @@ void globallyCanonicalize(CanonicalizationState& state) {
3036
3010
void canonicalizeEquirecursive (CanonicalizationState& state) {
3037
3011
// Equirecursive types always have null supertypes.
3038
3012
for (auto & info : state.newInfos ) {
3039
- if (!info->isNominal ) {
3040
- info->supertype = nullptr ;
3041
- }
3013
+ info->supertype = nullptr ;
3042
3014
}
3043
3015
3044
3016
#if TIME_CANONICALIZATION
@@ -3219,8 +3191,7 @@ std::vector<HeapType> TypeBuilder::build() {
3219
3191
3220
3192
// Note built signature types. See comment in `HeapType::HeapType(Signature)`.
3221
3193
for (auto type : state.results ) {
3222
- if (type.isSignature () &&
3223
- (type.isNominal () || getTypeSystem () == TypeSystem::Nominal)) {
3194
+ if (type.isSignature () && (getTypeSystem () == TypeSystem::Nominal)) {
3224
3195
nominalSignatureCache.insertType (type);
3225
3196
}
3226
3197
}
0 commit comments