diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Print.cpp | 9 | ||||
-rw-r--r-- | src/wasm-binary.h | 3 | ||||
-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 |
5 files changed, 15 insertions, 17 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 0f4a314ae..d0f19f78e 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2236,14 +2236,7 @@ struct PrintExpressionContents printMedium(o, "array.set "); TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType()); } - void visitArrayLen(ArrayLen* curr) { - printMedium(o, "array.len "); - if (curr->ref->type == Type::unreachable) { - TypeNamePrinter(o, wasm).print(HeapType::array); - } else { - TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType()); - } - } + void visitArrayLen(ArrayLen* curr) { printMedium(o, "array.len"); } void visitArrayCopy(ArrayCopy* curr) { if (printUnreachableOrNullReplacement(curr->srcRef) || printUnreachableOrNullReplacement(curr->destRef)) { diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 709c0c9f9..db123515a 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1111,8 +1111,9 @@ enum ASTNodes { ArrayGetS = 0x14, ArrayGetU = 0x15, ArraySet = 0x16, - ArrayLen = 0x17, + ArrayLenAnnotated = 0x17, ArrayCopy = 0x18, + ArrayLen = 0x19, ArrayInitStatic = 0x1a, ArrayNew = 0x1b, ArrayNewDefault = 0x1c, 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) { |