summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/asm2wasm.h1
-rw-r--r--src/binaryen-c.cpp1
-rw-r--r--src/passes/Print.cpp6
-rw-r--r--src/shared-constants.h2
-rw-r--r--src/wasm-binary.h1
-rw-r--r--src/wasm-linker.cpp3
-rw-r--r--src/wasm-s-parser.h25
-rw-r--r--src/wasm.cpp2
-rw-r--r--src/wasm.h5
-rw-r--r--test/dot_s/alias.wast3
-rw-r--r--test/dot_s/basics.wast3
-rw-r--r--test/dot_s/bcp-1.wast3
-rw-r--r--test/dot_s/dyncall.wast3
-rw-r--r--test/dot_s/indidx.wast3
-rw-r--r--test/dot_s/indirect-import.wast3
-rw-r--r--test/dot_s/invoke_wrapper.wast3
-rw-r--r--test/emcc_O2_hello_world.fromasm3
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise3
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise.no-opts3
-rw-r--r--test/emcc_O2_hello_world.fromasm.no-opts3
-rw-r--r--test/emcc_hello_world.fromasm3
-rw-r--r--test/emcc_hello_world.fromasm.imprecise3
-rw-r--r--test/emcc_hello_world.fromasm.imprecise.no-opts3
-rw-r--r--test/emcc_hello_world.fromasm.no-opts3
-rw-r--r--test/example/c-api-kitchen-sink.txt6
-rw-r--r--test/example/c-api-kitchen-sink.txt.txt3
-rw-r--r--test/memorygrowth.fromasm3
-rw-r--r--test/memorygrowth.fromasm.imprecise3
-rw-r--r--test/memorygrowth.fromasm.imprecise.no-opts3
-rw-r--r--test/memorygrowth.fromasm.no-opts3
-rw-r--r--test/passes/dce.txt3
-rw-r--r--test/passes/duplicate-function-elimination.txt12
-rw-r--r--test/passes/remove-unused-functions.txt3
-rw-r--r--test/passes/remove-unused-names_merge-blocks.txt3
-rw-r--r--test/unit.fromasm3
-rw-r--r--test/unit.fromasm.imprecise3
-rw-r--r--test/unit.fromasm.imprecise.no-opts3
-rw-r--r--test/unit.fromasm.no-opts3
-rw-r--r--test/unit.wast3
-rw-r--r--test/unit.wast.fromBinary3
40 files changed, 114 insertions, 37 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index c0f13ff8f..868aa31d3 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -666,6 +666,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
IString curr = contents[k][1]->getIString();
wasm.table.names.push_back(curr);
}
+ wasm.table.initial = wasm.table.max = wasm.table.names.size();
} else {
abort_on("invalid var element", pair);
}
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index b0e241ab3..d7f866663 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -732,6 +732,7 @@ void BinaryenSetFunctionTable(BinaryenModuleRef module, BinaryenFunctionRef* fun
for (BinaryenIndex i = 0; i < numFuncs; i++) {
wasm->table.names.push_back(((Function*)funcs[i])->name);
}
+ wasm->table.initial = wasm->table.max = wasm->table.names.size();
}
// Memory. One per module
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index eb97eead5..711cc8a84 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -575,7 +575,11 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
decIndent();
}
void visitTable(Table *curr) {
- printOpening(o, "table");
+ printOpening(o, "table") << ' ' << curr->initial;
+ if (curr->max && curr->max != Table::kMaxSize) o << ' ' << curr->max;
+ o << " anyfunc)\n";
+ doIndent(o, indent);
+ printOpening(o, "elem", true);
for (auto name : curr->names) {
o << ' ';
printName(name);
diff --git a/src/shared-constants.h b/src/shared-constants.h
index 8599d8144..f0148cb67 100644
--- a/src/shared-constants.h
+++ b/src/shared-constants.h
@@ -29,6 +29,7 @@ extern Name GROW_WASM_MEMORY,
EXPORT,
IMPORT,
TABLE,
+ ELEM,
LOCAL,
TYPE,
CALL,
@@ -44,6 +45,7 @@ extern Name GROW_WASM_MEMORY,
NEG_NAN,
CASE,
BR,
+ ANYFUNC,
FAKE_RETURN,
ASSERT_RETURN,
ASSERT_TRAP,
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index b67a79c3d..d405c91dc 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1648,6 +1648,7 @@ public:
assert(index < wasm.functions.size());
wasm.table.names.push_back(wasm.functions[index]->name);
}
+ wasm.table.initial = wasm.table.max = wasm.table.names.size();
}
void readDataSegments() {
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp
index 1f06c6ec2..29f439bfb 100644
--- a/src/wasm-linker.cpp
+++ b/src/wasm-linker.cpp
@@ -223,6 +223,9 @@ void Linker::layout() {
if (out.symbolInfo.implementedFunctions.count("free")) {
exportFunction("free", true);
}
+
+ // finalize function table
+ out.wasm.table.initial = out.wasm.table.max = out.wasm.table.names.size();
}
bool Linker::linkObject(S2WasmBuilder& builder) {
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 87217cd20..7f652da5a 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -372,6 +372,7 @@ private:
if (id == IMPORT) return; // already done
if (id == GLOBAL) return parseGlobal(curr);
if (id == TABLE) return parseTable(curr);
+ if (id == ELEM) return parseElem(curr);
if (id == TYPE) return; // already done
std::cerr << "bad module element " << id.str << '\n';
throw ParseException("unknown module element", curr.line, curr.col);
@@ -1424,7 +1425,29 @@ private:
}
void parseTable(Element& s) {
- for (size_t i = 1; i < s.size(); i++) {
+ if (s.size() == 1) return; // empty table in old notation
+ if (!s[1]->dollared()) {
+ if (s[1]->str() == ANYFUNC) {
+ // (table type (elem ..))
+ parseElem(*s[2]);
+ wasm.table.initial = wasm.table.max = wasm.table.names.size();
+ return;
+ }
+ // first element isn't dollared, and isn't anyfunc. this could be old syntax for (table 0 1) which means function 0 and 1, or it could be (table initial max? type), look for type
+ if (s[s.size() - 1]->str() == ANYFUNC) {
+ // (table initial max? type)
+ wasm.table.initial = atoi(s[1]->c_str());
+ wasm.table.max = atoi(s[2]->c_str());
+ return;
+ }
+ }
+ // old notation (table func1 func2 ..)
+ parseElem(s);
+ wasm.table.initial = wasm.table.max = wasm.table.names.size();
+ }
+
+ void parseElem(Element& s) {
+ for (Index i = 1; i < s.size(); i++) {
wasm.table.names.push_back(getFunctionName(*s[i]));
}
}
diff --git a/src/wasm.cpp b/src/wasm.cpp
index 2138ec34d..8cfdee759 100644
--- a/src/wasm.cpp
+++ b/src/wasm.cpp
@@ -54,6 +54,7 @@ Name GROW_WASM_MEMORY("__growWasmMemory"),
EXPORT("export"),
IMPORT("import"),
TABLE("table"),
+ ELEM("elem"),
LOCAL("local"),
TYPE("type"),
CALL("call"),
@@ -69,6 +70,7 @@ Name GROW_WASM_MEMORY("__growWasmMemory"),
NEG_NAN("-nan"),
CASE("case"),
BR("br"),
+ ANYFUNC("anyfunc"),
FAKE_RETURN("fake_return_waka123"),
ASSERT_RETURN("assert_return"),
ASSERT_TRAP("assert_trap"),
diff --git a/src/wasm.h b/src/wasm.h
index c0129cf23..82933bda0 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1432,7 +1432,12 @@ public:
class Table {
public:
+ static const Index kMaxSize = Index(-1);
+
+ Address initial, max;
std::vector<Name> names;
+
+ Table() : initial(0), max(kMaxSize) {}
};
class Memory {
diff --git a/test/dot_s/alias.wast b/test/dot_s/alias.wast
index bd114b9dc..ab52137a1 100644
--- a/test/dot_s/alias.wast
+++ b/test/dot_s/alias.wast
@@ -6,7 +6,8 @@
(export "__exit" $__exit)
(export "__needs_exit" $__needs_exit)
(export "dynCall_v" $dynCall_v)
- (table $__wasm_nullptr $__exit)
+ (table 2 2 anyfunc)
+ (elem $__wasm_nullptr $__exit)
(func $__exit (type $FUNCSIG$v)
(return
(i32.add
diff --git a/test/dot_s/basics.wast b/test/dot_s/basics.wast
index 7b13be3d8..e4cd73251 100644
--- a/test/dot_s/basics.wast
+++ b/test/dot_s/basics.wast
@@ -10,7 +10,8 @@
(import $puts "env" "puts" (param i32))
(export "main" $main)
(export "dynCall_iii" $dynCall_iii)
- (table $__wasm_nullptr $main)
+ (table 2 2 anyfunc)
+ (elem $__wasm_nullptr $main)
(func $main (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(call_import $puts
(i32.const 16)
diff --git a/test/dot_s/bcp-1.wast b/test/dot_s/bcp-1.wast
index c090d90e5..a5a63d750 100644
--- a/test/dot_s/bcp-1.wast
+++ b/test/dot_s/bcp-1.wast
@@ -34,7 +34,8 @@
(export "main" $main)
(export "dynCall_i" $dynCall_i)
(export "dynCall_ii" $dynCall_ii)
- (table $__wasm_nullptr $bad0 $bad1 $bad5 $bad7 $bad8 $bad10 $bad2 $bad3 $bad6 $bad4 $bad9 $good0 $good1 $good2 $opt0 $opt1 $opt2)
+ (table 18 18 anyfunc)
+ (elem $__wasm_nullptr $bad0 $bad1 $bad5 $bad7 $bad8 $bad10 $bad2 $bad3 $bad6 $bad4 $bad9 $good0 $good1 $good2 $opt0 $opt1 $opt2)
(func $bad0 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
diff --git a/test/dot_s/dyncall.wast b/test/dot_s/dyncall.wast
index e284c838d..f349bce7f 100644
--- a/test/dot_s/dyncall.wast
+++ b/test/dot_s/dyncall.wast
@@ -15,7 +15,8 @@
(export "dynCall_i" $dynCall_i)
(export "dynCall_if" $dynCall_if)
(export "dynCall_vd" $dynCall_vd)
- (table $__wasm_nullptr $i $i_f $vd $ffjjdi $vd2)
+ (table 6 6 anyfunc)
+ (elem $__wasm_nullptr $i $i_f $vd $ffjjdi $vd2)
(func $i (type $FUNCSIG$i) (result i32)
(i32.const 0)
)
diff --git a/test/dot_s/indidx.wast b/test/dot_s/indidx.wast
index 5fb481197..797183b04 100644
--- a/test/dot_s/indidx.wast
+++ b/test/dot_s/indidx.wast
@@ -7,7 +7,8 @@
(import $getchar "env" "getchar" (result i32))
(export "main" $main)
(export "dynCall_i" $dynCall_i)
- (table $__wasm_nullptr $c $b $d $a)
+ (table 5 5 anyfunc)
+ (elem $__wasm_nullptr $c $b $d $a)
(func $a (type $FUNCSIG$i) (result i32)
(i32.const 0)
)
diff --git a/test/dot_s/indirect-import.wast b/test/dot_s/indirect-import.wast
index 22821a4e0..8c8c3e01c 100644
--- a/test/dot_s/indirect-import.wast
+++ b/test/dot_s/indirect-import.wast
@@ -17,7 +17,8 @@
(export "dynCall_fd" $dynCall_fd)
(export "dynCall_v" $dynCall_v)
(export "dynCall_vi" $dynCall_vi)
- (table $__wasm_nullptr $__importThunk_extern_fd $__importThunk_extern_vj $__importThunk_extern_v $__importThunk_extern_ijidf $__importThunk_extern_struct $__importThunk_extern_sret)
+ (table 7 7 anyfunc)
+ (elem $__wasm_nullptr $__importThunk_extern_fd $__importThunk_extern_vj $__importThunk_extern_v $__importThunk_extern_ijidf $__importThunk_extern_struct $__importThunk_extern_sret)
(func $bar (result i32)
(local $0 i32)
(local $1 i32)
diff --git a/test/dot_s/invoke_wrapper.wast b/test/dot_s/invoke_wrapper.wast
index 6aa7a4ce6..c4a6d5931 100644
--- a/test/dot_s/invoke_wrapper.wast
+++ b/test/dot_s/invoke_wrapper.wast
@@ -17,7 +17,8 @@
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_ffd" $dynCall_ffd)
(export "dynCall_iii" $dynCall_iii)
- (table $__wasm_nullptr $_Z5func1v $_Z5func2iii $_Z5func3fd $_Z5func4P8mystructS_)
+ (table 5 5 anyfunc)
+ (elem $__wasm_nullptr $_Z5func1v $_Z5func2iii $_Z5func3fd $_Z5func4P8mystructS_)
(func $_Z5func1v (type $FUNCSIG$v)
)
(func $_Z5func2iii (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index 828905561..a324f42ba 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -42,7 +42,8 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(func $_malloc (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index ede6c05d4..127b7f77f 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -41,7 +41,8 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(func $_malloc (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
index d34022a9e..6822928b3 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
@@ -41,7 +41,8 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(func $_malloc (param $i1 i32) (result i32)
(local $i2 i32)
(local $i3 i32)
diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts
index f850b8306..6c6ad73c7 100644
--- a/test/emcc_O2_hello_world.fromasm.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.no-opts
@@ -42,7 +42,8 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $b1 $___stdio_write $b1 $b1 $b2 $b2 $b2 $b2 $_cleanup_418 $b2 $b2 $b2)
(func $_malloc (param $i1 i32) (result i32)
(local $i2 i32)
(local $i3 i32)
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index c99290ba8..9d4993ec3 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -55,7 +55,8 @@
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
(export "___udivmoddi4" $___udivmoddi4)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $0 i32) (result i32)
(local $1 i32)
(set_local $1
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index ee84765a1..6c9047895 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -49,7 +49,8 @@
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
(export "___udivmoddi4" $___udivmoddi4)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $0 i32) (result i32)
(local $1 i32)
(set_local $1
diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts
index 327618169..35e23d120 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -49,7 +49,8 @@
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
(export "___udivmoddi4" $___udivmoddi4)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $size i32) (result i32)
(local $ret i32)
(set_local $ret
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index 41e3e9e26..27409fe49 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -55,7 +55,8 @@
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
(export "___udivmoddi4" $___udivmoddi4)
- (table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
+ (table 18 18 anyfunc)
+ (elem $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $size i32) (result i32)
(local $ret i32)
(set_local $ret
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index c8f123bdd..6b766f173 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -17,7 +17,8 @@ BinaryenFloat64: 4
(type $3 (func))
(import $an-imported "module" "base" (param i32 f64) (result f32))
(export "kitchen_sinker" "$kitchen()sinker")
- (table "$kitchen()sinker")
+ (table 1 1 anyfunc)
+ (elem "$kitchen()sinker")
(func "$kitchen()sinker" (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32)
(local $4 i32)
(block $the-body
@@ -1409,7 +1410,8 @@ int main() {
(type $3 (func))
(import $an-imported "module" "base" (param i32 f64) (result f32))
(export "kitchen_sinker" "$kitchen()sinker")
- (table "$kitchen()sinker")
+ (table 1 1 anyfunc)
+ (elem "$kitchen()sinker")
(func "$kitchen()sinker" (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32)
(local $4 i32)
(block $the-body
diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt
index 24dcc8a5c..feae7152c 100644
--- a/test/example/c-api-kitchen-sink.txt.txt
+++ b/test/example/c-api-kitchen-sink.txt.txt
@@ -12,7 +12,8 @@
(type $3 (func))
(import $an-imported "module" "base" (param i32 f64) (result f32))
(export "kitchen_sinker" "$kitchen()sinker")
- (table "$kitchen()sinker")
+ (table 1 1 anyfunc)
+ (elem "$kitchen()sinker")
(func "$kitchen()sinker" (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32)
(local $4 i32)
(block $the-body
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index 5c005ba99..ee6b3ae68 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -40,7 +40,8 @@
(export "dynCall_iiii" $lb)
(export "dynCall_vi" $mb)
(export "__growWasmMemory" $__growWasmMemory)
- (table $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (table 8 8 anyfunc)
+ (elem $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index b70bc7c9e..458ab8f8f 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -39,7 +39,8 @@
(export "dynCall_iiii" $lb)
(export "dynCall_vi" $mb)
(export "__growWasmMemory" $__growWasmMemory)
- (table $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (table 8 8 anyfunc)
+ (elem $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts
index dd03e651e..c30a5933b 100644
--- a/test/memorygrowth.fromasm.imprecise.no-opts
+++ b/test/memorygrowth.fromasm.imprecise.no-opts
@@ -39,7 +39,8 @@
(export "dynCall_iiii" $lb)
(export "dynCall_vi" $mb)
(export "__growWasmMemory" $__growWasmMemory)
- (table $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (table 8 8 anyfunc)
+ (elem $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $a i32) (result i32)
(local $b i32)
(local $c i32)
diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts
index 29aa4aa30..3abed2662 100644
--- a/test/memorygrowth.fromasm.no-opts
+++ b/test/memorygrowth.fromasm.no-opts
@@ -40,7 +40,8 @@
(export "dynCall_iiii" $lb)
(export "dynCall_vi" $mb)
(export "__growWasmMemory" $__growWasmMemory)
- (table $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
+ (table 8 8 anyfunc)
+ (elem $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $a i32) (result i32)
(local $b i32)
(local $c i32)
diff --git a/test/passes/dce.txt b/test/passes/dce.txt
index 692a5005e..9c2836123 100644
--- a/test/passes/dce.txt
+++ b/test/passes/dce.txt
@@ -2,7 +2,8 @@
(memory 10)
(type $ii (func (param i32 i32)))
(type $1 (func))
- (table $call-me)
+ (table 1 1 anyfunc)
+ (elem $call-me)
(func $call-me (type $ii) (param $0 i32) (param $1 i32)
(nop)
)
diff --git a/test/passes/duplicate-function-elimination.txt b/test/passes/duplicate-function-elimination.txt
index 3671ce24b..6c64b081c 100644
--- a/test/passes/duplicate-function-elimination.txt
+++ b/test/passes/duplicate-function-elimination.txt
@@ -38,7 +38,8 @@
(type $0 (func))
(export "keep2" $keep2)
(export "other" $keep2)
- (table $keep2 $keep2 $caller)
+ (table 3 3 anyfunc)
+ (elem $keep2 $keep2 $caller)
(func $keep2 (type $0)
(nop)
)
@@ -363,7 +364,8 @@
(module
(memory 0)
(type $T (func))
- (table $erase $erase)
+ (table 2 2 anyfunc)
+ (elem $erase $erase)
(func $erase (type $T)
(call_indirect $T
(i32.const 0)
@@ -373,7 +375,8 @@
(module
(memory 0)
(type $T (func))
- (table $keep2 $other)
+ (table 2 2 anyfunc)
+ (elem $keep2 $other)
(func $keep2 (type $T)
(call_indirect $T
(i32.const 0)
@@ -389,7 +392,8 @@
(memory 0)
(type $T (func))
(type $S (func))
- (table $keep2 $other)
+ (table 2 2 anyfunc)
+ (elem $keep2 $other)
(func $keep2 (type $T)
(call_indirect $T
(i32.const 0)
diff --git a/test/passes/remove-unused-functions.txt b/test/passes/remove-unused-functions.txt
index b6f7cf3e1..6aa8e3265 100644
--- a/test/passes/remove-unused-functions.txt
+++ b/test/passes/remove-unused-functions.txt
@@ -3,7 +3,8 @@
(start $start)
(type $0 (func))
(export "exported" $exported)
- (table $called_indirect)
+ (table 1 1 anyfunc)
+ (elem $called_indirect)
(func $start (type $0)
(call $called0)
)
diff --git a/test/passes/remove-unused-names_merge-blocks.txt b/test/passes/remove-unused-names_merge-blocks.txt
index fe5bd5cf8..ead2c99ca 100644
--- a/test/passes/remove-unused-names_merge-blocks.txt
+++ b/test/passes/remove-unused-names_merge-blocks.txt
@@ -4,7 +4,8 @@
(type $ii (func (param i32 i32)))
(type $iii (func (param i32 i32 i32)))
(type $3 (func))
- (table $call-i)
+ (table 1 1 anyfunc)
+ (elem $call-i)
(func $call-i (type $i) (param $0 i32)
(nop)
)
diff --git a/test/unit.fromasm b/test/unit.fromasm
index f939782e7..e292f47ae 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -15,7 +15,8 @@
(import $i32u-div "asm2wasm" "i32u-div" (param i32 i32) (result i32))
(export "big_negative" $big_negative)
(export "pick" $big_negative)
- (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg)
+ (table 10 10 anyfunc)
+ (elem $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg)
(func $big_negative
(nop)
)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index f80f4ce6c..ef3c09ff0 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -11,7 +11,8 @@
(import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64))
(export "big_negative" $big_negative)
(export "pick" $big_negative)
- (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg)
+ (table 10 10 anyfunc)
+ (elem $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg)
(func $big_negative
(nop)
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 4fa627938..cde7eb176 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -11,7 +11,8 @@
(import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64))
(export "big_negative" $big_negative)
(export "pick" $exportMe)
- (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (table 10 10 anyfunc)
+ (elem $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative
(local $temp f64)
(set_local $temp
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index c10bd3dff..c0650ebd5 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -15,7 +15,8 @@
(import $i32u-div "asm2wasm" "i32u-div" (param i32 i32) (result i32))
(export "big_negative" $big_negative)
(export "pick" $exportMe)
- (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (table 10 10 anyfunc)
+ (elem $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative
(local $temp f64)
(set_local $temp
diff --git a/test/unit.wast b/test/unit.wast
index b18ba6fdf..30d16d1a2 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -13,7 +13,8 @@
(import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32))
(import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64))
(export "big_negative" $big_negative)
- (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (table 10 anyfunc)
+ (elem $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative (type $FUNCSIG$v)
(local $temp f64)
(block $block0
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index 495b3daed..4348394af 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -13,7 +13,8 @@
(import $import$1 "asm2wasm" "f64-to-int" (param f64) (result i32))
(import $import$2 "asm2wasm" "f64-rem" (param f64 f64) (result f64))
(export "big_negative" $big_negative)
- (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (table 10 10 anyfunc)
+ (elem $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative (type $1)
(local $var$0 f64)
(block $label$0