summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gen-s-parser.py3
-rw-r--r--src/gen-s-parser.inc9
-rw-r--r--src/ir/ReFinalize.cpp1
-rw-r--r--src/ir/cost.h3
-rw-r--r--src/ir/effects.h5
-rw-r--r--src/ir/possible-contents.cpp1
-rw-r--r--src/parser/parsers.h5
-rw-r--r--src/passes/Directize.cpp3
-rw-r--r--src/passes/Print.cpp6
-rw-r--r--src/passes/Unsubtyping.cpp4
-rw-r--r--src/wasm-binary.h2
-rw-r--r--src/wasm-builder.h14
-rw-r--r--src/wasm-delegations-fields.def10
-rw-r--r--src/wasm-delegations.def1
-rw-r--r--src/wasm-interpreter.h56
-rw-r--r--src/wasm-ir-builder.h1
-rw-r--r--src/wasm-s-parser.h1
-rw-r--r--src/wasm.h15
-rw-r--r--src/wasm/wasm-binary.cpp25
-rw-r--r--src/wasm/wasm-s-parser.cpp18
-rw-r--r--src/wasm/wasm-stack.cpp6
-rw-r--r--src/wasm/wasm-validator.cpp22
-rw-r--r--src/wasm/wasm.cpp8
-rw-r--r--src/wasm2js.h4
-rw-r--r--test/binaryen.js/exception-handling.js.txt8
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt68
-rw-r--r--test/lit/passes/unsubtyping.wast36
-rw-r--r--test/lit/table-operations.wast36
-rw-r--r--test/spec/table_copy.wast2216
29 files changed, 2545 insertions, 42 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py
index 831e217ba..776cc4425 100755
--- a/scripts/gen-s-parser.py
+++ b/scripts/gen-s-parser.py
@@ -548,10 +548,9 @@ instructions = [
("table.size", "makeTableSize(s)"),
("table.grow", "makeTableGrow(s)"),
("table.fill", "makeTableFill(s)"),
+ ("table.copy", "makeTableCopy(s)"),
# TODO:
# table.init
- # table.fill
- # table.copy
#
# exception handling instructions
("try", "makeTry(s)"),
diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc
index e09bacfc2..a7cdc76c7 100644
--- a/src/gen-s-parser.inc
+++ b/src/gen-s-parser.inc
@@ -3357,6 +3357,9 @@ switch (buf[0]) {
switch (buf[1]) {
case 'a': {
switch (buf[6]) {
+ case 'c':
+ if (op == "table.copy"sv) { return makeTableCopy(s); }
+ goto parse_error;
case 'f':
if (op == "table.fill"sv) { return makeTableFill(s); }
goto parse_error;
@@ -8619,6 +8622,12 @@ switch (buf[0]) {
switch (buf[1]) {
case 'a': {
switch (buf[6]) {
+ case 'c':
+ if (op == "table.copy"sv) {
+ CHECK_ERR(makeTableCopy(ctx, pos));
+ return Ok{};
+ }
+ goto parse_error;
case 'f':
if (op == "table.fill"sv) {
CHECK_ERR(makeTableFill(ctx, pos));
diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp
index bfdcfe7a6..3d74b1422 100644
--- a/src/ir/ReFinalize.cpp
+++ b/src/ir/ReFinalize.cpp
@@ -125,6 +125,7 @@ void ReFinalize::visitTableSet(TableSet* curr) { curr->finalize(); }
void ReFinalize::visitTableSize(TableSize* curr) { curr->finalize(); }
void ReFinalize::visitTableGrow(TableGrow* curr) { curr->finalize(); }
void ReFinalize::visitTableFill(TableFill* curr) { curr->finalize(); }
+void ReFinalize::visitTableCopy(TableCopy* curr) { curr->finalize(); }
void ReFinalize::visitTry(Try* curr) { curr->finalize(); }
void ReFinalize::visitThrow(Throw* curr) { curr->finalize(); }
void ReFinalize::visitRethrow(Rethrow* curr) { curr->finalize(); }
diff --git a/src/ir/cost.h b/src/ir/cost.h
index efc50eb1b..d3a483535 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -577,6 +577,9 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
CostType visitTableFill(TableFill* curr) {
return 6 + visit(curr->dest) + visit(curr->value) + visit(curr->size);
}
+ CostType visitTableCopy(TableCopy* curr) {
+ return 6 + visit(curr->dest) + visit(curr->source) + visit(curr->size);
+ }
CostType visitTry(Try* curr) {
// We assume no exception will be thrown in most cases
return visit(curr->body);
diff --git a/src/ir/effects.h b/src/ir/effects.h
index 9bdf08c74..0e45ec70c 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -696,6 +696,11 @@ private:
parent.writesTable = true;
parent.implicitTrap = true;
}
+ void visitTableCopy(TableCopy* curr) {
+ parent.readsTable = true;
+ parent.writesTable = true;
+ parent.implicitTrap = true;
+ }
void visitTry(Try* curr) {
if (curr->delegateTarget.is()) {
parent.delegateTargets.insert(curr->delegateTarget);
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp
index 06d380a95..7c9a4fc6b 100644
--- a/src/ir/possible-contents.cpp
+++ b/src/ir/possible-contents.cpp
@@ -662,6 +662,7 @@ struct InfoCollector
void visitTableSize(TableSize* curr) { addRoot(curr); }
void visitTableGrow(TableGrow* curr) { addRoot(curr); }
void visitTableFill(TableFill* curr) { addRoot(curr); }
+ void visitTableCopy(TableCopy* curr) { addRoot(curr); }
void visitNop(Nop* curr) {}
void visitUnreachable(Unreachable* curr) {}
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 65fd98a24..3a4f9c212 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -118,6 +118,7 @@ template<typename Ctx> Result<> makeTableSet(Ctx&, Index);
template<typename Ctx> Result<> makeTableSize(Ctx&, Index);
template<typename Ctx> Result<> makeTableGrow(Ctx&, Index);
template<typename Ctx> Result<> makeTableFill(Ctx&, Index);
+template<typename Ctx> Result<> makeTableCopy(Ctx&, Index);
template<typename Ctx> Result<> makeTry(Ctx&, Index);
template<typename Ctx>
Result<> makeTryOrCatchBody(Ctx&, Index, Type type, bool isTry);
@@ -1264,6 +1265,10 @@ template<typename Ctx> Result<> makeTableFill(Ctx& ctx, Index pos) {
return ctx.in.err("unimplemented instruction");
}
+template<typename Ctx> Result<> makeTableCopy(Ctx& ctx, Index pos) {
+ return ctx.in.err("unimplemented instruction");
+}
+
template<typename Ctx> Result<> makeTry(Ctx& ctx, Index pos) {
return ctx.in.err("unimplemented instruction");
}
diff --git a/src/passes/Directize.cpp b/src/passes/Directize.cpp
index 34930d127..78294d59d 100644
--- a/src/passes/Directize.cpp
+++ b/src/passes/Directize.cpp
@@ -263,6 +263,9 @@ struct Directize : public Pass {
void visitTableFill(TableFill* curr) {
tablesWithSet.insert(curr->table);
}
+ void visitTableCopy(TableCopy* curr) {
+ tablesWithSet.insert(curr->destTable);
+ }
};
Finder(tablesWithSet).walkFunction(func);
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 51d261126..889eb87fd 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1950,6 +1950,12 @@ struct PrintExpressionContents
printMedium(o, "table.fill ");
printName(curr->table, o);
}
+ void visitTableCopy(TableCopy* curr) {
+ printMedium(o, "table.copy ");
+ printName(curr->destTable, o);
+ o << ' ';
+ printName(curr->sourceTable, o);
+ }
void visitTry(Try* curr) {
printMedium(o, "try");
if (curr->name.is()) {
diff --git a/src/passes/Unsubtyping.cpp b/src/passes/Unsubtyping.cpp
index 87da111f0..e5d9453a8 100644
--- a/src/passes/Unsubtyping.cpp
+++ b/src/passes/Unsubtyping.cpp
@@ -446,6 +446,10 @@ struct Unsubtyping
void visitTableFill(TableFill* curr) {
noteSubtype(curr->value->type, getModule()->getTable(curr->table)->type);
}
+ void visitTableCopy(TableCopy* curr) {
+ noteSubtype(getModule()->getTable(curr->sourceTable)->type,
+ getModule()->getTable(curr->destTable)->type);
+ }
void visitTry(Try* curr) {
noteSubtype(curr->body->type, curr->type);
for (auto* body : curr->catchBodies) {
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 9e72b3b82..752f306fe 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1132,6 +1132,7 @@ enum ASTNodes {
TableGrow = 0x0f,
TableSize = 0x10,
TableFill = 0x11,
+ TableCopy = 0x0e,
RefNull = 0xd0,
RefIsNull = 0xd1,
RefFunc = 0xd2,
@@ -1844,6 +1845,7 @@ public:
bool maybeVisitTableSize(Expression*& out, uint32_t code);
bool maybeVisitTableGrow(Expression*& out, uint32_t code);
bool maybeVisitTableFill(Expression*& out, uint32_t code);
+ bool maybeVisitTableCopy(Expression*& out, uint32_t code);
bool maybeVisitRefI31(Expression*& out, uint32_t code);
bool maybeVisitI31Get(Expression*& out, uint32_t code);
bool maybeVisitRefTest(Expression*& out, uint32_t code);
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 9a59b4015..9e2881145 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -771,6 +771,20 @@ public:
ret->finalize();
return ret;
}
+ TableCopy* makeTableCopy(Expression* dest,
+ Expression* source,
+ Expression* size,
+ Name destTable,
+ Name sourceTable) {
+ auto* ret = wasm.allocator.alloc<TableCopy>();
+ ret->dest = dest;
+ ret->source = source;
+ ret->size = size;
+ ret->destTable = destTable;
+ ret->sourceTable = sourceTable;
+ ret->finalize();
+ return ret;
+ }
private:
Try* makeTry(Name name,
diff --git a/src/wasm-delegations-fields.def b/src/wasm-delegations-fields.def
index 3ab112bdd..d7567b38d 100644
--- a/src/wasm-delegations-fields.def
+++ b/src/wasm-delegations-fields.def
@@ -576,6 +576,16 @@ switch (DELEGATE_ID) {
DELEGATE_END(TableFill);
break;
}
+ case Expression::Id::TableCopyId: {
+ DELEGATE_START(TableCopy);
+ DELEGATE_FIELD_CHILD(TableCopy, size);
+ DELEGATE_FIELD_CHILD(TableCopy, source);
+ DELEGATE_FIELD_CHILD(TableCopy, dest);
+ DELEGATE_FIELD_NAME_KIND(TableCopy, sourceTable, ModuleItemKind::Table);
+ DELEGATE_FIELD_NAME_KIND(TableCopy, destTable, ModuleItemKind::Table);
+ DELEGATE_END(TableCopy);
+ break;
+ }
case Expression::Id::TryId: {
DELEGATE_START(Try);
DELEGATE_FIELD_SCOPE_NAME_USE(Try, delegateTarget);
diff --git a/src/wasm-delegations.def b/src/wasm-delegations.def
index a9c9c3f75..903b19bf7 100644
--- a/src/wasm-delegations.def
+++ b/src/wasm-delegations.def
@@ -63,6 +63,7 @@ DELEGATE(TableSet);
DELEGATE(TableSize);
DELEGATE(TableGrow);
DELEGATE(TableFill);
+DELEGATE(TableCopy);
DELEGATE(Try);
DELEGATE(Throw);
DELEGATE(Rethrow);
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 8eb52e634..3599def90 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1392,6 +1392,7 @@ public:
Flow visitTableSize(TableSize* curr) { WASM_UNREACHABLE("unimp"); }
Flow visitTableGrow(TableGrow* curr) { WASM_UNREACHABLE("unimp"); }
Flow visitTableFill(TableFill* curr) { WASM_UNREACHABLE("unimp"); }
+ Flow visitTableCopy(TableCopy* curr) { WASM_UNREACHABLE("unimp"); }
Flow visitTry(Try* curr) { WASM_UNREACHABLE("unimp"); }
Flow visitThrow(Throw* curr) {
NOTE_ENTER("Throw");
@@ -2210,6 +2211,10 @@ public:
NOTE_ENTER("TableFill");
return Flow(NONCONSTANT_FLOW);
}
+ Flow visitTableCopy(TableCopy* curr) {
+ NOTE_ENTER("TableCopy");
+ return Flow(NONCONSTANT_FLOW);
+ }
Flow visitLoad(Load* curr) {
NOTE_ENTER("Load");
return Flow(NONCONSTANT_FLOW);
@@ -3027,6 +3032,57 @@ public:
return Flow();
}
+ Flow visitTableCopy(TableCopy* curr) {
+ NOTE_ENTER("TableCopy");
+ Flow dest = self()->visit(curr->dest);
+ if (dest.breaking()) {
+ return dest;
+ }
+ Flow source = self()->visit(curr->source);
+ if (source.breaking()) {
+ return source;
+ }
+ Flow size = self()->visit(curr->size);
+ if (size.breaking()) {
+ return size;
+ }
+ NOTE_EVAL1(dest);
+ NOTE_EVAL1(source);
+ NOTE_EVAL1(size);
+ Address destVal(dest.getSingleValue().getUnsigned());
+ Address sourceVal(source.getSingleValue().getUnsigned());
+ Address sizeVal(size.getSingleValue().getUnsigned());
+
+ auto destInfo = getTableInterfaceInfo(curr->destTable);
+ auto sourceInfo = getTableInterfaceInfo(curr->sourceTable);
+ auto destTableSize = destInfo.interface->tableSize(destInfo.name);
+ auto sourceTableSize = sourceInfo.interface->tableSize(sourceInfo.name);
+ if (sourceVal + sizeVal > sourceTableSize ||
+ destVal + sizeVal > destTableSize ||
+ // FIXME: better/cheaper way to detect wrapping?
+ sourceVal + sizeVal < sourceVal || sourceVal + sizeVal < sizeVal ||
+ destVal + sizeVal < destVal || destVal + sizeVal < sizeVal) {
+ trap("out of bounds segment access in table.copy");
+ }
+
+ int64_t start = 0;
+ int64_t end = sizeVal;
+ int step = 1;
+ // Reverse direction if source is below dest
+ if (sourceVal < destVal) {
+ start = int64_t(sizeVal) - 1;
+ end = -1;
+ step = -1;
+ }
+ for (int64_t i = start; i != end; i += step) {
+ destInfo.interface->tableStore(
+ destInfo.name,
+ destVal + i,
+ sourceInfo.interface->tableLoad(sourceInfo.name, sourceVal + i));
+ }
+ return {};
+ }
+
Flow visitLocalGet(LocalGet* curr) {
NOTE_ENTER("LocalGet");
auto index = curr->index;
diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h
index b42d40892..c0fce32c7 100644
--- a/src/wasm-ir-builder.h
+++ b/src/wasm-ir-builder.h
@@ -135,6 +135,7 @@ public:
// [[nodiscard]] Result<> makeTableSize();
// [[nodiscard]] Result<> makeTableGrow();
// [[nodiscard]] Result<> makeTableFill();
+ // [[nodiscard]] Result<> makeTableCopy();
// [[nodiscard]] Result<> makeTry();
// [[nodiscard]] Result<> makeThrow();
// [[nodiscard]] Result<> makeRethrow();
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 6853f2c01..bbd07e3be 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -282,6 +282,7 @@ private:
Expression* makeTableSize(Element& s);
Expression* makeTableGrow(Element& s);
Expression* makeTableFill(Element& s);
+ Expression* makeTableCopy(Element& s);
Expression* makeTry(Element& s);
Expression* makeTryOrCatchBody(Element& s, Type type, bool isTry);
Expression* makeThrow(Element& s);
diff --git a/src/wasm.h b/src/wasm.h
index 1792b1538..ba797d773 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -699,6 +699,7 @@ public:
TableSizeId,
TableGrowId,
TableFillId,
+ TableCopyId,
TryId,
ThrowId,
RethrowId,
@@ -1435,6 +1436,20 @@ public:
void finalize();
};
+class TableCopy : public SpecificExpression<Expression::TableCopyId> {
+public:
+ TableCopy() = default;
+ TableCopy(MixedArena& allocator) : TableCopy() {}
+
+ Expression* dest;
+ Expression* source;
+ Expression* size;
+ Name destTable;
+ Name sourceTable;
+
+ void finalize();
+};
+
class Try : public SpecificExpression<Expression::TryId> {
public:
Try(MixedArena& allocator) : catchTags(allocator), catchBodies(allocator) {}
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) \
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 6f3fbe76b..7b415813e 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2706,6 +2706,24 @@ Expression* SExpressionWasmBuilder::makeTableFill(Element& s) {
return Builder(wasm).makeTableFill(tableName, dest, value, size);
}
+Expression* SExpressionWasmBuilder::makeTableCopy(Element& s) {
+ auto destTableName = s[1]->str();
+ auto* destTable = wasm.getTableOrNull(destTableName);
+ if (!destTable) {
+ throw SParseException("invalid dest table name in table.copy", s);
+ }
+ auto sourceTableName = s[2]->str();
+ auto* sourceTable = wasm.getTableOrNull(sourceTableName);
+ if (!sourceTable) {
+ throw SParseException("invalid source table name in table.copy", s);
+ }
+ auto* dest = parseExpression(s[3]);
+ auto* source = parseExpression(s[4]);
+ auto* size = parseExpression(s[5]);
+ return Builder(wasm).makeTableCopy(
+ dest, source, size, destTableName, sourceTableName);
+}
+
// try can be either in the form of try-catch or try-delegate.
// try-catch is written in the folded wast format as
// (try
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 1d2363be3..0f8facfd5 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -1941,6 +1941,12 @@ void BinaryInstWriter::visitTableFill(TableFill* curr) {
o << U32LEB(parent.getTableIndex(curr->table));
}
+void BinaryInstWriter::visitTableCopy(TableCopy* curr) {
+ o << int8_t(BinaryConsts::MiscPrefix) << U32LEB(BinaryConsts::TableCopy);
+ o << U32LEB(parent.getTableIndex(curr->destTable));
+ o << U32LEB(parent.getTableIndex(curr->sourceTable));
+}
+
void BinaryInstWriter::visitTry(Try* curr) {
breakStack.push_back(curr->name);
o << int8_t(BinaryConsts::Try);
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,
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index fef613cd2..24479c1cf 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -866,6 +866,14 @@ void TableFill::finalize() {
}
}
+void TableCopy::finalize() {
+ type = Type::none;
+ if (dest->type == Type::unreachable || source->type == Type::unreachable ||
+ size->type == Type::unreachable) {
+ type = Type::unreachable;
+ }
+}
+
void Try::finalize() {
// If none of the component bodies' type is a supertype of the others, assume
// the current type is already correct. TODO: Calculate a proper LUB.
diff --git a/src/wasm2js.h b/src/wasm2js.h
index e9090d756..4aef8c378 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -2255,6 +2255,10 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
unimplemented(curr);
WASM_UNREACHABLE("unimp");
}
+ Ref visitTableCopy(TableCopy* curr) {
+ unimplemented(curr);
+ WASM_UNREACHABLE("unimp");
+ }
Ref visitTry(Try* curr) {
unimplemented(curr);
WASM_UNREACHABLE("unimp");
diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt
index b1f6dab55..062f05202 100644
--- a/test/binaryen.js/exception-handling.js.txt
+++ b/test/binaryen.js/exception-handling.js.txt
@@ -34,7 +34,7 @@
)
)
-getExpressionInfo(throw) = {"id":51,"type":1,"tag":"e"}
-getExpressionInfo(rethrow) = {"id":52,"type":1,"target":"l0"}
-getExpressionInfo(try_catch) = {"id":50,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0}
-getExpressionInfo(try_delegate) = {"id":50,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0}
+getExpressionInfo(throw) = {"id":52,"type":1,"tag":"e"}
+getExpressionInfo(rethrow) = {"id":53,"type":1,"target":"l0"}
+getExpressionInfo(try_catch) = {"id":51,"type":1,"name":"l0","hasCatchAll":0,"delegateTarget":"","isDelegate":0}
+getExpressionInfo(try_delegate) = {"id":51,"type":0,"name":"try_outer","hasCatchAll":1,"delegateTarget":"","isDelegate":0}
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index 313d51efa..de465a5d3 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -82,40 +82,40 @@ TableGetId: 45
TableSetId: 46
TableSizeId: 47
TableGrowId: 48
-TryId: 50
-ThrowId: 51
-RethrowId: 52
-TupleMakeId: 53
-TupleExtractId: 54
-RefI31Id: 55
-I31GetId: 56
-CallRefId: 57
-RefTestId: 58
-RefCastId: 59
-BrOnId: 60
-StructNewId: 61
-StructGetId: 62
-StructSetId: 63
-ArrayNewId: 64
-ArrayNewFixedId: 67
-ArrayGetId: 68
-ArraySetId: 69
-ArrayLenId: 70
-ArrayCopy: 71
-RefAs: 75
-StringNew: 76
-StringConst: 77
-StringMeasure: 78
-StringEncode: 79
-StringConcat: 80
-StringEq: 81
-StringAs: 82
-StringWTF8Advance: 83
-StringWTF16Get: 84
-StringIterNext: 85
-StringIterMove: 86
-StringSliceWTF: 87
-StringSliceIter: 88
+TryId: 51
+ThrowId: 52
+RethrowId: 53
+TupleMakeId: 54
+TupleExtractId: 55
+RefI31Id: 56
+I31GetId: 57
+CallRefId: 58
+RefTestId: 59
+RefCastId: 60
+BrOnId: 61
+StructNewId: 62
+StructGetId: 63
+StructSetId: 64
+ArrayNewId: 65
+ArrayNewFixedId: 68
+ArrayGetId: 69
+ArraySetId: 70
+ArrayLenId: 71
+ArrayCopy: 72
+RefAs: 76
+StringNew: 77
+StringConst: 78
+StringMeasure: 79
+StringEncode: 80
+StringConcat: 81
+StringEq: 82
+StringAs: 83
+StringWTF8Advance: 84
+StringWTF16Get: 85
+StringIterNext: 86
+StringIterMove: 87
+StringSliceWTF: 88
+StringSliceIter: 89
getExpressionInfo={"id":15,"type":4,"op":6}
(f32.neg
(f32.const -33.61199951171875)
diff --git a/test/lit/passes/unsubtyping.wast b/test/lit/passes/unsubtyping.wast
index a82d601cc..836aec036 100644
--- a/test/lit/passes/unsubtyping.wast
+++ b/test/lit/passes/unsubtyping.wast
@@ -761,14 +761,14 @@
;; CHECK: (table $t 0 (ref null $super))
(table $t (ref null $super) 1 1)
- ;; CHECK: (func $table-set (type $2)
+ ;; CHECK: (func $table-fill (type $2)
;; CHECK-NEXT: (table.fill $t
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (struct.new_default $sub)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- (func $table-set
+ (func $table-fill
;; This requires $sub <: $super.
(table.fill $t
(i32.const 0)
@@ -780,6 +780,38 @@
(module
;; CHECK: (rec
+ ;; CHECK-NEXT: (type $0 (func))
+
+ ;; CHECK: (type $super (sub (struct )))
+ (type $super (sub (struct)))
+ ;; CHECK: (type $sub (sub $super (struct )))
+ (type $sub (sub $super (struct)))
+
+ ;; CHECK: (table $super 0 (ref null $super))
+ (table $super (ref null $super) 1 1)
+
+ ;; CHECK: (table $sub 0 (ref null $sub))
+ (table $sub (ref null $sub) 1 1)
+
+ ;; CHECK: (func $table-copy (type $0)
+ ;; CHECK-NEXT: (table.copy $super $sub
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $table-copy
+ ;; This requires $sub <: $super.
+ (table.copy $super $sub
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+)
+
+(module
+ ;; CHECK: (rec
;; CHECK-NEXT: (type $super (sub (struct )))
(type $super (sub (struct)))
;; CHECK: (type $sub (sub $super (struct )))
diff --git a/test/lit/table-operations.wast b/test/lit/table-operations.wast
index e3daa463b..f3aafe51a 100644
--- a/test/lit/table-operations.wast
+++ b/test/lit/table-operations.wast
@@ -18,6 +18,8 @@
;; CHECK-BINARY: (type $3 (func (param i32 funcref i32)))
+ ;; CHECK-BINARY: (type $4 (func (param i32 i32 i32)))
+
;; CHECK-BINARY: (table $table-1 1 1 funcref)
;; CHECK-TEXT: (type $0 (func))
@@ -27,6 +29,8 @@
;; CHECK-TEXT: (type $3 (func (param i32 funcref i32)))
+ ;; CHECK-TEXT: (type $4 (func (param i32 i32 i32)))
+
;; CHECK-TEXT: (table $table-1 1 1 funcref)
(table $table-1 funcref
(elem $foo)
@@ -173,6 +177,28 @@
(local.get $size)
)
)
+
+ ;; CHECK-BINARY: (func $table-copy (type $4) (param $dest i32) (param $source i32) (param $size i32)
+ ;; CHECK-BINARY-NEXT: (table.copy $table-1 $table-2
+ ;; CHECK-BINARY-NEXT: (local.get $dest)
+ ;; CHECK-BINARY-NEXT: (local.get $source)
+ ;; CHECK-BINARY-NEXT: (local.get $size)
+ ;; CHECK-BINARY-NEXT: )
+ ;; CHECK-BINARY-NEXT: )
+ ;; CHECK-TEXT: (func $table-copy (type $4) (param $dest i32) (param $source i32) (param $size i32)
+ ;; CHECK-TEXT-NEXT: (table.copy $table-1 $table-2
+ ;; CHECK-TEXT-NEXT: (local.get $dest)
+ ;; CHECK-TEXT-NEXT: (local.get $source)
+ ;; CHECK-TEXT-NEXT: (local.get $size)
+ ;; CHECK-TEXT-NEXT: )
+ ;; CHECK-TEXT-NEXT: )
+ (func $table-copy (param $dest i32) (param $source i32) (param $size i32)
+ (table.copy $table-1 $table-2
+ (local.get $dest)
+ (local.get $source)
+ (local.get $size)
+ )
+ )
)
;; CHECK-NODEBUG: (type $0 (func))
@@ -182,6 +208,8 @@
;; CHECK-NODEBUG: (type $3 (func (param i32 funcref i32)))
+;; CHECK-NODEBUG: (type $4 (func (param i32 i32 i32)))
+
;; CHECK-NODEBUG: (table $0 1 1 funcref)
;; CHECK-NODEBUG: (table $1 3 3 funcref)
@@ -237,3 +265,11 @@
;; CHECK-NODEBUG-NEXT: (local.get $2)
;; CHECK-NODEBUG-NEXT: )
;; CHECK-NODEBUG-NEXT: )
+
+;; CHECK-NODEBUG: (func $6 (type $4) (param $0 i32) (param $1 i32) (param $2 i32)
+;; CHECK-NODEBUG-NEXT: (table.copy $0 $1
+;; CHECK-NODEBUG-NEXT: (local.get $0)
+;; CHECK-NODEBUG-NEXT: (local.get $1)
+;; CHECK-NODEBUG-NEXT: (local.get $2)
+;; CHECK-NODEBUG-NEXT: )
+;; CHECK-NODEBUG-NEXT: )
diff --git a/test/spec/table_copy.wast b/test/spec/table_copy.wast
new file mode 100644
index 000000000..a23dbcba5
--- /dev/null
+++ b/test/spec/table_copy.wast
@@ -0,0 +1,2216 @@
+(module
+ (func (export "ef0") (result i32) (i32.const 0))
+ (func (export "ef1") (result i32) (i32.const 1))
+ (func (export "ef2") (result i32) (i32.const 2))
+ (func (export "ef3") (result i32) (i32.const 3))
+ (func (export "ef4") (result i32) (i32.const 4))
+)
+(register "a")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (nop))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 13) (i32.const 2) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 25) (i32.const 15) (i32.const 2)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 25)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 26)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 13) (i32.const 25) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_trap (invoke "check_t0" (i32.const 13)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 14)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 15)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 20) (i32.const 22) (i32.const 4)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 25) (i32.const 1) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 26)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 27)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 10) (i32.const 12) (i32.const 7)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 10)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 11)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 15)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 12) (i32.const 10) (i32.const 7)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 12)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 13)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 17)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 18)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t1) (i32.const 3) func 1 3 1 4)
+ (elem (table $t1) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 10) (i32.const 0) (i32.const 20)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 4))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 1))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 22)) (i32.const 7))
+(assert_return (invoke "check_t1" (i32.const 23)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 24)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 25)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 26)) (i32.const 6))
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (nop))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 13) (i32.const 2) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 25) (i32.const 15) (i32.const 2)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 25)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 26)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 13) (i32.const 25) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_trap (invoke "check_t0" (i32.const 13)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 14)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 15)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 20) (i32.const 22) (i32.const 4)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 25) (i32.const 1) (i32.const 3)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 26)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 27)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 10) (i32.const 12) (i32.const 7)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 10)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 11)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 15)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t1 $t1 (i32.const 12) (i32.const 10) (i32.const 7)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 12)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 13)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 17)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 18)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 11)) (i32.const 6))
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 7))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (type (func (result i32))) ;; type #0
+ (import "a" "ef0" (func (result i32))) ;; index 0
+ (import "a" "ef1" (func (result i32)))
+ (import "a" "ef2" (func (result i32)))
+ (import "a" "ef3" (func (result i32)))
+ (import "a" "ef4" (func (result i32))) ;; index 4
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t1) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t1) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (elem (table $t0) (i32.const 3) func 1 3 1 4)
+ (elem (table $t0) (i32.const 11) func 6 3 2 5 7)
+ (func (result i32) (i32.const 5)) ;; index 5
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9)) ;; index 9
+ (func (export "test")
+ (table.copy $t0 $t1 (i32.const 10) (i32.const 0) (i32.const 20)))
+ (func (export "check_t0") (param i32) (result i32)
+ (call_indirect $t1 (type 0) (local.get 0)))
+ (func (export "check_t1") (param i32) (result i32)
+ (call_indirect $t0 (type 0) (local.get 0)))
+)
+
+(invoke "test")
+(assert_trap (invoke "check_t0" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 1)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 2)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t0" (i32.const 4)) (i32.const 4))
+(assert_return (invoke "check_t0" (i32.const 5)) (i32.const 1))
+(assert_trap (invoke "check_t0" (i32.const 6)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t0" (i32.const 12)) (i32.const 7))
+(assert_return (invoke "check_t0" (i32.const 13)) (i32.const 5))
+(assert_return (invoke "check_t0" (i32.const 14)) (i32.const 2))
+(assert_return (invoke "check_t0" (i32.const 15)) (i32.const 3))
+(assert_return (invoke "check_t0" (i32.const 16)) (i32.const 6))
+(assert_trap (invoke "check_t0" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 21)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 22)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 23)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 24)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 25)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 26)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t0" (i32.const 29)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 0)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 1)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 2)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 3)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 4)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 5)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 6)) (i32.const 4))
+(assert_trap (invoke "check_t1" (i32.const 7)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 8)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 9)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 10)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 11)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 12)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 13)) (i32.const 1))
+(assert_return (invoke "check_t1" (i32.const 14)) (i32.const 4))
+(assert_return (invoke "check_t1" (i32.const 15)) (i32.const 1))
+(assert_trap (invoke "check_t1" (i32.const 16)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 17)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 18)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 19)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 20)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 21)) "uninitialized element")
+(assert_return (invoke "check_t1" (i32.const 22)) (i32.const 7))
+(assert_return (invoke "check_t1" (i32.const 23)) (i32.const 5))
+(assert_return (invoke "check_t1" (i32.const 24)) (i32.const 2))
+(assert_return (invoke "check_t1" (i32.const 25)) (i32.const 3))
+(assert_return (invoke "check_t1" (i32.const 26)) (i32.const 6))
+(assert_trap (invoke "check_t1" (i32.const 27)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element")
+(assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 28) (i32.const 1) (i32.const 3))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 0xFFFFFFFE) (i32.const 1) (i32.const 2))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 15) (i32.const 25) (i32.const 6))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 15) (i32.const 0xFFFFFFFE) (i32.const 2))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 15) (i32.const 25) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 30) (i32.const 15) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 31) (i32.const 15) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 15) (i32.const 30) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 15) (i32.const 31) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 30) (i32.const 30) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t0 $t0 (i32.const 31) (i32.const 31) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 28) (i32.const 1) (i32.const 3))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 0xFFFFFFFE) (i32.const 1) (i32.const 2))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 15) (i32.const 25) (i32.const 6))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 15) (i32.const 0xFFFFFFFE) (i32.const 2))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 15) (i32.const 25) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 30) (i32.const 15) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 31) (i32.const 15) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 15) (i32.const 30) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 15) (i32.const 31) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 30) (i32.const 30) (i32.const 0))
+ ))
+
+(invoke "test")
+
+(module
+ (table $t0 30 30 funcref)
+ (table $t1 30 30 funcref)
+ (elem (table $t0) (i32.const 2) func 3 1 4 1)
+ (elem funcref
+ (ref.func 2) (ref.func 7) (ref.func 1) (ref.func 8))
+ (elem (table $t0) (i32.const 12) func 7 5 2 3 6)
+ (elem funcref
+ (ref.func 5) (ref.func 9) (ref.func 2) (ref.func 7) (ref.func 6))
+ (func (result i32) (i32.const 0))
+ (func (result i32) (i32.const 1))
+ (func (result i32) (i32.const 2))
+ (func (result i32) (i32.const 3))
+ (func (result i32) (i32.const 4))
+ (func (result i32) (i32.const 5))
+ (func (result i32) (i32.const 6))
+ (func (result i32) (i32.const 7))
+ (func (result i32) (i32.const 8))
+ (func (result i32) (i32.const 9))
+ (func (export "test")
+ (table.copy $t1 $t0 (i32.const 31) (i32.const 31) (i32.const 0))
+ ))
+
+(assert_trap (invoke "test") "out of bounds table access")
+
+;; TODO: add remaining parts that do not pass yet