diff options
author | Alon Zakai <azakai@google.com> | 2024-07-29 16:27:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-29 16:27:42 -0700 |
commit | 6645f0c05b8e9268f35742bb6b0a67e0a9c40795 (patch) | |
tree | e8bfed8efcaa4d74a38b31636d1ee34b6c6734ac | |
parent | eac08461444da84e20d0641e429db7b03e45a21c (diff) | |
download | binaryen-6645f0c05b8e9268f35742bb6b0a67e0a9c40795.tar.gz binaryen-6645f0c05b8e9268f35742bb6b0a67e0a9c40795.tar.bz2 binaryen-6645f0c05b8e9268f35742bb6b0a67e0a9c40795.zip |
Fix shareability of internalized nulls (#6789)
-rw-r--r-- | src/wasm/literal.cpp | 5 | ||||
-rw-r--r-- | test/spec/convert_extern.wast | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index b3128025e..afbee4435 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -2700,11 +2700,12 @@ Literal Literal::externalize() const { } Literal Literal::internalize() const { - auto extType = HeapTypes::ext.getBasic(type.getHeapType().getShared()); + auto share = type.getHeapType().getShared(); + auto extType = HeapTypes::ext.getBasic(share); assert(Type::isSubType(type, Type(extType, Nullable)) && "can only internalize external references"); if (isNull()) { - return Literal(std::shared_ptr<GCData>{}, HeapType::none); + return Literal(std::shared_ptr<GCData>{}, HeapTypes::none.getBasic(share)); } if (gcData->type.isMaybeShared(HeapType::i31)) { assert(gcData->values[0].type.getHeapType().isMaybeShared(HeapType::i31)); diff --git a/test/spec/convert_extern.wast b/test/spec/convert_extern.wast new file mode 100644 index 000000000..36254bc4a --- /dev/null +++ b/test/spec/convert_extern.wast @@ -0,0 +1,11 @@ +(module + (func $shared-null (export "shared-null") (result (ref null (shared any))) + ;; The shared null here should remain shared as we internalize it. + (any.convert_extern + (ref.null (shared noextern)) + ) + ) +) + +(assert_return (invoke "shared-null") (ref.null (shared any))) + |