diff options
author | Thomas Lively <tlively@google.com> | 2024-08-13 00:32:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 21:32:49 -0700 |
commit | d7955a34e332a78cc71bf77800114cba008185bb (patch) | |
tree | 8d06474d8af8c3784345a022dac6de76733d39b1 /src/wasm | |
parent | a4f9128f94b540fa04b67610eb501cb32ea203b4 (diff) | |
download | binaryen-d7955a34e332a78cc71bf77800114cba008185bb.tar.gz binaryen-d7955a34e332a78cc71bf77800114cba008185bb.tar.bz2 binaryen-d7955a34e332a78cc71bf77800114cba008185bb.zip |
Add a TypeBuilder API for copying a heap type (#6828)
Given a function that maps the old child heap types to new child heap
types, the new API takes care of copying the rest of the structure of a
given heap type into a TypeBuilder slot.
Use the new API in GlobalTypeRewriter::rebuildTypes. It will also be
used in an upcoming type optimization. This refactoring also required
adding the ability to clear the supertype of a TypeBuilder slot, which
was previously not possible.
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-type.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 173e4b8c3..011c51e7b 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -2532,10 +2532,10 @@ Type TypeBuilder::getTempRefType(HeapType type, Nullability nullable) { return markTemp(impl->typeStore.insert(TypeInfo(type, nullable))); } -void TypeBuilder::setSubType(size_t i, HeapType super) { +void TypeBuilder::setSubType(size_t i, std::optional<HeapType> super) { assert(i < size() && "index out of bounds"); HeapTypeInfo* sub = impl->entries[i].info.get(); - sub->supertype = getHeapTypeInfo(super); + sub->supertype = super ? getHeapTypeInfo(*super) : nullptr; } void TypeBuilder::createRecGroup(size_t index, size_t length) { |