diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 7 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 11 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 13c28f151..54c904459 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -7111,11 +7111,12 @@ bool WasmBinaryBuilder::maybeVisitArraySet(Expression*& out, uint32_t code) { } bool WasmBinaryBuilder::maybeVisitArrayLen(Expression*& out, uint32_t code) { - if (code != BinaryConsts::ArrayLen) { + if (code == BinaryConsts::ArrayLenAnnotated) { + // Ignore the type annotation and don't bother validating it. + getU32LEB(); + } else if (code != BinaryConsts::ArrayLen) { return false; } - // Ignore the type annotation and don't bother validating it. - getU32LEB(); auto* ref = popNonVoidExpression(); out = Builder(wasm).makeArrayLen(ref); return true; diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 41a0619f9..78ac84f42 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -3027,9 +3027,14 @@ Expression* SExpressionWasmBuilder::makeArraySet(Element& s) { } Expression* SExpressionWasmBuilder::makeArrayLen(Element& s) { - // Ignore the type annotation and don't bother validating it. - parseHeapType(*s[1]); - auto ref = parseExpression(*s[2]); + // There may or may not be a type annotation. + Index i = 1; + try { + parseHeapType(*s[i]); + ++i; + } catch (...) { + } + auto ref = parseExpression(*s[i]); return Builder(wasm).makeArrayLen(ref); } diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index 7c1c121d5..f30e4be82 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2169,8 +2169,6 @@ void BinaryInstWriter::visitArraySet(ArraySet* curr) { void BinaryInstWriter::visitArrayLen(ArrayLen* curr) { o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::ArrayLen); - // Unused type index. - o << U32LEB(0); } void BinaryInstWriter::visitArrayCopy(ArrayCopy* curr) { |