summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-07-11 17:25:54 -0400
committerGitHub <noreply@github.com>2024-07-11 14:25:54 -0700
commitae4800bebd0d479813d99e31e098296c9167e34a (patch)
treee675041374e8411372b21ca3f6551a13acd63170 /src
parentc64ac5d5a676fdbb9b108e0ad16c293a32a9b611 (diff)
downloadbinaryen-ae4800bebd0d479813d99e31e098296c9167e34a.tar.gz
binaryen-ae4800bebd0d479813d99e31e098296c9167e34a.tar.bz2
binaryen-ae4800bebd0d479813d99e31e098296c9167e34a.zip
[threads] Shared polymorphism for extern conversions (#6730)
`any.convert_extern` and `extern.convert_any` return references to shared heap types iff their operands are references to shared heap types.
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-validator.cpp18
-rw-r--r--src/wasm/wasm.cpp9
2 files changed, 16 insertions, 11 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 9732f54a9..eb2f949b2 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2222,10 +2222,11 @@ void FunctionValidator::visitRefAs(RefAs* curr) {
if (curr->type == Type::unreachable) {
return;
}
- shouldBeSubType(curr->value->type,
- Type(HeapType::ext, Nullable),
- curr->value,
- "any.convert_extern value should be an externref");
+ shouldBeSubTypeIgnoringShared(
+ curr->value->type,
+ Type(HeapType::ext, Nullable),
+ curr->value,
+ "any.convert_extern value should be an externref");
break;
}
case ExternConvertAny: {
@@ -2235,10 +2236,11 @@ void FunctionValidator::visitRefAs(RefAs* curr) {
if (curr->type == Type::unreachable) {
return;
}
- shouldBeSubType(curr->value->type,
- Type(HeapType::any, Nullable),
- curr->value,
- "extern.convert_any value should be an anyref");
+ shouldBeSubTypeIgnoringShared(
+ curr->value->type,
+ Type(HeapType::any, Nullable),
+ curr->value,
+ "extern.convert_any value should be an anyref");
break;
}
}
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 58699ad8b..8a2b4755c 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1227,15 +1227,18 @@ void RefAs::finalize() {
type = Type::unreachable;
return;
}
+ auto valHeapType = value->type.getHeapType();
switch (op) {
case RefAsNonNull:
- type = Type(value->type.getHeapType(), NonNullable);
+ type = Type(valHeapType, NonNullable);
break;
case AnyConvertExtern:
- type = Type(HeapType::any, value->type.getNullability());
+ type = Type(HeapTypes::any.getBasic(valHeapType.getShared()),
+ value->type.getNullability());
break;
case ExternConvertAny:
- type = Type(HeapType::ext, value->type.getNullability());
+ type = Type(HeapTypes::ext.getBasic(valHeapType.getShared()),
+ value->type.getNullability());
break;
default:
WASM_UNREACHABLE("invalid ref.as_*");