summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-07-28 14:16:19 -0700
committerGitHub <noreply@github.com>2016-07-28 14:16:19 -0700
commitcffbc4bc36f5e5f53e34f16ba4e687fdf130131d (patch)
tree0bf5c6d3bc347b2fddffce477a67826c9093a8be
parent3dc2e2579199fb0457846a22b3759ef16531b3da (diff)
downloadbinaryen-cffbc4bc36f5e5f53e34f16ba4e687fdf130131d.tar.gz
binaryen-cffbc4bc36f5e5f53e34f16ba4e687fdf130131d.tar.bz2
binaryen-cffbc4bc36f5e5f53e34f16ba4e687fdf130131d.zip
wast function type name desugaring is changing in spec:301 (#654)
-rwxr-xr-xauto_update_tests.py18
-rw-r--r--src/wasm-s-parser.h53
-rw-r--r--src/wasm.h8
-rw-r--r--test/hello_world.wast3
-rw-r--r--test/kitchen_sink.wast3
-rw-r--r--test/min.wast12
-rw-r--r--test/passes/coalesce-locals-learning.txt73
-rw-r--r--test/passes/coalesce-locals.txt77
-rw-r--r--test/passes/dce.txt9
-rw-r--r--test/passes/drop-return-values.txt3
-rw-r--r--test/passes/duplicate-function-elimination.txt317
-rw-r--r--test/passes/lower-if-else.txt3
-rw-r--r--test/passes/metrics.txt3
-rw-r--r--test/passes/nm.txt7
-rw-r--r--test/passes/optimize-instructions.txt3
-rw-r--r--test/passes/post-emscripten.txt3
-rw-r--r--test/passes/precompute.txt3
-rw-r--r--test/passes/remove-imports.txt2
-rw-r--r--test/passes/remove-unused-brs.txt53
-rw-r--r--test/passes/remove-unused-functions.txt17
-rw-r--r--test/passes/remove-unused-names.txt8
-rw-r--r--test/passes/remove-unused-names_merge-blocks.txt39
-rw-r--r--test/passes/reorder-functions.txt7
-rw-r--r--test/passes/reorder-locals.txt8
-rw-r--r--test/passes/simplify-locals.txt17
-rw-r--r--test/passes/vacuum.txt25
-rw-r--r--test/reg_switch.wast3
m---------test/spec0
-rw-r--r--test/unit.wast46
29 files changed, 495 insertions, 328 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index 75396655e..1ecbb7a40 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -79,6 +79,13 @@ for t in sorted(os.listdir(os.path.join('test', 'passes'))):
actual += run_command(cmd)
with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual)
+print '\n[ checking wasm-opt -o notation... ]\n'
+
+wast = os.path.join('test', 'hello_world.wast')
+cmd = [os.path.join('bin', 'wasm-opt'), wast, '-o', 'a.wast']
+run_command(cmd)
+open(wast, 'w').write(open('a.wast').read())
+
print '\n[ checking binary format testcases... ]\n'
for wast in sorted(os.listdir('test')):
@@ -145,4 +152,15 @@ for t in sorted(os.listdir(os.path.join('test', 'example'))):
# Also removes debug directory produced on Mac OS
shutil.rmtree(output_file + '.dSYM')
+print '\n[ checking wasm-opt testcases... ]\n'
+
+for t in os.listdir('test'):
+ if t.endswith('.wast') and not t.startswith('spec'):
+ print '..', t
+ t = os.path.join('test', t)
+ cmd = [os.path.join('bin', 'wasm-opt'), t, '--print']
+ actual = run_command(cmd)
+ actual = actual.replace('printing before:\n', '')
+ open(t, 'w').write(actual)
+
print '\n[ success! ]'
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 8f62c8af8..750d485fb 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -312,21 +312,49 @@ private:
}
functionNames.push_back(name);
functionCounter++;
+ FunctionType* type = nullptr;
+ functionTypes[name] = none;
+ std::vector<WasmType> params;
for (;i < s.size(); i++) {
Element& curr = *s[i];
IString id = curr[0]->str();
if (id == RESULT) {
functionTypes[name] = stringToWasmType(curr[1]->str());
- return;
} else if (id == TYPE) {
Name typeName = curr[1]->str();
if (!wasm.checkFunctionType(typeName)) throw ParseException("unknown function");
- FunctionType* type = wasm.getFunctionType(typeName);
+ type = wasm.getFunctionType(typeName);
functionTypes[name] = type->result;
- return;
+ } else if (id == PARAM && curr.size() > 1) {
+ Index j = 1;
+ if (curr[j]->dollared()) {
+ // dollared input symbols cannot be types
+ params.push_back(stringToWasmType(curr[j + 1]->str(), true));
+ } else {
+ while (j < curr.size()) {
+ params.push_back(stringToWasmType(curr[j++]->str(), true));
+ }
+ }
+ }
+ }
+ if (!type) {
+ // if no function type provided, generate one, but reuse a previous one with the
+ // right structure if there is one.
+ // see https://github.com/WebAssembly/spec/pull/301
+ bool need = true;
+ std::unique_ptr<FunctionType> functionType = make_unique<FunctionType>();
+ functionType->result = functionTypes[name];
+ functionType->params = std::move(params);
+ for (auto& existing : wasm.functionTypes) {
+ if (existing->structuralComparison(*functionType)) {
+ need = false;
+ break;
+ }
+ }
+ if (need) {
+ wasm.addFunctionType(functionType.release());
}
}
- functionTypes[name] = none;
}
void preParseImports(Element& curr) {
@@ -500,16 +528,21 @@ private:
body = allocator.alloc<Nop>();
}
if (currFunction->result != result) throw ParseException("bad func declaration", s.line, s.col);
- /* TODO: spec in flux, https://github.com/WebAssembly/spec/pull/301
+ // see https://github.com/WebAssembly/spec/pull/301
if (type.isNull()) {
- // if no function type provided, generate a private one for this function
- auto* functionType = sigToFunctionType(getSig(currFunction.get()));
- wasm.addFunctionType(functionType);
- type = functionType->name;
+ // if no function type name provided, then we generated one
+ std::unique_ptr<FunctionType> functionType = std::unique_ptr<FunctionType>(sigToFunctionType(getSig(currFunction.get())));
+ for (auto& existing : wasm.functionTypes) {
+ if (existing->structuralComparison(*functionType)) {
+ type = existing->name;
+ break;
+ }
+ }
+ if (!type.is()) throw ParseException("no function type [internal error?]", s.line, s.col);
}
- */
currFunction->body = body;
currFunction->type = type;
+
wasm.addFunction(currFunction.release());
currLocalTypes.clear();
labelStack.clear();
diff --git a/src/wasm.h b/src/wasm.h
index 5c1baaf09..38a030e1a 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1065,8 +1065,7 @@ public:
FunctionType() : result(none) {}
- bool operator==(FunctionType& b) {
- if (name != b.name) return false; // XXX
+ bool structuralComparison(FunctionType& b) {
if (result != b.result) return false;
if (params.size() != b.params.size()) return false;
for (size_t i = 0; i < params.size(); i++) {
@@ -1074,6 +1073,11 @@ public:
}
return true;
}
+
+ bool operator==(FunctionType& b) {
+ if (name != b.name) return false;
+ return structuralComparison(b);
+ }
bool operator!=(FunctionType& b) {
return !(*this == b);
}
diff --git a/test/hello_world.wast b/test/hello_world.wast
index 0a2dd083d..915c4a99a 100644
--- a/test/hello_world.wast
+++ b/test/hello_world.wast
@@ -1,7 +1,8 @@
(module
(memory 256 256)
+ (type $0 (func (param i32 i32) (result i32)))
(export "add" $add)
- (func $add (param $x i32) (param $y i32) (result i32)
+ (func $add (type $0) (param $x i32) (param $y i32) (result i32)
(i32.add
(get_local $x)
(get_local $y)
diff --git a/test/kitchen_sink.wast b/test/kitchen_sink.wast
index 29b4c47d0..e0cc6617a 100644
--- a/test/kitchen_sink.wast
+++ b/test/kitchen_sink.wast
@@ -2,7 +2,8 @@
(memory 4096 4096
(segment 1026 "\14\00")
)
- (func $kitchensink (result i32)
+ (type $0 (func (result i32)))
+ (func $kitchensink (type $0) (result i32)
(block $block0
(i32.add
(i32.const 10)
diff --git a/test/min.wast b/test/min.wast
index 790e29e9b..44d848991 100644
--- a/test/min.wast
+++ b/test/min.wast
@@ -1,14 +1,18 @@
(module
(memory 256 256)
+ (type $0 (func (param f32) (result f32)))
+ (type $1 (func (param i32 i32) (result f32)))
+ (type $2 (func (param i32) (result i32)))
+ (type $3 (func (param i32 i32 i32) (result i32)))
(export "floats" $floats)
- (func $floats (param $f f32) (result f32)
+ (func $floats (type $0) (param $f f32) (result f32)
(local $t f32)
(f32.add
(get_local $t)
(get_local $f)
)
)
- (func $neg (param $k i32) (param $p i32) (result f32)
+ (func $neg (type $1) (param $k i32) (param $p i32) (result f32)
(local $n f32)
(set_local $n
(f32.neg
@@ -24,7 +28,7 @@
)
)
)
- (func $littleswitch (param $x i32) (result i32)
+ (func $littleswitch (type $2) (param $x i32) (result i32)
(block $topmost
(block $switch-case$2
(block $switch-case$1
@@ -45,7 +49,7 @@
(i32.const 0)
)
)
- (func $f1 (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32)
+ (func $f1 (type $3) (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32)
(block $topmost
(get_local $i3)
)
diff --git a/test/passes/coalesce-locals-learning.txt b/test/passes/coalesce-locals-learning.txt
index aa3c8c9c0..44ad12f53 100644
--- a/test/passes/coalesce-locals-learning.txt
+++ b/test/passes/coalesce-locals-learning.txt
@@ -2,21 +2,24 @@
(memory 10)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $2 (func))
+ (type $3 (func (param i32 f32)))
+ (type $4 (func (param i32)))
(import $_emscripten_autodebug_i32 "env" "_emscripten_autodebug_i32" (param i32 i32) (result i32))
- (func $nothing-to-do
+ (func $nothing-to-do (type $2)
(local $0 i32)
(nop)
)
- (func $merge
+ (func $merge (type $2)
(local $0 i32)
(nop)
)
- (func $leave-type
+ (func $leave-type (type $2)
(local $0 i32)
(local $1 f32)
(nop)
)
- (func $leave-interfere
+ (func $leave-interfere (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -28,7 +31,7 @@
(get_local $0)
(get_local $1)
)
- (func $almost-interfere
+ (func $almost-interfere (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -39,7 +42,7 @@
)
(get_local $0)
)
- (func $redundant-copy
+ (func $redundant-copy (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -47,7 +50,7 @@
(get_local $0)
(get_local $0)
)
- (func $ineffective-store
+ (func $ineffective-store (type $2)
(local $0 i32)
(i32.const 0)
(set_local $0
@@ -55,7 +58,7 @@
)
(get_local $0)
)
- (func $block
+ (func $block (type $2)
(local $0 i32)
(block $block0
(set_local $0
@@ -64,7 +67,7 @@
)
(get_local $0)
)
- (func $see-both-sides
+ (func $see-both-sides (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -78,7 +81,7 @@
(get_local $0)
(get_local $1)
)
- (func $see-br-and-ignore-dead
+ (func $see-br-and-ignore-dead (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -91,7 +94,7 @@
)
(get_local $0)
)
- (func $see-block-body
+ (func $see-block-body (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -106,19 +109,19 @@
)
(get_local $0)
)
- (func $zero-init
+ (func $zero-init (type $2)
(local $0 i32)
(local $1 i32)
(get_local $0)
(get_local $1)
)
- (func $multi
+ (func $multi (type $2)
(local $0 i32)
(local $1 i32)
(get_local $0)
(get_local $1)
)
- (func $if-else
+ (func $if-else (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -127,7 +130,7 @@
(get_local $1)
)
)
- (func $if-else-parallel
+ (func $if-else-parallel (type $2)
(local $0 i32)
(if
(i32.const 0)
@@ -145,7 +148,7 @@
)
)
)
- (func $if-else-after
+ (func $if-else-after (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -160,7 +163,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-else-through
+ (func $if-else-through (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -177,7 +180,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through
+ (func $if-through (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -193,7 +196,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through2
+ (func $if-through2 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -208,7 +211,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through2
+ (func $if-through2 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -222,7 +225,7 @@
)
)
)
- (func $if2
+ (func $if2 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -235,7 +238,7 @@
)
)
)
- (func $if3
+ (func $if3 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -249,7 +252,7 @@
)
(get_local $1)
)
- (func $if4
+ (func $if4 (type $2)
(local $0 i32)
(if
(i32.const 0)
@@ -265,7 +268,7 @@
)
(get_local $0)
)
- (func $if5
+ (func $if5 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -279,7 +282,7 @@
)
(get_local $1)
)
- (func $loop
+ (func $loop (type $2)
(local $0 i32)
(local $1 i32)
(loop $out $in
@@ -291,7 +294,7 @@
(br $in)
)
)
- (func $interfere-in-dead
+ (func $interfere-in-dead (type $2)
(local $0 i32)
(block $block
(br $block)
@@ -299,7 +302,7 @@
(get_local $0)
)
)
- (func $interfere-in-dead2
+ (func $interfere-in-dead2 (type $2)
(local $0 i32)
(block $block
(unreachable)
@@ -307,7 +310,7 @@
(get_local $0)
)
)
- (func $interfere-in-dead3
+ (func $interfere-in-dead3 (type $2)
(local $0 i32)
(block $block
(return)
@@ -315,7 +318,7 @@
(get_local $0)
)
)
- (func $params (param $0 i32) (param $1 f32)
+ (func $params (type $3) (param $0 i32) (param $1 f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -323,7 +326,7 @@
(get_local $3)
(get_local $4)
)
- (func $interfere-in-dead
+ (func $interfere-in-dead (type $2)
(local $0 i32)
(local $1 i32)
(block $block
@@ -334,7 +337,7 @@
(get_local $1)
)
)
- (func $switch
+ (func $switch (type $2)
(local $0 i32)
(local $1 i32)
(local $2 i32)
@@ -352,7 +355,7 @@
)
(get_local $2)
)
- (func $greedy-can-be-happy
+ (func $greedy-can-be-happy (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -431,7 +434,7 @@
)
)
)
- (func $greedy-can-be-sad
+ (func $greedy-can-be-sad (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -510,7 +513,7 @@
)
)
)
- (func $_memcpy (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memcpy (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(if
(i32.ge_s
@@ -662,7 +665,7 @@
(get_local $3)
)
)
- (func $this-is-effective-i-tell-you (param $0 i32)
+ (func $this-is-effective-i-tell-you (type $4) (param $0 i32)
(if
(i32.const -1)
(block $block1
diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt
index c9e803665..c24cf34e9 100644
--- a/test/passes/coalesce-locals.txt
+++ b/test/passes/coalesce-locals.txt
@@ -2,21 +2,24 @@
(memory 10)
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $2 (func))
+ (type $3 (func (param i32 f32)))
+ (type $4 (func (param i32)))
(import $_emscripten_autodebug_i32 "env" "_emscripten_autodebug_i32" (param i32 i32) (result i32))
- (func $nothing-to-do
+ (func $nothing-to-do (type $2)
(local $0 i32)
(nop)
)
- (func $merge
+ (func $merge (type $2)
(local $0 i32)
(nop)
)
- (func $leave-type
+ (func $leave-type (type $2)
(local $0 i32)
(local $1 f32)
(nop)
)
- (func $leave-interfere
+ (func $leave-interfere (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -28,7 +31,7 @@
(get_local $0)
(get_local $1)
)
- (func $almost-interfere
+ (func $almost-interfere (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -39,7 +42,7 @@
)
(get_local $0)
)
- (func $redundant-copy
+ (func $redundant-copy (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -47,7 +50,7 @@
(get_local $0)
(get_local $0)
)
- (func $ineffective-store
+ (func $ineffective-store (type $2)
(local $0 i32)
(i32.const 0)
(set_local $0
@@ -55,7 +58,7 @@
)
(get_local $0)
)
- (func $block
+ (func $block (type $2)
(local $0 i32)
(block $block0
(set_local $0
@@ -64,7 +67,7 @@
)
(get_local $0)
)
- (func $see-both-sides
+ (func $see-both-sides (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -78,7 +81,7 @@
(get_local $0)
(get_local $1)
)
- (func $see-br-and-ignore-dead
+ (func $see-br-and-ignore-dead (type $2)
(local $0 i32)
(set_local $0
(i32.const 0)
@@ -91,7 +94,7 @@
)
(get_local $0)
)
- (func $see-block-body
+ (func $see-block-body (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -106,19 +109,19 @@
)
(get_local $0)
)
- (func $zero-init
+ (func $zero-init (type $2)
(local $0 i32)
(local $1 i32)
(get_local $0)
(get_local $1)
)
- (func $multi
+ (func $multi (type $2)
(local $0 i32)
(local $1 i32)
(get_local $0)
(get_local $1)
)
- (func $if-else
+ (func $if-else (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -127,7 +130,7 @@
(get_local $1)
)
)
- (func $if-else-parallel
+ (func $if-else-parallel (type $2)
(local $0 i32)
(if
(i32.const 0)
@@ -145,7 +148,7 @@
)
)
)
- (func $if-else-after
+ (func $if-else-after (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -160,7 +163,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-else-through
+ (func $if-else-through (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -177,7 +180,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through
+ (func $if-through (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -193,7 +196,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through2
+ (func $if-through2 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -208,7 +211,7 @@
(get_local $0)
(get_local $1)
)
- (func $if-through2
+ (func $if-through2 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -222,7 +225,7 @@
)
)
)
- (func $if2
+ (func $if2 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -235,7 +238,7 @@
)
)
)
- (func $if3
+ (func $if3 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -249,7 +252,7 @@
)
(get_local $1)
)
- (func $if4
+ (func $if4 (type $2)
(local $0 i32)
(if
(i32.const 0)
@@ -265,7 +268,7 @@
)
(get_local $0)
)
- (func $if5
+ (func $if5 (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -279,7 +282,7 @@
)
(get_local $1)
)
- (func $loop
+ (func $loop (type $2)
(local $0 i32)
(local $1 i32)
(loop $out $in
@@ -291,7 +294,7 @@
(br $in)
)
)
- (func $interfere-in-dead
+ (func $interfere-in-dead (type $2)
(local $0 i32)
(block $block
(br $block)
@@ -299,7 +302,7 @@
(get_local $0)
)
)
- (func $interfere-in-dead2
+ (func $interfere-in-dead2 (type $2)
(local $0 i32)
(block $block
(unreachable)
@@ -307,7 +310,7 @@
(get_local $0)
)
)
- (func $interfere-in-dead3
+ (func $interfere-in-dead3 (type $2)
(local $0 i32)
(block $block
(return)
@@ -315,7 +318,7 @@
(get_local $0)
)
)
- (func $params (param $0 i32) (param $1 f32)
+ (func $params (type $3) (param $0 i32) (param $1 f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -323,7 +326,7 @@
(get_local $3)
(get_local $4)
)
- (func $interfere-in-dead
+ (func $interfere-in-dead (type $2)
(local $0 i32)
(local $1 i32)
(block $block
@@ -334,7 +337,7 @@
(get_local $1)
)
)
- (func $switch
+ (func $switch (type $2)
(local $0 i32)
(local $1 i32)
(local $2 i32)
@@ -352,7 +355,7 @@
)
(get_local $2)
)
- (func $greedy-can-be-happy
+ (func $greedy-can-be-happy (type $2)
(local $0 i32)
(local $1 i32)
(if
@@ -431,7 +434,7 @@
)
)
)
- (func $greedy-can-be-sad
+ (func $greedy-can-be-sad (type $2)
(local $0 i32)
(local $1 i32)
(local $2 i32)
@@ -511,7 +514,7 @@
)
)
)
- (func $_memcpy (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memcpy (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(if
(i32.ge_s
@@ -663,7 +666,7 @@
(get_local $3)
)
)
- (func $this-is-effective-i-tell-you (param $0 i32)
+ (func $this-is-effective-i-tell-you (type $4) (param $0 i32)
(if
(i32.const -1)
(block $block1
@@ -679,7 +682,7 @@
)
(get_local $0)
)
- (func $prefer-remove-copies1
+ (func $prefer-remove-copies1 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $0
@@ -692,7 +695,7 @@
(get_local $0)
(get_local $1)
)
- (func $prefer-remove-copies1
+ (func $prefer-remove-copies1 (type $2)
(local $0 i32)
(local $1 i32)
(set_local $1
diff --git a/test/passes/dce.txt b/test/passes/dce.txt
index 5f287e183..692a5005e 100644
--- a/test/passes/dce.txt
+++ b/test/passes/dce.txt
@@ -1,11 +1,12 @@
(module
(memory 10)
(type $ii (func (param i32 i32)))
+ (type $1 (func))
(table $call-me)
- (func $call-me (param $0 i32) (param $1 i32)
+ (func $call-me (type $ii) (param $0 i32) (param $1 i32)
(nop)
)
- (func $code-to-kill
+ (func $code-to-kill (type $1)
(local $x i32)
(block $out
(br $out)
@@ -236,10 +237,10 @@
)
(i32.const 1337)
)
- (func $killer
+ (func $killer (type $1)
(unreachable)
)
- (func $target
+ (func $target (type $1)
(i32.const 2000)
)
)
diff --git a/test/passes/drop-return-values.txt b/test/passes/drop-return-values.txt
index 8f372ea24..81ca99327 100644
--- a/test/passes/drop-return-values.txt
+++ b/test/passes/drop-return-values.txt
@@ -1,6 +1,7 @@
(module
(memory 10)
- (func $0
+ (type $0 (func))
+ (func $0 (type $0)
(local $x i32)
(local $1 i32)
(i32.add
diff --git a/test/passes/duplicate-function-elimination.txt b/test/passes/duplicate-function-elimination.txt
index 9595f5705..3671ce24b 100644
--- a/test/passes/duplicate-function-elimination.txt
+++ b/test/passes/duplicate-function-elimination.txt
@@ -1,68 +1,75 @@
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(nop)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.const 0)
)
- (func $other
+ (func $other (type $0)
(nop)
)
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(i32.const 0)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.const 0)
)
- (func $other
+ (func $other (type $0)
(i32.const 1)
)
)
(module
(memory 0)
(start $keep2)
+ (type $0 (func))
(export "keep2" $keep2)
(export "other" $keep2)
(table $keep2 $keep2 $caller)
- (func $keep2
+ (func $keep2 (type $0)
(nop)
)
- (func $caller
+ (func $caller (type $0)
(call $keep2)
(call $keep2)
)
)
(module
(memory 0)
- (func $keep2-after-two-passes
+ (type $0 (func))
+ (func $keep2-after-two-passes (type $0)
(nop)
)
- (func $keep-caller
+ (func $keep-caller (type $0)
(call $keep2-after-two-passes)
)
)
(module
(memory 0)
- (func $keep-4
+ (type $0 (func))
+ (func $keep-4 (type $0)
(nop)
)
- (func $other
+ (func $other (type $0)
(unreachable)
)
- (func $keep-caller
+ (func $keep-caller (type $0)
(call $keep-4)
)
- (func $other-caller
+ (func $other-caller (type $0)
(call $other)
)
)
@@ -70,10 +77,12 @@
(memory 0)
(type $T (func (result i32)))
(type $S (func (result i32)))
- (func $keep4-similar-but-func-sig-differs
+ (type $2 (func))
+ (type $3 (func (param i32)))
+ (func $keep4-similar-but-func-sig-differs (type $2)
(i32.const 0)
)
- (func $other1 (param $i i32)
+ (func $other1 (type $3) (param $i i32)
(i32.const 0)
)
(func $other2 (type $T) (result i32)
@@ -86,7 +95,8 @@
(module
(memory 0)
(type $S (func (result i32)))
- (func $keep2-similar-but-func-sig-differs (param $i i32)
+ (type $1 (func (param i32)))
+ (func $keep2-similar-but-func-sig-differs (type $1) (param $i i32)
(i32.const 0)
)
(func $other2 (type $S) (result i32)
@@ -95,28 +105,31 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(nop)
)
- (func $other
+ (func $other (type $0)
(nop)
(nop)
)
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(block $block0
)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $block0
)
)
- (func $other
+ (func $other (type $0)
(block $block0
(nop)
)
@@ -124,7 +137,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(block $block0
(nop)
)
@@ -132,12 +146,13 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $block0
(nop)
)
)
- (func $other
+ (func $other (type $0)
(block $block0
(nop)
(unreachable)
@@ -146,12 +161,13 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $block0
(nop)
)
)
- (func $other
+ (func $other (type $0)
(block $block0
(unreachable)
)
@@ -159,14 +175,16 @@
)
(module
(memory 0)
- (func $erase-since-block-names-do-not-matter
+ (type $0 (func))
+ (func $erase-since-block-names-do-not-matter (type $0)
(block $foo
)
)
)
(module
(memory 0)
- (func $erase-since-block-names-do-not-matter
+ (type $0 (func))
+ (func $erase-since-block-names-do-not-matter (type $0)
(block $foo
(br $foo)
(br_table $foo $foo
@@ -177,14 +195,15 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $foo
(br $foo
(i32.const 0)
)
)
)
- (func $other
+ (func $other (type $0)
(block $bar
(br $bar
(i32.const 1)
@@ -194,14 +213,15 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $foo
(br_if $foo
(i32.const 0)
)
)
)
- (func $other
+ (func $other (type $0)
(block $bar
(br_if $bar
(i32.const 1)
@@ -211,7 +231,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(block $foo
(br_if $foo
(i32.const 0)
@@ -221,14 +242,15 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $foo
(br_table $foo $foo
(i32.const 0)
)
)
)
- (func $other
+ (func $other (type $0)
(block $bar
(br_table $bar $bar
(i32.const 1)
@@ -238,7 +260,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(loop $foo $bar
(nop)
)
@@ -246,7 +269,8 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $foo
(br_table $foo $foo
(i32.const 0)
@@ -254,7 +278,7 @@
)
)
)
- (func $other
+ (func $other (type $0)
(block $bar
(br_table $bar $bar
(i32.const 0)
@@ -265,7 +289,8 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(block $foo
(block $bar
(br_table $foo $bar
@@ -277,7 +302,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(block $foo
(block $bar
(br_table $foo $bar
@@ -286,7 +312,7 @@
)
)
)
- (func $other
+ (func $other (type $0)
(block $bar
(block $foo
(br_table $foo $bar
@@ -298,16 +324,18 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(call $erase)
)
)
(module
(memory 0)
- (func $keep2-but-in-theory-we-could-erase
+ (type $0 (func))
+ (func $keep2-but-in-theory-we-could-erase (type $0)
(call $keep2-but-in-theory-we-could-erase)
)
- (func $other
+ (func $other (type $0)
(call $other)
)
)
@@ -316,7 +344,7 @@
(type $FUNCSIG$v (func))
(import $i "env" "i")
(import $i "env" "j")
- (func $erase
+ (func $erase (type $FUNCSIG$v)
(call_import $i)
)
)
@@ -325,10 +353,10 @@
(type $FUNCSIG$v (func))
(import $i "env" "i")
(import $j "env" "j")
- (func $keep2
+ (func $keep2 (type $FUNCSIG$v)
(call_import $i)
)
- (func $other
+ (func $other (type $FUNCSIG$v)
(call_import $j)
)
)
@@ -336,7 +364,7 @@
(memory 0)
(type $T (func))
(table $erase $erase)
- (func $erase
+ (func $erase (type $T)
(call_indirect $T
(i32.const 0)
)
@@ -346,12 +374,12 @@
(memory 0)
(type $T (func))
(table $keep2 $other)
- (func $keep2
+ (func $keep2 (type $T)
(call_indirect $T
(i32.const 0)
)
)
- (func $other
+ (func $other (type $T)
(call_indirect $T
(i32.const 1)
)
@@ -362,12 +390,12 @@
(type $T (func))
(type $S (func))
(table $keep2 $other)
- (func $keep2
+ (func $keep2 (type $T)
(call_indirect $T
(i32.const 0)
)
)
- (func $other
+ (func $other (type $T)
(call_indirect $S
(i32.const 0)
)
@@ -375,25 +403,28 @@
)
(module
(memory 0)
- (func $erase-even-locals-with-different-names
+ (type $0 (func))
+ (func $erase-even-locals-with-different-names (type $0)
(local $i i32)
(get_local $i)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(local $i i32)
(get_local $i)
)
- (func $other
+ (func $other (type $0)
(local $j i64)
(get_local $j)
)
)
(module
(memory 0)
- (func $erase-even-locals-with-different-names
+ (type $0 (func))
+ (func $erase-even-locals-with-different-names (type $0)
(local $i i32)
(set_local $i
(i32.const 0)
@@ -402,13 +433,14 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(local $i i32)
(set_local $i
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(local $j i64)
(set_local $j
(i64.const 0)
@@ -417,13 +449,14 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(local $i i32)
(set_local $i
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(local $j i32)
(set_local $j
(i32.const 1)
@@ -432,7 +465,8 @@
)
(module
(memory 10)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(i32.load
(i32.const 0)
)
@@ -443,12 +477,13 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.load16_s offset=3
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(i32.load8_s offset=3 align=2
(i32.const 0)
)
@@ -456,12 +491,13 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.load8_s offset=3
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(i32.load8_s offset=3 align=2
(i32.const 0)
)
@@ -469,12 +505,13 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.load8_s align=2
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(i32.load8_s offset=3 align=2
(i32.const 0)
)
@@ -482,12 +519,13 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.load8_s offset=3 align=2
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(i32.load8_s offset=3 align=2
(i32.const 1)
)
@@ -495,12 +533,13 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.load8_u offset=3 align=2
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(i32.load8_s offset=3 align=2
(i32.const 0)
)
@@ -508,7 +547,8 @@
)
(module
(memory 10)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(i32.store
(i32.const 0)
(i32.const 100)
@@ -521,13 +561,14 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.store16 offset=3
(i32.const 0)
(i32.const 100)
)
)
- (func $other
+ (func $other (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 100)
@@ -536,13 +577,14 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.store8 offset=3
(i32.const 0)
(i32.const 100)
)
)
- (func $other
+ (func $other (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 100)
@@ -551,13 +593,14 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.store8 align=2
(i32.const 0)
(i32.const 100)
)
)
- (func $other
+ (func $other (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 100)
@@ -566,13 +609,14 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 100)
)
)
- (func $other
+ (func $other (type $0)
(i32.store8 offset=3 align=2
(i32.const 1)
(i32.const 100)
@@ -581,13 +625,14 @@
)
(module
(memory 10)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 100)
)
)
- (func $other
+ (func $other (type $0)
(i32.store8 offset=3 align=2
(i32.const 0)
(i32.const 101)
@@ -596,61 +641,68 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.const 0)
)
- (func $other
+ (func $other (type $0)
(i64.const 0)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.const 0)
)
- (func $other
+ (func $other (type $0)
(f32.const 0)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i32.const 0)
)
- (func $other
+ (func $other (type $0)
(f64.const 0)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(i64.const 0)
)
- (func $other
+ (func $other (type $0)
(i64.const 1)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.const 0.10000000149011612)
)
- (func $other
+ (func $other (type $0)
(f32.const -0.10000000149011612)
)
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f64.const 0.1)
)
- (func $other
+ (func $other (type $0)
(f64.const 0.2)
)
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(f32.abs
(f32.const 0)
)
@@ -658,12 +710,13 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.abs
(f32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(f32.abs
(f32.const 1)
)
@@ -671,12 +724,13 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.abs
(f32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(f32.neg
(f32.const 0)
)
@@ -684,7 +738,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(f32.add
(f32.const 0)
(f32.const 0)
@@ -693,13 +748,14 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.add
(f32.const 0)
(f32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(f32.add
(f32.const 0)
(f32.const 1)
@@ -708,13 +764,14 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.add
(f32.const 0)
(f32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(f32.add
(f32.const 1)
(f32.const 0)
@@ -723,13 +780,14 @@
)
(module
(memory 0)
- (func $keep2
+ (type $0 (func))
+ (func $keep2 (type $0)
(f32.add
(f32.const 0)
(f32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(f32.sub
(f32.const 0)
(f32.const 0)
@@ -738,7 +796,8 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(select
(i32.const 0)
(i32.const 0)
@@ -748,14 +807,15 @@
)
(module
(memory 0)
- (func $keep
+ (type $0 (func))
+ (func $keep (type $0)
(select
(i32.const 0)
(i32.const 0)
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(select
(i32.const 1)
(i32.const 0)
@@ -765,14 +825,15 @@
)
(module
(memory 0)
- (func $keep
+ (type $0 (func))
+ (func $keep (type $0)
(select
(i32.const 0)
(i32.const 0)
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(select
(i32.const 0)
(i32.const 2)
@@ -782,14 +843,15 @@
)
(module
(memory 0)
- (func $keep
+ (type $0 (func))
+ (func $keep (type $0)
(select
(i32.const 0)
(i32.const 0)
(i32.const 0)
)
)
- (func $other
+ (func $other (type $0)
(select
(i32.const 0)
(i32.const 0)
@@ -799,13 +861,15 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(return)
)
)
(module
(memory 0)
- (func $erase (result i32)
+ (type $0 (func (result i32)))
+ (func $erase (type $0) (result i32)
(return
(i32.const 0)
)
@@ -813,12 +877,13 @@
)
(module
(memory 0)
- (func $keep (result i32)
+ (type $0 (func (result i32)))
+ (func $keep (type $0) (result i32)
(return
(i32.const 0)
)
)
- (func $other (result i32)
+ (func $other (type $0) (result i32)
(return
(i32.const 1)
)
@@ -826,13 +891,15 @@
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(current_memory)
)
)
(module
(memory 0)
- (func $erase
+ (type $0 (func))
+ (func $erase (type $0)
(grow_memory
(i32.const 10)
)
@@ -840,12 +907,13 @@
)
(module
(memory 0)
- (func $keep
+ (type $0 (func))
+ (func $keep (type $0)
(grow_memory
(i32.const 10)
)
)
- (func $other
+ (func $other (type $0)
(grow_memory
(i32.const 11)
)
@@ -853,10 +921,11 @@
)
(module
(memory 0)
- (func $keep
+ (type $0 (func))
+ (func $keep (type $0)
(current_memory)
)
- (func $other
+ (func $other (type $0)
(grow_memory
(i32.const 10)
)
diff --git a/test/passes/lower-if-else.txt b/test/passes/lower-if-else.txt
index ab840ef04..93dd6d916 100644
--- a/test/passes/lower-if-else.txt
+++ b/test/passes/lower-if-else.txt
@@ -1,6 +1,7 @@
(module
(memory 256 256)
- (func $ifs
+ (type $0 (func))
+ (func $ifs (type $0)
(block $block0
(if
(i32.const 0)
diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt
index 9668954e3..97a241c0b 100644
--- a/test/passes/metrics.txt
+++ b/test/passes/metrics.txt
@@ -8,7 +8,8 @@ Counts
if : 4
(module
(memory 256 256)
- (func $ifs (param $x i32)
+ (type $0 (func (param i32)))
+ (func $ifs (type $0) (param $x i32)
(local $y f32)
(block $block0
(if
diff --git a/test/passes/nm.txt b/test/passes/nm.txt
index 99404c670..1129a16ad 100644
--- a/test/passes/nm.txt
+++ b/test/passes/nm.txt
@@ -3,16 +3,17 @@
$c : 11
(module
(memory 0)
- (func $a
+ (type $0 (func))
+ (func $a (type $0)
(nop)
)
- (func $b
+ (func $b (type $0)
(loop $loop-out0 $loop-in1
(nop)
(i32.const 1000)
)
)
- (func $c
+ (func $c (type $0)
(block $top
(nop)
(i32.const 1000)
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt
index fc74041a9..a25c36a5d 100644
--- a/test/passes/optimize-instructions.txt
+++ b/test/passes/optimize-instructions.txt
@@ -1,6 +1,7 @@
(module
(memory 0)
- (func $f (param $i1 i32) (param $i2 i64)
+ (type $0 (func (param i32 i64)))
+ (func $f (type $0) (param $i1 i32) (param $i2 i64)
(if
(i32.eqz
(get_local $i1)
diff --git a/test/passes/post-emscripten.txt b/test/passes/post-emscripten.txt
index 8687a8743..c122b77d5 100644
--- a/test/passes/post-emscripten.txt
+++ b/test/passes/post-emscripten.txt
@@ -1,6 +1,7 @@
(module
(memory 256 256)
- (func $b0 (param $x i32)
+ (type $0 (func (param i32)))
+ (func $b0 (type $0) (param $x i32)
(i32.load offset=1
(get_local $x)
)
diff --git a/test/passes/precompute.txt b/test/passes/precompute.txt
index 2e343c7fa..a3e8623f5 100644
--- a/test/passes/precompute.txt
+++ b/test/passes/precompute.txt
@@ -1,6 +1,7 @@
(module
(memory 0)
- (func $x (param $x i32)
+ (type $0 (func (param i32)))
+ (func $x (type $0) (param $x i32)
(i32.const 3)
(i32.add
(i32.const 1)
diff --git a/test/passes/remove-imports.txt b/test/passes/remove-imports.txt
index f4d1d5b99..a285ef0eb 100644
--- a/test/passes/remove-imports.txt
+++ b/test/passes/remove-imports.txt
@@ -3,7 +3,7 @@
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$d (func (result f64)))
- (func $nada
+ (func $nada (type $FUNCSIG$v)
(nop)
(i32.const 0)
(f64.const 0)
diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt
index c3ac71057..4290d9e05 100644
--- a/test/passes/remove-unused-brs.txt
+++ b/test/passes/remove-unused-brs.txt
@@ -1,48 +1,51 @@
(module
(memory 256 256)
- (func $b0-yes (param $i1 i32)
+ (type $0 (func (param i32)))
+ (type $1 (func))
+ (type $2 (func (result i32)))
+ (func $b0-yes (type $0) (param $i1 i32)
(block $topmost
)
)
- (func $b1 (param $i1 i32)
+ (func $b1 (type $0) (param $i1 i32)
(block $topmost
(i32.const 0)
)
)
- (func $b2 (param $i1 i32)
+ (func $b2 (type $0) (param $i1 i32)
(block $topmost
(block $inner
)
)
)
- (func $b3-yes (param $i1 i32)
+ (func $b3-yes (type $0) (param $i1 i32)
(block $topmost
(block $inner
)
)
)
- (func $b4 (param $i1 i32)
+ (func $b4 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(i32.const 0)
)
)
)
- (func $b5 (param $i1 i32)
+ (func $b5 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(i32.const 0)
)
)
)
- (func $b6 (param $i1 i32)
+ (func $b6 (type $0) (param $i1 i32)
(block $topmost
(br_if $topmost
(i32.const 1)
)
)
)
- (func $b7 (param $i1 i32)
+ (func $b7 (type $0) (param $i1 i32)
(block $topmost
(br_if $topmost
(i32.const 0)
@@ -50,7 +53,7 @@
)
)
)
- (func $b8 (param $i1 i32)
+ (func $b8 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(br_if $topmost
@@ -59,7 +62,7 @@
)
)
)
- (func $b9 (param $i1 i32)
+ (func $b9 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(br_if $topmost
@@ -68,7 +71,7 @@
)
)
)
- (func $b10 (param $i1 i32)
+ (func $b10 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(br_if $topmost
@@ -78,7 +81,7 @@
)
)
)
- (func $b11 (param $i1 i32)
+ (func $b11 (type $0) (param $i1 i32)
(block $topmost
(block $inner
(br_if $inner
@@ -88,7 +91,7 @@
)
)
)
- (func $b12-yes
+ (func $b12-yes (type $1)
(block $topmost
(select
(block $block1
@@ -103,7 +106,7 @@
)
)
)
- (func $b13 (result i32)
+ (func $b13 (type $2) (result i32)
(block $topmost
(if
(i32.const 1)
@@ -124,7 +127,7 @@
(i32.const 3)
)
)
- (func $b14 (result i32)
+ (func $b14 (type $2) (result i32)
(block $topmost
(select
(block $block1
@@ -137,14 +140,14 @@
)
)
)
- (func $b15
+ (func $b15 (type $1)
(block $topmost
(br_if $topmost
(i32.const 17)
)
)
)
- (func $b15
+ (func $b15 (type $1)
(block $topmost
(br_if $topmost
(i32.const 0)
@@ -152,7 +155,7 @@
)
)
)
- (func $b16
+ (func $b16 (type $1)
(block $a
(block $b
(block $c
@@ -172,7 +175,7 @@
)
)
)
- (func $b17
+ (func $b17 (type $1)
(block $a
(select
(block $block1
@@ -210,16 +213,16 @@
)
)
)
- (func $ret-1
+ (func $ret-1 (type $1)
(nop)
)
- (func $ret-2
+ (func $ret-2 (type $1)
(block $block0
(block $block1
)
)
)
- (func $ret-3
+ (func $ret-3 (type $1)
(block $block0
(select
(nop)
@@ -229,14 +232,14 @@
)
)
)
- (func $ret-value (result i32)
+ (func $ret-value (type $2) (result i32)
(block $block0
(block $block1
(i32.const 1)
)
)
)
- (func $no-select-but-the-last
+ (func $no-select-but-the-last (type $1)
(block $a
(if
(i32.const 0)
@@ -281,7 +284,7 @@
)
)
)
- (func $side-effects-and-order (result i32)
+ (func $side-effects-and-order (type $2) (result i32)
(local $x i32)
(block $do-once$0
(br_if $do-once$0
diff --git a/test/passes/remove-unused-functions.txt b/test/passes/remove-unused-functions.txt
index 171997e14..b6f7cf3e1 100644
--- a/test/passes/remove-unused-functions.txt
+++ b/test/passes/remove-unused-functions.txt
@@ -1,31 +1,32 @@
(module
(memory 0)
(start $start)
+ (type $0 (func))
(export "exported" $exported)
(table $called_indirect)
- (func $start
+ (func $start (type $0)
(call $called0)
)
- (func $called0
+ (func $called0 (type $0)
(call $called1)
)
- (func $called1
+ (func $called1 (type $0)
(nop)
)
- (func $called_indirect
+ (func $called_indirect (type $0)
(nop)
)
- (func $exported
+ (func $exported (type $0)
(call $called2)
)
- (func $called2
+ (func $called2 (type $0)
(call $called2)
(call $called3)
)
- (func $called3
+ (func $called3 (type $0)
(call $called4)
)
- (func $called4
+ (func $called4 (type $0)
(call $called3)
)
)
diff --git a/test/passes/remove-unused-names.txt b/test/passes/remove-unused-names.txt
index 74cde2f1a..b36ebb622 100644
--- a/test/passes/remove-unused-names.txt
+++ b/test/passes/remove-unused-names.txt
@@ -1,9 +1,11 @@
(module
(memory 256 256)
- (func $b0 (param $i1 i32) (result i32)
+ (type $0 (func (param i32) (result i32)))
+ (type $1 (func))
+ (func $b0 (type $0) (param $i1 i32) (result i32)
(i32.const 0)
)
- (func $loops
+ (func $loops (type $1)
(loop $out $in
(br $out)
(br $in)
@@ -42,7 +44,7 @@
(br $in)
)
)
- (func $merges
+ (func $merges (type $1)
(block $b
(br $b)
(br $b)
diff --git a/test/passes/remove-unused-names_merge-blocks.txt b/test/passes/remove-unused-names_merge-blocks.txt
index a0ed7ea32..fe5bd5cf8 100644
--- a/test/passes/remove-unused-names_merge-blocks.txt
+++ b/test/passes/remove-unused-names_merge-blocks.txt
@@ -3,20 +3,21 @@
(type $i (func (param i32)))
(type $ii (func (param i32 i32)))
(type $iii (func (param i32 i32 i32)))
+ (type $3 (func))
(table $call-i)
- (func $call-i (param $0 i32)
+ (func $call-i (type $i) (param $0 i32)
(nop)
)
- (func $call-ii (param $0 i32) (param $1 i32)
+ (func $call-ii (type $ii) (param $0 i32) (param $1 i32)
(nop)
)
- (func $call-iii (param $0 i32) (param $1 i32) (param $2 i32)
+ (func $call-iii (type $iii) (param $0 i32) (param $1 i32) (param $2 i32)
(nop)
)
- (func $b0-yes (param $i1 i32)
+ (func $b0-yes (type $i) (param $i1 i32)
(i32.const 10)
)
- (func $b0-no (param $i1 i32)
+ (func $b0-no (type $i) (param $i1 i32)
(block $topmost
(block $block0
(br $block0)
@@ -24,33 +25,33 @@
(br $topmost)
)
)
- (func $b0-br-but-ok (param $i1 i32)
+ (func $b0-br-but-ok (type $i) (param $i1 i32)
(block $topmost
(br $topmost)
)
)
- (func $b1-yes (param $i1 i32)
+ (func $b1-yes (type $i) (param $i1 i32)
(i32.const 10)
)
- (func $b2-yes (param $i1 i32)
+ (func $b2-yes (type $i) (param $i1 i32)
(i32.const 5)
(i32.const 10)
(i32.const 15)
)
- (func $b3-yes (param $i1 i32)
+ (func $b3-yes (type $i) (param $i1 i32)
(i32.const 3)
(i32.const 6)
(i32.const 10)
(i32.const 15)
(i32.const 20)
)
- (func $b4 (param $i1 i32)
+ (func $b4 (type $i) (param $i1 i32)
(block $inner
(i32.const 10)
(br $inner)
)
)
- (func $b5 (param $i1 i32)
+ (func $b5 (type $i) (param $i1 i32)
(block $middle
(block $inner
(i32.const 10)
@@ -59,7 +60,7 @@
(br $middle)
)
)
- (func $b6 (param $i1 i32)
+ (func $b6 (type $i) (param $i1 i32)
(i32.const 5)
(block $inner
(i32.const 10)
@@ -67,7 +68,7 @@
)
(i32.const 15)
)
- (func $b7 (param $i1 i32)
+ (func $b7 (type $i) (param $i1 i32)
(i32.const 3)
(block $middle
(i32.const 6)
@@ -80,7 +81,7 @@
)
(i32.const 20)
)
- (func $unary
+ (func $unary (type $3)
(local $x i32)
(i32.eqz
(block
@@ -109,7 +110,7 @@
(unreachable)
)
)
- (func $binary
+ (func $binary (type $3)
(i32.add
(block
(i32.const 10)
@@ -190,7 +191,7 @@
(i32.const 30)
)
)
- (func $trinary
+ (func $trinary (type $3)
(i32.const 10)
(i32.const 30)
(i32.const 50)
@@ -311,7 +312,7 @@
(unreachable)
)
)
- (func $breaks
+ (func $breaks (type $3)
(block $out
(i32.const 10)
(br $out
@@ -339,7 +340,7 @@
)
)
)
- (func $calls
+ (func $calls (type $3)
(call $call-i
(block
(i32.const 10)
@@ -421,7 +422,7 @@
)
)
)
- (func $block-type-change
+ (func $block-type-change (type $3)
(local $0 f64)
(local $1 f64)
(if
diff --git a/test/passes/reorder-functions.txt b/test/passes/reorder-functions.txt
index b9c0f1154..d7b59a591 100644
--- a/test/passes/reorder-functions.txt
+++ b/test/passes/reorder-functions.txt
@@ -1,15 +1,16 @@
(module
(memory 256 256)
- (func $c
+ (type $0 (func))
+ (func $c (type $0)
(call $c)
(call $c)
(call $c)
)
- (func $b
+ (func $b (type $0)
(call $b)
(call $b)
)
- (func $a
+ (func $a (type $0)
(call $a)
)
)
diff --git a/test/passes/reorder-locals.txt b/test/passes/reorder-locals.txt
index db7d75f15..7ecb7c4a4 100644
--- a/test/passes/reorder-locals.txt
+++ b/test/passes/reorder-locals.txt
@@ -1,6 +1,8 @@
(module
(memory 256 256)
- (func $b0-yes (param $a i32) (param $b i32)
+ (type $0 (func (param i32 i32)))
+ (type $1 (func))
+ (func $b0-yes (type $0) (param $a i32) (param $b i32)
(local $z i32)
(local $y i32)
(local $x i32)
@@ -41,11 +43,11 @@
(get_local $b)
)
)
- (func $zero
+ (func $zero (type $1)
(local $b i32)
(get_local $b)
)
- (func $null
+ (func $null (type $1)
(nop)
)
)
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
index 2310366de..0ca96893f 100644
--- a/test/passes/simplify-locals.txt
+++ b/test/passes/simplify-locals.txt
@@ -4,11 +4,14 @@
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $FUNCSIG$iiiiii (func (param i32 i32 i32 i32 i32) (result i32)))
+ (type $4 (func (param i32)))
+ (type $5 (func (param i32) (result i32)))
+ (type $6 (func (param i32 i32 i32 i32 i32 i32)))
(import $waka "env" "waka")
(import $waka_int "env" "waka_int" (result i32))
(import $_i64Subtract "env" "i64sub" (param i32 i32 i32 i32) (result i32))
(import $___udivmoddi4 "env" "moddi" (param i32 i32 i32 i32 i32) (result i32))
- (func $b0-yes (param $i1 i32)
+ (func $b0-yes (type $4) (param $i1 i32)
(local $x i32)
(local $y i32)
(local $a i32)
@@ -206,7 +209,7 @@
(get_local $a)
)
)
- (func $Ia (param $a i32) (result i32)
+ (func $Ia (type $5) (param $a i32) (result i32)
(local $b i32)
(block $switch$0
(block $switch-default$6
@@ -217,7 +220,7 @@
(i32.const 60)
)
)
- (func $memories (param $i2 i32) (param $i3 i32) (param $bi2 i32) (param $bi3 i32) (param $ci3 i32) (param $di3 i32)
+ (func $memories (type $6) (param $i2 i32) (param $i3 i32) (param $bi2 i32) (param $bi3 i32) (param $ci3 i32) (param $di3 i32)
(local $set_with_no_get i32)
(nop)
(i32.store8
@@ -247,7 +250,7 @@
)
(i32.const 456)
)
- (func $___remdi3 (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (result i32)
+ (func $___remdi3 (type $FUNCSIG$iiiii) (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (result i32)
(local $$1$1 i32)
(local $$1$0 i32)
(local $$rem i32)
@@ -438,7 +441,7 @@
)
)
)
- (func $block-returns
+ (func $block-returns (type $FUNCSIG$v)
(local $x i32)
(set_local $x
(block $out
@@ -494,7 +497,7 @@
)
)
)
- (func $multiple (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32)
+ (func $multiple (type $6) (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32)
(nop)
(set_local $r
(i32.add
@@ -517,7 +520,7 @@
(get_local $m)
(get_local $t)
)
- (func $switch-def (param $i3 i32) (result i32)
+ (func $switch-def (type $5) (param $i3 i32) (result i32)
(local $i1 i32)
(set_local $i1
(i32.const 10)
diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt
index 2fd45cbc0..7fa247bdd 100644
--- a/test/passes/vacuum.txt
+++ b/test/passes/vacuum.txt
@@ -1,9 +1,14 @@
(module
(memory 256 256)
- (func $b
+ (type $0 (func))
+ (type $1 (func (param i32)))
+ (type $2 (func (result f32)))
+ (type $3 (func (result i32)))
+ (type $4 (func (param i32 f64 i32 i32)))
+ (func $b (type $0)
(nop)
)
- (func $l
+ (func $l (type $0)
(local $x i32)
(local $y i32)
(set_local $x
@@ -24,16 +29,16 @@
)
)
)
- (func $loopy (param $0 i32)
+ (func $loopy (type $1) (param $0 i32)
(nop)
)
- (func $unary (result f32)
+ (func $unary (type $2) (result f32)
(unreachable)
(f32.abs
(f32.const 2)
)
)
- (func $binary (result f32)
+ (func $binary (type $2) (result f32)
(unreachable)
(unreachable)
(f32.add
@@ -45,7 +50,7 @@
(f32.const 6)
)
)
- (func $select (result i32)
+ (func $select (type $3) (result i32)
(unreachable)
(unreachable)
(unreachable)
@@ -75,7 +80,7 @@
(i32.const 15)
)
)
- (func $block-to-one
+ (func $block-to-one (type $0)
(block $block0
)
(block $block1
@@ -91,13 +96,13 @@
(unreachable)
)
)
- (func $recurse
+ (func $recurse (type $0)
(nop)
)
- (func $func-block
+ (func $func-block (type $0)
(nop)
)
- (func $Gu (param $b i32) (param $e f64) (param $l i32) (param $d i32)
+ (func $Gu (type $4) (param $b i32) (param $e f64) (param $l i32) (param $d i32)
(if
(if
(get_local $d)
diff --git a/test/reg_switch.wast b/test/reg_switch.wast
index 60a294af0..ef2142d2a 100644
--- a/test/reg_switch.wast
+++ b/test/reg_switch.wast
@@ -1,6 +1,7 @@
(module
(memory 0)
- (func $0
+ (type $0 (func))
+ (func $0 (type $0)
(if
(i32.const 0)
(block $A
diff --git a/test/spec b/test/spec
-Subproject 88274ef4376b5a679a2cd0a1d630bf7e71f96cf
+Subproject 9af9a32b3b9335b9dfb4a6a6ba24bc3858815de
diff --git a/test/unit.wast b/test/unit.wast
index 46c40fa04..301ba719c 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -6,12 +6,16 @@
(type $FUNCSIG$v (func))
(type $FUNCSIG$id (func (param f64) (result i32)))
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
+ (type $4 (func (result f64)))
+ (type $5 (func (result i32)))
+ (type $6 (func (param i32) (result i32)))
+ (type $7 (func (param f64) (result f64)))
(import $_emscripten_asm_const_vi "env" "_emscripten_asm_const_vi")
(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)
- (func $big_negative
+ (func $big_negative (type $FUNCSIG$v)
(local $temp f64)
(block $block0
(set_local $temp
@@ -31,7 +35,7 @@
)
)
)
- (func $importedDoubles (result f64)
+ (func $importedDoubles (type $4) (result f64)
(local $temp f64)
(block $topmost
(set_local $temp
@@ -83,7 +87,7 @@
(f64.const 1.2)
)
)
- (func $doubleCompares (param $x f64) (param $y f64) (result f64)
+ (func $doubleCompares (type $FUNCSIG$ddd) (param $x f64) (param $y f64) (result f64)
(local $t f64)
(local $Int f64)
(local $Double i32)
@@ -127,14 +131,14 @@
(get_local $y)
)
)
- (func $intOps (result i32)
+ (func $intOps (type $5) (result i32)
(local $x i32)
(i32.eq
(get_local $x)
(i32.const 0)
)
)
- (func $hexLiterals
+ (func $hexLiterals (type $FUNCSIG$v)
(i32.add
(i32.add
(i32.const 0)
@@ -143,7 +147,7 @@
(i32.const -19088752)
)
)
- (func $conversions
+ (func $conversions (type $FUNCSIG$v)
(local $i i32)
(local $d f64)
(block $block0
@@ -167,7 +171,7 @@
)
)
)
- (func $seq
+ (func $seq (type $FUNCSIG$v)
(local $J f64)
(set_local $J
(f64.sub
@@ -182,7 +186,7 @@
)
)
)
- (func $switcher (param $x i32) (result i32)
+ (func $switcher (type $6) (param $x i32) (result i32)
(block $topmost
(block $switch$0
(block $switch-default$3
@@ -268,18 +272,18 @@
(i32.const 0)
)
)
- (func $blocker
+ (func $blocker (type $FUNCSIG$v)
(block $label$break$L
(br $label$break$L)
)
)
- (func $frem (result f64)
+ (func $frem (type $4) (result f64)
(call_import $f64-rem
(f64.const 5.5)
(f64.const 1.2)
)
)
- (func $big_uint_div_u (result i32)
+ (func $big_uint_div_u (type $5) (result i32)
(local $x i32)
(block $topmost
(set_local $x
@@ -294,7 +298,7 @@
(get_local $x)
)
)
- (func $fr (param $x f32)
+ (func $fr (type $FUNCSIG$vf) (param $x f32)
(local $y f32)
(local $z f64)
(block $block0
@@ -308,10 +312,10 @@
(f32.const 0)
)
)
- (func $negZero (result f64)
+ (func $negZero (type $4) (result f64)
(f64.const -0)
)
- (func $abs
+ (func $abs (type $FUNCSIG$v)
(local $x i32)
(local $y f64)
(local $z f32)
@@ -347,7 +351,7 @@
)
)
)
- (func $neg
+ (func $neg (type $FUNCSIG$v)
(local $x f32)
(block $block0
(set_local $x
@@ -367,7 +371,7 @@
)
)
)
- (func $cneg (param $x f32)
+ (func $cneg (type $FUNCSIG$vf) (param $x f32)
(call_indirect $FUNCSIG$vf
(i32.add
(i32.and
@@ -379,7 +383,7 @@
(get_local $x)
)
)
- (func $___syscall_ret
+ (func $___syscall_ret (type $FUNCSIG$v)
(local $$0 i32)
(i32.gt_u
(i32.shr_u
@@ -389,20 +393,20 @@
(i32.const -4096)
)
)
- (func $z
+ (func $z (type $FUNCSIG$v)
(nop)
)
- (func $w
+ (func $w (type $FUNCSIG$v)
(nop)
)
- (func $block_and_after (result i32)
+ (func $block_and_after (type $5) (result i32)
(block $waka
(i32.const 1)
(br $waka)
)
(i32.const 0)
)
- (func $loop-roundtrip (param $0 f64) (result f64)
+ (func $loop-roundtrip (type $7) (param $0 f64) (result f64)
(loop $loop-out0 $loop-in1
(get_local $0)
(get_local $0)