diff options
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 6b74f2597..3c01e5df5 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -4062,6 +4062,9 @@ BinaryConsts::ASTNodes WasmBinaryReader::readExpression(Expression*& curr) { if (maybeVisitTableFill(curr, opcode)) { break; } + if (maybeVisitTableCopy(curr, opcode)) { + break; + } throwError("invalid code after misc prefix: " + std::to_string(opcode)); break; } @@ -5436,6 +5439,28 @@ bool WasmBinaryReader::maybeVisitTableFill(Expression*& out, uint32_t code) { return true; } +bool WasmBinaryReader::maybeVisitTableCopy(Expression*& out, uint32_t code) { + if (code != BinaryConsts::TableCopy) { + return false; + } + Index destTableIdx = getU32LEB(); + if (destTableIdx >= wasm.tables.size()) { + throwError("bad table index"); + } + Index sourceTableIdx = getU32LEB(); + if (sourceTableIdx >= wasm.tables.size()) { + throwError("bad table index"); + } + auto* size = popNonVoidExpression(); + auto* source = popNonVoidExpression(); + auto* dest = popNonVoidExpression(); + auto* ret = Builder(wasm).makeTableCopy(dest, source, size, Name(), Name()); + tableRefs[destTableIdx].push_back(&ret->destTable); + tableRefs[sourceTableIdx].push_back(&ret->sourceTable); + out = ret; + return true; +} + bool WasmBinaryReader::maybeVisitBinary(Expression*& out, uint8_t code) { Binary* curr; #define INT_TYPED_CODE(code) \ |