diff options
author | Alon Zakai <azakai@google.com> | 2023-06-07 13:29:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 20:29:01 +0000 |
commit | 1daa10fb356cb01d80eaa3fd13c8c1d9a53ea343 (patch) | |
tree | 5e385e3f69971f576f930400e83215a5ac7df5f5 /src | |
parent | c70c0da85b689a7be23292731aa9bdc4ab22285e (diff) | |
download | binaryen-1daa10fb356cb01d80eaa3fd13c8c1d9a53ea343.tar.gz binaryen-1daa10fb356cb01d80eaa3fd13c8c1d9a53ea343.tar.bz2 binaryen-1daa10fb356cb01d80eaa3fd13c8c1d9a53ea343.zip |
[Strings] Fix non-nullable string emitting in the binary format (#5756)
Related to #5737 which did something similar for other types.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 1d0e99415..7b3f741b6 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1401,9 +1401,15 @@ void WasmBinaryWriter::writeType(Type type) { o << S32LEB(BinaryConsts::EncodedType::funcref); return; } - assert(Type::isSubType(type, Type(HeapType::ext, Nullable))); - o << S32LEB(BinaryConsts::EncodedType::externref); - return; + if (Type::isSubType(type, Type(HeapType::ext, Nullable))) { + o << S32LEB(BinaryConsts::EncodedType::externref); + return; + } + if (Type::isSubType(type, Type(HeapType::string, Nullable))) { + o << S32LEB(BinaryConsts::EncodedType::stringref); + return; + } + WASM_UNREACHABLE("bad type without GC"); } auto heapType = type.getHeapType(); if (heapType.isBasic() && type.isNullable()) { |