summaryrefslogtreecommitdiff
path: root/test/metadce
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-08-24 12:11:55 -0500
committerGitHub <noreply@github.com>2023-08-24 10:11:55 -0700
commit73bbbab144c4543edb70d35160cd620d3fe94539 (patch)
tree47c40a9722f73c1be24ef5a963281aca371074ca /test/metadce
parentda8937a71e908fecfc5722594dadd3c7ec6e80be (diff)
downloadbinaryen-73bbbab144c4543edb70d35160cd620d3fe94539.tar.gz
binaryen-73bbbab144c4543edb70d35160cd620d3fe94539.tar.bz2
binaryen-73bbbab144c4543edb70d35160cd620d3fe94539.zip
Simplify and consolidate type printing (#5816)
When printing Binaryen IR, we previously generated names for unnamed heap types based on their structure. This was useful for seeing the structure of simple types at a glance without having to separately go look up their definitions, but it also had two problems: 1. The same name could be generated for multiple types. The generated names did not take into account rec group structure or finality, so types that differed only in these properties would have the same name. Also, generated type names were limited in length, so very large types that shared only some structure could also end up with the same names. Using the same name for multiple types produces incorrect and unparsable output. 2. The generated names were not useful beyond the most trivial examples. Even with length limits, names for nontrivial types were extremely long and visually noisy, which made reading disassembled real-world code more challenging. Fix these problems by emitting simple indexed names for unnamed heap types instead. This regresses readability for very simple examples, but the trade off is worth it. This change also reduces the number of type printing systems we have by one. Previously we had the system in Print.cpp, but we had another, more general and extensible system in wasm-type-printing.h and wasm-type.cpp as well. Remove the old type printing system from Print.cpp and replace it with a much smaller use of the new system. This requires significant refactoring of Print.cpp so that PrintExpressionContents object now holds a reference to a parent PrintSExpression object that holds the type name state. This diff is very large because almost every test output changed slightly. To minimize the diff and ease review, change the type printer in wasm-type.cpp to behave the same as the old type printer in Print.cpp except for the differences in name generation. These changes will be reverted in much smaller PRs in the future to generally improve how types are printed.
Diffstat (limited to 'test/metadce')
-rw-r--r--test/metadce/corners.wast.dced8
-rw-r--r--test/metadce/outside.wast.dced8
-rw-r--r--test/metadce/ref-func.wast.dced10
-rw-r--r--test/metadce/rooted-export.wast.dced6
-rw-r--r--test/metadce/segments.wast.dced6
-rw-r--r--test/metadce/spanning_cycle.wast.dced6
-rw-r--r--test/metadce/tag.wast.dced4
-rw-r--r--test/metadce/threaded.wast.dced16
-rw-r--r--test/metadce/threaded_cycle.wast.dced18
9 files changed, 41 insertions, 41 deletions
diff --git a/test/metadce/corners.wast.dced b/test/metadce/corners.wast.dced
index c6d5d7e74..14b57d2cc 100644
--- a/test/metadce/corners.wast.dced
+++ b/test/metadce/corners.wast.dced
@@ -1,13 +1,13 @@
(module
- (type $none_=>_none (func))
+ (type $0 (func))
(import "env" "table" (table $timport$0 10 10 funcref))
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
- (import "env" "imported_twice" (func $imported_twice_a (type $none_=>_none)))
- (import "env" "an-imported-table-func" (func $imported_table_func (type $none_=>_none)))
+ (import "env" "imported_twice" (func $imported_twice_a (type $0)))
+ (import "env" "an-imported-table-func" (func $imported_table_func (type $0)))
(global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import))
(elem $0 (i32.const 0) $imported_table_func)
(export "stackAlloc" (func $stackAlloc))
- (func $stackAlloc (type $none_=>_none)
+ (func $stackAlloc (type $0)
(drop
(global.get $STACKTOP)
)
diff --git a/test/metadce/outside.wast.dced b/test/metadce/outside.wast.dced
index f35124e27..6cc8b71d6 100644
--- a/test/metadce/outside.wast.dced
+++ b/test/metadce/outside.wast.dced
@@ -1,19 +1,19 @@
(module
- (type $none_=>_none (func))
+ (type $0 (func))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table $timport$0 10 10 funcref))
(import "env" "g1" (global $from_segment i32))
(import "env" "g2" (global $from_segment_2 i32))
- (import "env" "js_func" (func $a_js_func (type $none_=>_none)))
+ (import "env" "js_func" (func $a_js_func (type $0)))
(global $__THREW__ (mut i32) (i32.const 0))
(data $0 (i32.const 1024) "abcd")
(data $1 (global.get $from_segment) "abcd")
(elem $0 (global.get $from_segment_2) $table_func)
(export "wasm_func" (func $a_wasm_func))
- (func $table_func (type $none_=>_none)
+ (func $table_func (type $0)
(nop)
)
- (func $a_wasm_func (type $none_=>_none)
+ (func $a_wasm_func (type $0)
(call $a_js_func)
(drop
(global.get $__THREW__)
diff --git a/test/metadce/ref-func.wast.dced b/test/metadce/ref-func.wast.dced
index 3117c4978..4f3115a7e 100644
--- a/test/metadce/ref-func.wast.dced
+++ b/test/metadce/ref-func.wast.dced
@@ -1,13 +1,13 @@
(module
- (type $none_=>_none (func))
- (type $none_=>_funcref (func (result funcref)))
- (import "env" "f2" (func $f2 (type $none_=>_none)))
- (import "env" "f1" (func $f1 (type $none_=>_none)))
+ (type $0 (func))
+ (type $1 (func (result funcref)))
+ (import "env" "f2" (func $f2 (type $0)))
+ (import "env" "f1" (func $f1 (type $0)))
(global $g funcref (ref.func $f1))
(elem declare func $f2)
(export "g" (global $g))
(export "f" (func $f))
- (func $f (type $none_=>_funcref) (result funcref)
+ (func $f (type $1) (result funcref)
(ref.func $f2)
)
)
diff --git a/test/metadce/rooted-export.wast.dced b/test/metadce/rooted-export.wast.dced
index 62001de23..186746e56 100644
--- a/test/metadce/rooted-export.wast.dced
+++ b/test/metadce/rooted-export.wast.dced
@@ -1,10 +1,10 @@
(module
- (type $i32_=>_none (func (param i32)))
- (type $none_=>_none (func))
+ (type $0 (func (param i32)))
+ (type $1 (func))
(tag $b_wasm_tag (param i32))
(export "wasm_func_b" (func $b_wasm_func))
(export "wasm_tag_b" (tag $b_wasm_tag))
- (func $b_wasm_func (type $none_=>_none)
+ (func $b_wasm_func (type $1)
(unreachable)
)
)
diff --git a/test/metadce/segments.wast.dced b/test/metadce/segments.wast.dced
index 944614bc2..2989ad60a 100644
--- a/test/metadce/segments.wast.dced
+++ b/test/metadce/segments.wast.dced
@@ -1,5 +1,5 @@
(module
- (type $i32_=>_none (func (param i32)))
+ (type $0 (func (param i32)))
(import "env" "g1" (global $g1 i32))
(import "env" "g2" (global $g2 i32))
(memory $0 3)
@@ -7,8 +7,8 @@
(table $tbl 0 funcref)
(elem $0 (global.get $g1) $f)
(export "f" (func $f))
- (func $f (type $i32_=>_none) (param $0 i32)
- (call_indirect $tbl (type $i32_=>_none)
+ (func $f (type $0) (param $0 i32)
+ (call_indirect $tbl (type $0)
(local.get $0)
(i32.load8_u
(i32.const 0)
diff --git a/test/metadce/spanning_cycle.wast.dced b/test/metadce/spanning_cycle.wast.dced
index 5c8145a3a..2341de82e 100644
--- a/test/metadce/spanning_cycle.wast.dced
+++ b/test/metadce/spanning_cycle.wast.dced
@@ -1,10 +1,10 @@
(module
- (type $none_=>_none (func))
- (import "env" "js_func" (func $a_js_func (type $none_=>_none)))
+ (type $0 (func))
+ (import "env" "js_func" (func $a_js_func (type $0)))
(memory $0 1 1)
(data $0 "Hello, datacount section!")
(export "wasm_func_a" (func $a_wasm_func))
- (func $a_wasm_func (type $none_=>_none)
+ (func $a_wasm_func (type $0)
(memory.init $0
(i32.const 0)
(i32.const 0)
diff --git a/test/metadce/tag.wast.dced b/test/metadce/tag.wast.dced
index 704eee1e1..3a71a2eed 100644
--- a/test/metadce/tag.wast.dced
+++ b/test/metadce/tag.wast.dced
@@ -1,9 +1,9 @@
(module
- (type $none_=>_none (func))
+ (type $0 (func))
(import "env" "imported_tag" (tag $t0 (param)))
(tag $t1 (param))
(export "test" (func $test))
- (func $test (type $none_=>_none)
+ (func $test (type $0)
(try $try
(do
(throw $t0)
diff --git a/test/metadce/threaded.wast.dced b/test/metadce/threaded.wast.dced
index 3617f112e..0d5d2f98d 100644
--- a/test/metadce/threaded.wast.dced
+++ b/test/metadce/threaded.wast.dced
@@ -1,22 +1,22 @@
(module
- (type $none_=>_none (func))
- (import "env" "js_func4" (func $js_func_4 (type $none_=>_none)))
- (import "env" "js_func3" (func $js_func_3 (type $none_=>_none)))
- (import "env" "js_func2" (func $js_func_2 (type $none_=>_none)))
+ (type $0 (func))
+ (import "env" "js_func4" (func $js_func_4 (type $0)))
+ (import "env" "js_func3" (func $js_func_3 (type $0)))
+ (import "env" "js_func2" (func $js_func_2 (type $0)))
(export "wasm_func1" (func $wasm_func_1))
(export "wasm_func2" (func $wasm_func_2))
(export "wasm_func3" (func $wasm_func_3))
(export "wasm_func4" (func $wasm_func_4))
- (func $wasm_func_4 (type $none_=>_none)
+ (func $wasm_func_4 (type $0)
(nop)
)
- (func $wasm_func_3 (type $none_=>_none)
+ (func $wasm_func_3 (type $0)
(call $js_func_4)
)
- (func $wasm_func_2 (type $none_=>_none)
+ (func $wasm_func_2 (type $0)
(call $js_func_3)
)
- (func $wasm_func_1 (type $none_=>_none)
+ (func $wasm_func_1 (type $0)
(call $js_func_2)
)
)
diff --git a/test/metadce/threaded_cycle.wast.dced b/test/metadce/threaded_cycle.wast.dced
index 69071006a..302cb3faf 100644
--- a/test/metadce/threaded_cycle.wast.dced
+++ b/test/metadce/threaded_cycle.wast.dced
@@ -1,23 +1,23 @@
(module
- (type $none_=>_none (func))
- (import "env" "js_func4" (func $js_func_4 (type $none_=>_none)))
- (import "env" "js_func3" (func $js_func_3 (type $none_=>_none)))
- (import "env" "js_func2" (func $js_func_2 (type $none_=>_none)))
- (import "env" "js_func1" (func $js_func_1 (type $none_=>_none)))
+ (type $0 (func))
+ (import "env" "js_func4" (func $js_func_4 (type $0)))
+ (import "env" "js_func3" (func $js_func_3 (type $0)))
+ (import "env" "js_func2" (func $js_func_2 (type $0)))
+ (import "env" "js_func1" (func $js_func_1 (type $0)))
(export "wasm_func1" (func $wasm_func_1))
(export "wasm_func2" (func $wasm_func_2))
(export "wasm_func3" (func $wasm_func_3))
(export "wasm_func4" (func $wasm_func_4))
- (func $wasm_func_4 (type $none_=>_none)
+ (func $wasm_func_4 (type $0)
(call $js_func_1)
)
- (func $wasm_func_3 (type $none_=>_none)
+ (func $wasm_func_3 (type $0)
(call $js_func_4)
)
- (func $wasm_func_2 (type $none_=>_none)
+ (func $wasm_func_2 (type $0)
(call $js_func_3)
)
- (func $wasm_func_1 (type $none_=>_none)
+ (func $wasm_func_1 (type $0)
(call $js_func_2)
)
)