diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 13 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 5 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 8 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 5aa5948fe..ef564db6e 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -3933,6 +3933,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitStringConcat(curr, opcode)) { break; } + if (maybeVisitStringEq(curr, opcode)) { + break; + } if (opcode == BinaryConsts::RefIsFunc || opcode == BinaryConsts::RefIsData || opcode == BinaryConsts::RefIsI31) { @@ -7234,6 +7237,16 @@ bool WasmBinaryBuilder::maybeVisitStringConcat(Expression*& out, return true; } +bool WasmBinaryBuilder::maybeVisitStringEq(Expression*& out, uint32_t code) { + if (code != BinaryConsts::StringEq) { + return false; + } + auto* right = popNonVoidExpression(); + auto* left = popNonVoidExpression(); + out = Builder(wasm).makeStringEq(left, right); + return true; +} + void WasmBinaryBuilder::visitRefAs(RefAs* curr, uint8_t code) { BYN_TRACE("zz node: RefAs\n"); switch (code) { diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index fe52864d8..ecb8c2432 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2995,6 +2995,11 @@ Expression* SExpressionWasmBuilder::makeStringConcat(Element& s) { parseExpression(s[2])); } +Expression* SExpressionWasmBuilder::makeStringEq(Element& s) { + return Builder(wasm).makeStringEq(parseExpression(s[1]), + parseExpression(s[2])); +} + // converts an s-expression string representing binary data into an output // sequence of raw bytes this appends to data, which may already contain // content. diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index 6596cccc7..9a5db2928 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2304,6 +2304,10 @@ void BinaryInstWriter::visitStringConcat(StringConcat* curr) { o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::StringConcat); } +void BinaryInstWriter::visitStringEq(StringEq* curr) { + o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::StringEq); +} + void BinaryInstWriter::emitScopeEnd(Expression* curr) { assert(!breakStack.empty()); breakStack.pop_back(); diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index d3b1c2151..5e316d4f4 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1208,6 +1208,14 @@ void StringConcat::finalize() { } } +void StringEq::finalize() { + if (left->type == Type::unreachable || right->type == Type::unreachable) { + type = Type::unreachable; + } else { + type = Type::i32; + } +} + size_t Function::getNumParams() { return getParams().size(); } size_t Function::getNumVars() { return vars.size(); } |