summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-11-06 12:29:19 -0800
committerGitHub <noreply@github.com>2023-11-06 12:29:19 -0800
commite3d27166370da202bef6c012014604beac41d43f (patch)
treef9e0515c0c6044e6c9b12f6d5d83f8ba99ab0fc3 /src/wasm/wasm-validator.cpp
parent4fba26a77ea344b8d2b49cc8e1afdc8fcda13e96 (diff)
downloadbinaryen-e3d27166370da202bef6c012014604beac41d43f.tar.gz
binaryen-e3d27166370da202bef6c012014604beac41d43f.tar.bz2
binaryen-e3d27166370da202bef6c012014604beac41d43f.zip
Implement table.copy (#6078)
Helps #5951
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index cd90e767e..68d1f786d 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -441,6 +441,7 @@ public:
void visitTableSize(TableSize* curr);
void visitTableGrow(TableGrow* curr);
void visitTableFill(TableFill* curr);
+ void visitTableCopy(TableCopy* curr);
void noteDelegate(Name name, Expression* curr);
void noteRethrow(Name name, Expression* curr);
void visitTry(Try* curr);
@@ -2315,6 +2316,27 @@ void FunctionValidator::visitTableFill(TableFill* curr) {
curr->size->type, Type(Type::i32), curr, "table.fill size must be i32");
}
+void FunctionValidator::visitTableCopy(TableCopy* curr) {
+ shouldBeTrue(getModule()->features.hasBulkMemory(),
+ curr,
+ "table.copy requires bulk-memory [--enable-bulk-memory]");
+ auto* sourceTable = getModule()->getTableOrNull(curr->sourceTable);
+ auto* destTable = getModule()->getTableOrNull(curr->destTable);
+ if (shouldBeTrue(!!sourceTable, curr, "table.copy source table must exist") &&
+ shouldBeTrue(!!destTable, curr, "table.copy dest table must exist")) {
+ shouldBeSubType(sourceTable->type,
+ destTable->type,
+ curr,
+ "table.copy source must have right type for dest");
+ }
+ shouldBeEqualOrFirstIsUnreachable(
+ curr->dest->type, Type(Type::i32), curr, "table.copy dest must be i32");
+ shouldBeEqualOrFirstIsUnreachable(
+ curr->source->type, Type(Type::i32), curr, "table.copy source must be i32");
+ shouldBeEqualOrFirstIsUnreachable(
+ curr->size->type, Type(Type::i32), curr, "table.copy size must be i32");
+}
+
void FunctionValidator::noteDelegate(Name name, Expression* curr) {
if (name != DELEGATE_CALLER_TARGET) {
shouldBeTrue(delegateTargetNames.count(name) != 0,