summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Precompute.cpp2
-rw-r--r--src/passes/StringLowering.cpp13
-rw-r--r--src/tools/wasm-ctor-eval.cpp8
-rw-r--r--src/wasm-builder.h6
-rw-r--r--src/wasm/literal.cpp2
-rw-r--r--src/wasm/wasm-validator.cpp2
6 files changed, 21 insertions, 12 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index ba04a68aa..c60136ec7 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -293,7 +293,7 @@ struct Precompute
return;
}
} else if (singleValue.type.isRef() &&
- singleValue.type.getHeapType() == HeapType::func) {
+ singleValue.type.getHeapType().isSignature()) {
if (auto* r = curr->value->template dynCast<RefFunc>()) {
r->func = singleValue.getFunc();
r->finalize();
diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp
index f735b9ab2..fa5c1c9a8 100644
--- a/src/passes/StringLowering.cpp
+++ b/src/passes/StringLowering.cpp
@@ -291,8 +291,9 @@ struct StringLowering : public StringGathering {
// singleton rec group.
std::vector<Type> params, results;
auto fix = [](Type t) {
- if (t.isRef() && t.getHeapType() == HeapType::string) {
- t = Type(HeapType::ext, t.getNullability());
+ if (t.isRef() && t.getHeapType().isMaybeShared(HeapType::string)) {
+ auto share = t.getHeapType().getShared();
+ t = Type(HeapTypes::ext.getBasic(share), t.getNullability());
}
return t;
};
@@ -495,9 +496,13 @@ struct StringLowering : public StringGathering {
void noteSubtype(Expression* a, Type b) {
// This is the case we care about: if |a| is a null that must be a
// subtype of ext then we fix that up.
- if (b.isRef() && b.getHeapType().getTop() == HeapType::ext) {
+ if (!b.isRef()) {
+ return;
+ }
+ HeapType top = b.getHeapType().getTop();
+ if (top.isMaybeShared(HeapType::ext)) {
if (auto* null = a->dynCast<RefNull>()) {
- null->finalize(HeapType::noext);
+ null->finalize(HeapTypes::noext.getBasic(top.getShared()));
}
}
}
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 6c72f1c73..9cf552450 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -834,11 +834,13 @@ public:
// logic here, we save the original (possible externalized) value, and then
// look at the internals from here on out.
Literal original = value;
- if (value.type.isRef() && value.type.getHeapType() == HeapType::ext) {
+ if (value.type.isRef() &&
+ value.type.getHeapType().isMaybeShared(HeapType::ext)) {
value = value.internalize();
// We cannot serialize truly external things, only data and i31s.
- assert(value.isData() || value.type.getHeapType() == HeapType::i31);
+ assert(value.isData() ||
+ value.type.getHeapType().isMaybeShared(HeapType::i31));
}
// GC data (structs and arrays) must be handled with the special global-
@@ -920,7 +922,7 @@ public:
Expression* ret = builder.makeGlobalGet(definingGlobalName, value.type);
if (original != value) {
// The original is externalized.
- assert(original.type.getHeapType() == HeapType::ext);
+ assert(original.type.getHeapType().isMaybeShared(HeapType::ext));
ret = builder.makeRefAs(ExternConvertAny, ret);
}
return ret;
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 72d2a1db0..8f8895781 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -1387,8 +1387,10 @@ public:
if (curr->type.isNullable() && curr->type.isNull()) {
return ExpressionManipulator::refNull(curr, curr->type);
}
- if (curr->type.isRef() && curr->type.getHeapType() == HeapType::i31) {
- Expression* ret = makeRefI31(makeConst(0));
+ if (curr->type.isRef() &&
+ curr->type.getHeapType().isMaybeShared(HeapType::i31)) {
+ Expression* ret =
+ makeRefI31(makeConst(0), curr->type.getHeapType().getShared());
if (curr->type.isNullable()) {
// To keep the type identical, wrap it in a block that adds nullability.
ret = makeBlock({ret}, curr->type);
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index 40a1f9519..9d659f753 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -444,7 +444,7 @@ bool Literal::operator==(const Literal& other) const {
return gcData == other.gcData;
}
assert(type.getHeapType().isBasic());
- if (type.getHeapType().getBasic(Unshared) == HeapType::i31) {
+ if (type.getHeapType().isMaybeShared(HeapType::i31)) {
return i32 == other.i32;
}
WASM_UNREACHABLE("unexpected type");
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 758ae158e..0bdc18658 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2769,7 +2769,7 @@ void FunctionValidator::visitCallRef(CallRef* curr) {
getModule()->features.hasGC(), curr, "call_ref requires gc [--enable-gc]");
if (curr->target->type == Type::unreachable ||
(curr->target->type.isRef() &&
- curr->target->type.getHeapType() == HeapType::nofunc)) {
+ curr->target->type.getHeapType().isMaybeShared(HeapType::nofunc))) {
return;
}
if (shouldBeTrue(curr->target->type.isFunction(),