diff options
author | Alon Zakai <azakai@google.com> | 2023-02-03 08:10:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 08:10:13 -0800 |
commit | d2d5135b14c2b36cdd6b5a5d00a7734fe385fc37 (patch) | |
tree | 3e36da69e914c016c7b2d10b074f21fafc8d1e20 /src | |
parent | f8261babf4c3b69c9339ddbd4d2b0318062833a8 (diff) | |
download | binaryen-d2d5135b14c2b36cdd6b5a5d00a7734fe385fc37.tar.gz binaryen-d2d5135b14c2b36cdd6b5a5d00a7734fe385fc37.tar.bz2 binaryen-d2d5135b14c2b36cdd6b5a5d00a7734fe385fc37.zip |
Fix issues with ref.cast_nop (#5473)
It did not have proper annotation for the safety field, and also
it could not handle basic heap types.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-delegations-fields.def | 1 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 3 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 2 |
3 files changed, 3 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(); |