Skip to content

Commit 6645f0c

Browse files
authored
Fix shareability of internalized nulls (#6789)
1 parent eac0846 commit 6645f0c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/wasm/literal.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,11 +2700,12 @@ Literal Literal::externalize() const {
27002700
}
27012701

27022702
Literal Literal::internalize() const {
2703-
auto extType = HeapTypes::ext.getBasic(type.getHeapType().getShared());
2703+
auto share = type.getHeapType().getShared();
2704+
auto extType = HeapTypes::ext.getBasic(share);
27042705
assert(Type::isSubType(type, Type(extType, Nullable)) &&
27052706
"can only internalize external references");
27062707
if (isNull()) {
2707-
return Literal(std::shared_ptr<GCData>{}, HeapType::none);
2708+
return Literal(std::shared_ptr<GCData>{}, HeapTypes::none.getBasic(share));
27082709
}
27092710
if (gcData->type.isMaybeShared(HeapType::i31)) {
27102711
assert(gcData->values[0].type.getHeapType().isMaybeShared(HeapType::i31));

test/spec/convert_extern.wast

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(module
2+
(func $shared-null (export "shared-null") (result (ref null (shared any)))
3+
;; The shared null here should remain shared as we internalize it.
4+
(any.convert_extern
5+
(ref.null (shared noextern))
6+
)
7+
)
8+
)
9+
10+
(assert_return (invoke "shared-null") (ref.null (shared any)))
11+

0 commit comments

Comments
 (0)