diff options
author | Max Graey <maxgraey@gmail.com> | 2021-10-18 22:48:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 12:48:50 -0700 |
commit | f0a8de302b85441deb8864c9e20c561c934e27b8 (patch) | |
tree | b71e540462b865891a0b63d25b0b16b9653fd04a /src/wasm/wasm-validator.cpp | |
parent | 0bec0a4bbaf4859bb4c7a2f1c4ecda60ccab72f2 (diff) | |
download | binaryen-f0a8de302b85441deb8864c9e20c561c934e27b8.tar.gz binaryen-f0a8de302b85441deb8864c9e20c561c934e27b8.tar.bz2 binaryen-f0a8de302b85441deb8864c9e20c561c934e27b8.zip |
Add table.grow operation (#4245)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 0271884a4..f8669961c 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -367,6 +367,7 @@ public: void visitTableGet(TableGet* curr); void visitTableSet(TableSet* curr); void visitTableSize(TableSize* curr); + void visitTableGrow(TableGrow* curr); void noteDelegate(Name name, Expression* curr); void noteRethrow(Name name, Expression* curr); void visitTry(Try* curr); @@ -2072,6 +2073,24 @@ void FunctionValidator::visitTableSize(TableSize* curr) { shouldBeTrue(!!table, curr, "table.size table must exist"); } +void FunctionValidator::visitTableGrow(TableGrow* curr) { + shouldBeTrue(getModule()->features.hasReferenceTypes(), + curr, + "table.grow requires reference types to be enabled"); + auto* table = getModule()->getTableOrNull(curr->table); + if (shouldBeTrue(!!table, curr, "table.grow table must exist") && + curr->type != Type::unreachable) { + shouldBeSubType(curr->value->type, + table->type, + curr, + "table.grow value must have right type"); + shouldBeEqual(curr->delta->type, + Type(Type::i32), + curr, + "table.grow must match table index type"); + } +} + void FunctionValidator::noteDelegate(Name name, Expression* curr) { if (name != DELEGATE_CALLER_TARGET) { shouldBeTrue(delegateTargetNames.count(name) != 0, |