summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp8
-rw-r--r--src/wasm/wasm-validator.cpp2
-rw-r--r--src/wasm/wasm.cpp6
3 files changed, 11 insertions, 5 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 920baf944..bc7ec8ac8 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1544,9 +1544,9 @@ void WasmBinaryWriter::writeInlineBuffer(const char* data, size_t size) {
void WasmBinaryWriter::writeType(Type type) {
if (type.isRef()) {
- // The only reference types allowed without GC are funcref and externref. We
- // internally use more refined versions of those types, but we cannot emit
- // those more refined types.
+ // The only reference types allowed without GC are funcref, externref, and
+ // exnref. We internally use more refined versions of those types, but we
+ // cannot emit those without GC.
if (!wasm->features.hasGC()) {
auto ht = type.getHeapType();
if (ht.isMaybeShared(HeapType::string)) {
@@ -1555,6 +1555,8 @@ void WasmBinaryWriter::writeType(Type type) {
// string, the stringref feature must be enabled.
type = Type(HeapTypes::string.getBasic(ht.getShared()), Nullable);
} else {
+ // Only the top type (func, extern, exn) is available, and only the
+ // nullable version.
type = Type(type.getHeapType().getTop(), Nullable);
}
}
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index a86187fa7..0184e3284 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2658,7 +2658,7 @@ void FunctionValidator::visitTryTable(TryTable* curr) {
"the number of catch tags and sent types do not match");
const char* invalidSentTypeMsg = "invalid catch sent type information";
- Type exnref = Type(HeapType::exn, Nullable);
+ Type exnref = Type(HeapType::exn, NonNullable);
for (Index i = 0; i < curr->catchTags.size(); i++) {
auto sentType = curr->sentTypes[i];
size_t tagTypeSize;
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 0245fc01e..4150af5b4 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -933,7 +933,11 @@ static void populateTryTableSentTypes(TryTable* curr, Module* wasm) {
return;
}
curr->sentTypes.clear();
- Type exnref = Type(HeapType::exn, Nullable);
+ // We always use the refined non-nullable type in our IR, which is what the
+ // wasm spec defines when GC is enabled (=== non-nullable types are allowed).
+ // If GC is not enabled then we emit a nullable type in the binary format in
+ // WasmBinaryWriter::writeType.
+ Type exnref = Type(HeapType::exn, NonNullable);
for (Index i = 0; i < curr->catchTags.size(); i++) {
auto tagName = curr->catchTags[i];
std::vector<Type> sentType;