summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-delegations-fields.def1
-rw-r--r--src/wasm/wasm-binary.cpp3
-rw-r--r--src/wasm/wasm-stack.cpp2
-rw-r--r--test/lit/ref-cast-nop.wast11
4 files changed, 14 insertions, 3 deletions
diff --git a/src/wasm-delegations-fields.def b/src/wasm-delegations-fields.def
index cd182e319..e3ec30a40 100644
--- a/src/wasm-delegations-fields.def
+++ b/src/wasm-delegations-fields.def
@@ -620,6 +620,7 @@ switch (DELEGATE_ID) {
}
case Expression::Id::RefCastId: {
DELEGATE_START(RefCast);
+ DELEGATE_FIELD_INT(RefCast, safety);
DELEGATE_FIELD_CHILD(RefCast, ref);
DELEGATE_END(RefCast);
break;
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index cd5763c12..431c39631 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -6935,8 +6935,7 @@ void WasmBinaryBuilder::visitRefAsCast(RefCast* curr, uint32_t code) {
bool WasmBinaryBuilder::maybeVisitRefCast(Expression*& out, uint32_t code) {
if (code == BinaryConsts::RefCastStatic || code == BinaryConsts::RefCast ||
code == BinaryConsts::RefCastNull || code == BinaryConsts::RefCastNop) {
- bool legacy =
- code == BinaryConsts::RefCastStatic || code == BinaryConsts::RefCastNop;
+ bool legacy = code == BinaryConsts::RefCastStatic;
auto heapType = legacy ? getIndexedHeapType() : getHeapType();
auto* ref = popNonVoidExpression();
Nullability nullability;
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 694ed4269..a2fba3907 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -2036,7 +2036,7 @@ void BinaryInstWriter::visitRefCast(RefCast* curr) {
o << int8_t(BinaryConsts::GCPrefix);
if (curr->safety == RefCast::Unsafe) {
o << U32LEB(BinaryConsts::RefCastNop);
- parent.writeIndexedHeapType(curr->type.getHeapType());
+ parent.writeHeapType(curr->type.getHeapType());
} else {
// TODO: These instructions are deprecated. Remove them.
if (auto type = curr->type.getHeapType();
diff --git a/test/lit/ref-cast-nop.wast b/test/lit/ref-cast-nop.wast
index 060005f4d..3b284db04 100644
--- a/test/lit/ref-cast-nop.wast
+++ b/test/lit/ref-cast-nop.wast
@@ -15,4 +15,15 @@
(local.get $x)
)
)
+
+ ;; CHECK: (func $ref.cast_nop.null (type $ref|any|_=>_ref|none|) (param $x (ref any)) (result (ref none))
+ ;; CHECK-NEXT: (ref.cast_nop none
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $ref.cast_nop.null (param $x (ref any)) (result (ref none))
+ (ref.cast_nop none
+ (local.get $x)
+ )
+ )
)