summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 0f1017e00..792e43cbe 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1018,14 +1018,18 @@ void RttSub::finalize() {
}
void StructNew::finalize() {
- if (rtt->type == Type::unreachable) {
+ if (rtt && rtt->type == Type::unreachable) {
type = Type::unreachable;
return;
}
if (handleUnreachableOperands(this)) {
return;
}
- type = Type(rtt->type.getHeapType(), NonNullable);
+ // A dynamic StructNew infers the type from the rtt. A static one has the type
+ // already in the type field.
+ if (rtt) {
+ type = Type(rtt->type.getHeapType(), NonNullable);
+ }
}
void StructGet::finalize() {
@@ -1045,16 +1049,21 @@ void StructSet::finalize() {
}
void ArrayNew::finalize() {
- if (rtt->type == Type::unreachable || size->type == Type::unreachable ||
+ if ((rtt && rtt->type == Type::unreachable) ||
+ size->type == Type::unreachable ||
(init && init->type == Type::unreachable)) {
type = Type::unreachable;
return;
}
- type = Type(rtt->type.getHeapType(), NonNullable);
+ // A dynamic ArrayNew infers the type from the rtt. A static one has the type
+ // already in the type field.
+ if (rtt) {
+ type = Type(rtt->type.getHeapType(), NonNullable);
+ }
}
void ArrayInit::finalize() {
- if (rtt->type == Type::unreachable) {
+ if (rtt && rtt->type == Type::unreachable) {
type = Type::unreachable;
return;
}
@@ -1064,7 +1073,11 @@ void ArrayInit::finalize() {
return;
}
}
- type = Type(rtt->type.getHeapType(), NonNullable);
+ // A dynamic ArrayInit infers the type from the rtt. A static one has the type
+ // already in the type field.
+ if (rtt) {
+ type = Type(rtt->type.getHeapType(), NonNullable);
+ }
}
void ArrayGet::finalize() {