diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 4 | ||||
-rw-r--r-- | src/binaryen-c.h | 4 | ||||
-rw-r--r-- | src/ir/type-updating.cpp | 3 | ||||
-rw-r--r-- | src/wasm-type.h | 8 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 11 |
5 files changed, 15 insertions, 15 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 7b06bf584..cc7ed5b15 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -6266,8 +6266,8 @@ BinaryenType TypeBuilderGetTempRefType(TypeBuilderRef builder, } void TypeBuilderSetSubType(TypeBuilderRef builder, BinaryenIndex index, - BinaryenIndex superIndex) { - ((TypeBuilder*)builder)->setSubType(index, superIndex); + BinaryenHeapType superType) { + ((TypeBuilder*)builder)->setSubType(index, HeapType(superType)); } void TypeBuilderCreateRecGroup(TypeBuilderRef builder, BinaryenIndex index, diff --git a/src/binaryen-c.h b/src/binaryen-c.h index ba7c20126..5b343e8ba 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -3533,10 +3533,10 @@ BINARYEN_API BinaryenType TypeBuilderGetTempTupleType(TypeBuilderRef builder, BINARYEN_API BinaryenType TypeBuilderGetTempRefType(TypeBuilderRef builder, BinaryenHeapType heapType, int nullable); -// Sets the type at `index` to be a subtype of the type at `superIndex`. +// Sets the type at `index` to be a subtype of the given super type. BINARYEN_API void TypeBuilderSetSubType(TypeBuilderRef builder, BinaryenIndex index, - BinaryenIndex superIndex); + BinaryenHeapType superType); // Creates a new recursion group in the range `index` inclusive to `index + // length` exclusive. Recursion groups must not overlap. BINARYEN_API void TypeBuilderCreateRecGroup(TypeBuilderRef builder, diff --git a/src/ir/type-updating.cpp b/src/ir/type-updating.cpp index 6d5848c83..c560ce236 100644 --- a/src/ir/type-updating.cpp +++ b/src/ir/type-updating.cpp @@ -80,7 +80,8 @@ void GlobalTypeRewriter::update() { // Apply a super, if there is one if (auto super = type.getSuperType()) { - typeBuilder.setSubType(i, indexedTypes.indices[*super]); + typeBuilder.setSubType( + i, typeBuilder.getTempHeapType(indexedTypes.indices[*super])); } } diff --git a/src/wasm-type.h b/src/wasm-type.h index 778318794..940009cbe 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -599,9 +599,9 @@ struct TypeBuilder { Type getTempRefType(HeapType heapType, Nullability nullable); // In nominal mode, or for nominal types, declare the HeapType being built at - // index `i` to be an immediate subtype of the HeapType being built at index - // `j`. Does nothing for equirecursive types. - void setSubType(size_t i, size_t j); + // index `i` to be an immediate subtype of the given HeapType. Does nothing + // for equirecursive types. + void setSubType(size_t i, HeapType super); // Create a new recursion group covering slots [i, i + length). Groups must // not overlap or go out of bounds. @@ -669,7 +669,7 @@ struct TypeBuilder { } Entry& subTypeOf(Entry other) { assert(&builder == &other.builder); - builder.setSubType(index, other.index); + builder.setSubType(index, other); return *this; } }; diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 1bced53e4..c77099a1d 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -2803,11 +2803,10 @@ Type TypeBuilder::getTempRefType(HeapType type, Nullability nullable) { return markTemp(impl->typeStore.insert(TypeInfo(type, nullable))); } -void TypeBuilder::setSubType(size_t i, size_t j) { - assert(i < size() && j < size() && "index out of bounds"); +void TypeBuilder::setSubType(size_t i, HeapType super) { + assert(i < size() && "index out of bounds"); HeapTypeInfo* sub = impl->entries[i].info.get(); - HeapTypeInfo* super = impl->entries[j].info.get(); - sub->supertype = super; + sub->supertype = getHeapTypeInfo(super); } void TypeBuilder::createRecGroup(size_t i, size_t length) { @@ -3657,9 +3656,9 @@ std::optional<TypeBuilder::Error> canonicalizeIsorecursive( if (type.isBasic()) { continue; } - // Validate the supertype. Supertypes must precede their subtypes. + // Validate the supertype. Temporary supertypes must precede their subtypes. if (auto super = type.getSuperType()) { - if (!indexOfType.count(*super)) { + if (isTemp(*super) && !indexOfType.count(*super)) { return {{index, TypeBuilder::ErrorReason::ForwardSupertypeReference}}; } } |