summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-stack.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-08-16 12:53:52 -0700
committerGitHub <noreply@github.com>2024-08-16 12:53:52 -0700
commit958ff4115e542ef1d0ae712f4961e342386efe54 (patch)
tree7805d641d9a73b32650a053931c4bd8c3814d804 /src/wasm/wasm-stack.cpp
parent7209629bec3961fcc12b150ba6df546d3997b6c2 (diff)
downloadbinaryen-958ff4115e542ef1d0ae712f4961e342386efe54.tar.gz
binaryen-958ff4115e542ef1d0ae712f4961e342386efe54.tar.bz2
binaryen-958ff4115e542ef1d0ae712f4961e342386efe54.zip
Implement table.init (#6827)
Also use TableInit in the interpreter to initialize module's table state, which will now handle traps properly, fixing #6431
Diffstat (limited to 'src/wasm/wasm-stack.cpp')
-rw-r--r--src/wasm/wasm-stack.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index a9b582f43..1c2c2c42b 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -2053,6 +2053,12 @@ void BinaryInstWriter::visitTableCopy(TableCopy* curr) {
o << U32LEB(parent.getTableIndex(curr->sourceTable));
}
+void BinaryInstWriter::visitTableInit(TableInit* curr) {
+ o << int8_t(BinaryConsts::MiscPrefix) << U32LEB(BinaryConsts::TableInit);
+ o << U32LEB(parent.getElementSegmentIndex(curr->segment));
+ o << U32LEB(parent.getTableIndex(curr->table));
+}
+
void BinaryInstWriter::visitTry(Try* curr) {
breakStack.push_back(curr->name);
o << int8_t(BinaryConsts::Try);