summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-09-20 13:45:16 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-20 13:45:16 -0700
commit947cd3f224623f2d1e76f3c6cc30487ea8fd79ef (patch)
tree084235cae91bc812f2bd31c58c75a5c9fccb7a2d
parent2aa7ba43b59782243cd4960df43c7936292c41f4 (diff)
downloadbinaryen-947cd3f224623f2d1e76f3c6cc30487ea8fd79ef.tar.gz
binaryen-947cd3f224623f2d1e76f3c6cc30487ea8fd79ef.tar.bz2
binaryen-947cd3f224623f2d1e76f3c6cc30487ea8fd79ef.zip
memory and table printing fixes
-rw-r--r--src/passes/Print.cpp44
-rw-r--r--test/emcc_O2_hello_world.fromasm6
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise6
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise.no-opts6
-rw-r--r--test/emcc_O2_hello_world.fromasm.no-opts6
-rw-r--r--test/emcc_hello_world.fromasm6
-rw-r--r--test/emcc_hello_world.fromasm.imprecise6
-rw-r--r--test/emcc_hello_world.fromasm.imprecise.no-opts6
-rw-r--r--test/emcc_hello_world.fromasm.no-opts6
-rw-r--r--test/empty.fromasm5
-rw-r--r--test/empty.fromasm.imprecise5
-rw-r--r--test/empty.fromasm.imprecise.no-opts5
-rw-r--r--test/empty.fromasm.no-opts5
-rw-r--r--test/hello_world.fromasm5
-rw-r--r--test/hello_world.fromasm.imprecise5
-rw-r--r--test/hello_world.fromasm.imprecise.no-opts5
-rw-r--r--test/hello_world.fromasm.no-opts5
-rw-r--r--test/memorygrowth.fromasm6
-rw-r--r--test/memorygrowth.fromasm.imprecise6
-rw-r--r--test/memorygrowth.fromasm.imprecise.no-opts6
-rw-r--r--test/memorygrowth.fromasm.no-opts6
-rw-r--r--test/min.fromasm5
-rw-r--r--test/min.fromasm.imprecise5
-rw-r--r--test/min.fromasm.imprecise.no-opts5
-rw-r--r--test/min.fromasm.no-opts5
-rw-r--r--test/two_sides.fromasm5
-rw-r--r--test/two_sides.fromasm.imprecise5
-rw-r--r--test/two_sides.fromasm.imprecise.no-opts5
-rw-r--r--test/two_sides.fromasm.no-opts5
-rw-r--r--test/unit.fromasm6
-rw-r--r--test/unit.fromasm.imprecise6
-rw-r--r--test/unit.fromasm.imprecise.no-opts6
-rw-r--r--test/unit.fromasm.no-opts6
33 files changed, 100 insertions, 120 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 06a8758c5..363147b98 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -540,8 +540,8 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
printText(o, curr->base.str) << ' ';
switch (curr->kind) {
case Export::Function: if (curr->functionType) visitFunctionType(curr->functionType, &curr->name); break;
- case Export::Table: o << "(table " << curr->name << ")"; break;
- case Export::Memory: o << "(memory " << curr->name << ")"; break;
+ case Export::Table: printTableHeader(&currModule->table); break;
+ case Export::Memory: printMemoryHeader(&currModule->memory); break;
case Export::Global: o << "(global " << curr->name << ' ' << printWasmType(curr->globalType) << ")"; break;
default: WASM_UNREACHABLE();
}
@@ -606,11 +606,26 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
}
decIndent();
}
- void visitTable(Table *curr) {
+ void printTableHeader(Table* curr) {
printOpening(o, "table") << ' ';
o << curr->initial;
if (curr->max && curr->max != Table::kMaxSize) o << ' ' << curr->max;
- o << " anyfunc)\n";
+ o << " anyfunc)";
+ }
+ void visitTable(Table *curr) {
+ // if table wasn't imported, declare it
+ bool found = false;
+ for (auto& import : currModule->imports) {
+ if (import->kind == Import::Table) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ doIndent(o, indent);
+ printTableHeader(curr);
+ o << '\n';
+ }
doIndent(o, indent);
for (auto& segment : curr->segments) {
printOpening(o, "elem ", true);
@@ -622,11 +637,26 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
o << ')';
}
}
- void visitMemory(Memory* curr) {
+ void printMemoryHeader(Memory* curr) {
printOpening(o, "memory") << ' ';
o << curr->initial;
if (curr->max && curr->max != Memory::kMaxSize) o << ' ' << curr->max;
- o << ")\n";
+ o << ")";
+ }
+ void visitMemory(Memory* curr) {
+ // if memory wasn't imported, declare it
+ bool found = false;
+ for (auto& import : currModule->imports) {
+ if (import->kind == Import::Memory) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ doIndent(o, indent);
+ printMemoryHeader(curr);
+ o << '\n';
+ }
for (auto segment : curr->segments) {
doIndent(o, indent);
printOpening(o, "data ", true);
@@ -659,7 +689,6 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
currModule = curr;
printOpening(o, "module", true);
incIndent();
- doIndent(o, indent);
visitMemory(&curr->memory);
if (curr->start.is()) {
doIndent(o, indent);
@@ -689,7 +718,6 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
o << maybeNewLine;
}
if (curr->table.segments.size() > 0 || curr->table.initial > 0 || curr->table.max != Table::kMaxSize) {
- doIndent(o, indent);
visitTable(&curr->table);
o << maybeNewLine;
}
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index 53a7cf917..624cd3fd1 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "emcc_O2_hello_world.asm.js")
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
@@ -30,8 +29,8 @@
(import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $_free))
@@ -82,7 +81,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index 603308902..7b84b9c38 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -28,8 +27,8 @@
(import "env" "___unlock" (func $___unlock (param i32)))
(import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $_free))
@@ -80,7 +79,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
index 97d2e41d0..0a5967f3e 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -28,8 +27,8 @@
(import "env" "___unlock" (func $___unlock (param i32)))
(import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $_free))
@@ -80,7 +79,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts
index 48340942f..f40a19522 100644
--- a/test/emcc_O2_hello_world.fromasm.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
@@ -29,8 +28,8 @@
(import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $_free))
@@ -81,7 +80,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 26e13e794..f2074155b 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "emcc_hello_world.asm.js")
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$id (func (param f64) (result i32)))
@@ -39,8 +38,8 @@
(import "asm2wasm" "i32s-rem" (func $i32s-rem (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-rem" (func $i32u-rem (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_i64Subtract" (func $_i64Subtract))
@@ -97,7 +96,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index e78774569..a43f347b1 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -32,8 +31,8 @@
(import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32)))
(import "env" "_sysconf" (func $_sysconf (param i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_i64Subtract" (func $_i64Subtract))
@@ -90,7 +89,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts
index e9335450b..fa62da5fd 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -32,8 +31,8 @@
(import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32)))
(import "env" "_sysconf" (func $_sysconf (param i32) (result i32)))
(import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_i64Subtract" (func $_i64Subtract))
@@ -90,7 +89,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index 9fa2a2895..6942c296b 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$id (func (param f64) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
@@ -38,8 +37,8 @@
(import "asm2wasm" "i32s-rem" (func $i32s-rem (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-rem" (func $i32u-rem (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 18 18 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_i64Subtract" (func $_i64Subtract))
@@ -96,7 +95,6 @@
(global $tempRet8 (mut i32) (i32.const 0))
(global $tempRet9 (mut i32) (i32.const 0))
(global $tempFloat (mut f64) (f64.const 0))
- (table 18 18 anyfunc)
(elem (i32.const 0) $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)
diff --git a/test/empty.fromasm b/test/empty.fromasm
index 67c1135d4..83d404801 100644
--- a/test/empty.fromasm
+++ b/test/empty.fromasm
@@ -1,8 +1,7 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "empty.asm.js")
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
)
diff --git a/test/empty.fromasm.imprecise b/test/empty.fromasm.imprecise
index 5fbd4b5f8..7e9ff6f81 100644
--- a/test/empty.fromasm.imprecise
+++ b/test/empty.fromasm.imprecise
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
)
diff --git a/test/empty.fromasm.imprecise.no-opts b/test/empty.fromasm.imprecise.no-opts
index 5fbd4b5f8..7e9ff6f81 100644
--- a/test/empty.fromasm.imprecise.no-opts
+++ b/test/empty.fromasm.imprecise.no-opts
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
)
diff --git a/test/empty.fromasm.no-opts b/test/empty.fromasm.no-opts
index 5fbd4b5f8..7e9ff6f81 100644
--- a/test/empty.fromasm.no-opts
+++ b/test/empty.fromasm.no-opts
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
)
diff --git a/test/hello_world.fromasm b/test/hello_world.fromasm
index 23aba7d9d..02625d09e 100644
--- a/test/hello_world.fromasm
+++ b/test/hello_world.fromasm
@@ -1,8 +1,7 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "hello_world.asm.js")
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "add" (func $add))
diff --git a/test/hello_world.fromasm.imprecise b/test/hello_world.fromasm.imprecise
index 6bfc4bf68..21ac8112c 100644
--- a/test/hello_world.fromasm.imprecise
+++ b/test/hello_world.fromasm.imprecise
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "add" (func $add))
diff --git a/test/hello_world.fromasm.imprecise.no-opts b/test/hello_world.fromasm.imprecise.no-opts
index 31ce2e573..8ef16e1e0 100644
--- a/test/hello_world.fromasm.imprecise.no-opts
+++ b/test/hello_world.fromasm.imprecise.no-opts
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "add" (func $add))
diff --git a/test/hello_world.fromasm.no-opts b/test/hello_world.fromasm.no-opts
index 31ce2e573..8ef16e1e0 100644
--- a/test/hello_world.fromasm.no-opts
+++ b/test/hello_world.fromasm.no-opts
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "add" (func $add))
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index 9c335557f..7847fa1dc 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "memorygrowth.asm.js")
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
@@ -26,8 +25,8 @@
(import "env" "___unlock" (func $xa (param i32)))
(import "env" "___syscall146" (func $ya (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $fb))
@@ -80,7 +79,6 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
- (table 8 8 anyfunc)
(elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $0 i32) (result i32)
(local $1 i32)
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index 258fbd3ad..febb33861 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -24,8 +23,8 @@
(import "env" "___syscall54" (func $wa (param i32 i32) (result i32)))
(import "env" "___unlock" (func $xa (param i32)))
(import "env" "___syscall146" (func $ya (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $fb))
@@ -78,7 +77,6 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
- (table 8 8 anyfunc)
(elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $0 i32) (result i32)
(local $1 i32)
diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts
index cd2c80cc0..0de4e25b3 100644
--- a/test/memorygrowth.fromasm.imprecise.no-opts
+++ b/test/memorygrowth.fromasm.imprecise.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -24,8 +23,8 @@
(import "env" "___syscall54" (func $wa (param i32 i32) (result i32)))
(import "env" "___unlock" (func $xa (param i32)))
(import "env" "___syscall146" (func $ya (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $fb))
@@ -78,7 +77,6 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
- (table 8 8 anyfunc)
(elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $a i32) (result i32)
(local $b i32)
diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts
index 0b50f1248..124e87a18 100644
--- a/test/memorygrowth.fromasm.no-opts
+++ b/test/memorygrowth.fromasm.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
@@ -25,8 +24,8 @@
(import "env" "___unlock" (func $xa (param i32)))
(import "env" "___syscall146" (func $ya (param i32 i32) (result i32)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 8 8 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_free" (func $fb))
@@ -79,7 +78,6 @@
(global $S (mut i32) (i32.const 0))
(global $T (mut i32) (i32.const 0))
(global $za (mut f64) (f64.const 0))
- (table 8 8 anyfunc)
(elem (i32.const 0) $nb $Oa $ob $Va $Ua $Ra $pb $Sa)
(func $eb (param $a i32) (result i32)
(local $b i32)
diff --git a/test/min.fromasm b/test/min.fromasm
index a52a6e876..0c5a14670 100644
--- a/test/min.fromasm
+++ b/test/min.fromasm
@@ -1,9 +1,8 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "min.asm.js")
(import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "floats" (func $floats))
diff --git a/test/min.fromasm.imprecise b/test/min.fromasm.imprecise
index 495c600d1..485e2593c 100644
--- a/test/min.fromasm.imprecise
+++ b/test/min.fromasm.imprecise
@@ -1,8 +1,7 @@
(module
- (memory 256 256)
(import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "floats" (func $floats))
diff --git a/test/min.fromasm.imprecise.no-opts b/test/min.fromasm.imprecise.no-opts
index 60303aa74..89326688f 100644
--- a/test/min.fromasm.imprecise.no-opts
+++ b/test/min.fromasm.imprecise.no-opts
@@ -1,8 +1,7 @@
(module
- (memory 256 256)
(import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "floats" (func $floats))
diff --git a/test/min.fromasm.no-opts b/test/min.fromasm.no-opts
index 60303aa74..89326688f 100644
--- a/test/min.fromasm.no-opts
+++ b/test/min.fromasm.no-opts
@@ -1,8 +1,7 @@
(module
- (memory 256 256)
(import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "floats" (func $floats))
diff --git a/test/two_sides.fromasm b/test/two_sides.fromasm
index 9ddb1a9ac..e6595d04b 100644
--- a/test/two_sides.fromasm
+++ b/test/two_sides.fromasm
@@ -1,10 +1,9 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "two_sides.asm.js")
(type $FUNCSIG$id (func (param f64) (result i32)))
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_test" (func $_test))
diff --git a/test/two_sides.fromasm.imprecise b/test/two_sides.fromasm.imprecise
index 1578c86da..428c56a97 100644
--- a/test/two_sides.fromasm.imprecise
+++ b/test/two_sides.fromasm.imprecise
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_test" (func $_test))
diff --git a/test/two_sides.fromasm.imprecise.no-opts b/test/two_sides.fromasm.imprecise.no-opts
index a8a338489..e695bc124 100644
--- a/test/two_sides.fromasm.imprecise.no-opts
+++ b/test/two_sides.fromasm.imprecise.no-opts
@@ -1,7 +1,6 @@
(module
- (memory 256 256)
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_test" (func $_test))
diff --git a/test/two_sides.fromasm.no-opts b/test/two_sides.fromasm.no-opts
index 56c2062cf..cb693267a 100644
--- a/test/two_sides.fromasm.no-opts
+++ b/test/two_sides.fromasm.no-opts
@@ -1,9 +1,8 @@
(module
- (memory 256 256)
(type $FUNCSIG$id (func (param f64) (result i32)))
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "_test" (func $_test))
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 300ac4a5b..fb9f239da 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(data (get_global $memoryBase) "unit.asm.js")
(type $FUNCSIG$id (func (param f64) (result i32)))
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
@@ -22,8 +21,8 @@
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 10 10 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "big_negative" (func $big_negative))
@@ -35,7 +34,6 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
- (table 10 10 anyfunc)
(elem (i32.const 0) $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 3238ef902..ad130ea82 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -17,8 +16,8 @@
(import "env" "h" (func $h (param i32)))
(import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 10 10 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "big_negative" (func $big_negative))
@@ -30,7 +29,6 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
- (table 10 10 anyfunc)
(elem (i32.const 0) $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 e8bb300b0..636238f17 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$vf (func (param f32)))
(type $FUNCSIG$vi (func (param i32)))
@@ -17,8 +16,8 @@
(import "env" "h" (func $h (param i32)))
(import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 10 10 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "big_negative" (func $big_negative))
@@ -30,7 +29,6 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
- (table 10 10 anyfunc)
(elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative
(local $temp f64)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index 09fb6fc6f..0684c1464 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -1,5 +1,4 @@
(module
- (memory 256 256)
(type $FUNCSIG$id (func (param f64) (result i32)))
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
@@ -21,8 +20,8 @@
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
- (import "env" "memory" (memory $memory))
- (import "env" "table" (table $table))
+ (import "env" "memory" (memory 256 256))
+ (import "env" "table" (table 10 10 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(export "big_negative" (func $big_negative))
@@ -34,7 +33,6 @@
(global $tempDoublePtr (mut i32) (get_global $tempDoublePtr$asm2wasm$import))
(global $n (mut i32) (get_global $n$asm2wasm$import))
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
- (table 10 10 anyfunc)
(elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
(func $big_negative
(local $temp f64)