summaryrefslogtreecommitdiff
path: root/test/typed-function-references.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-07-07 12:46:43 -0700
committerGitHub <noreply@github.com>2022-07-07 12:46:43 -0700
commit9831b36d339b1cea61d5313f7dfa256fc1ee9bcc (patch)
tree70178cf4d01b7d5b9319be6fdd59c4d05cc2a0a1 /test/typed-function-references.wast
parenta82e2dbfc3a554377b93cc1f5fca731ff688f925 (diff)
downloadbinaryen-9831b36d339b1cea61d5313f7dfa256fc1ee9bcc.tar.gz
binaryen-9831b36d339b1cea61d5313f7dfa256fc1ee9bcc.tar.bz2
binaryen-9831b36d339b1cea61d5313f7dfa256fc1ee9bcc.zip
Group reference types in binary format. (#4774)
Grouping all references together makes it easier for baseline compilers to zero out memory (as the zeroing out may be different for MVP types vs. references). This puts all references together, either at the start or the end. As a heuristic for that we see if the first local is a reference. As the optimizer will sort locals by frequency, this ensures that the most-frequent local stays in index 0. Fixes #4773. See more details there
Diffstat (limited to 'test/typed-function-references.wast')
-rw-r--r--test/typed-function-references.wast41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/typed-function-references.wast b/test/typed-function-references.wast
index 1057d4487..40eae6ebd 100644
--- a/test/typed-function-references.wast
+++ b/test/typed-function-references.wast
@@ -41,4 +41,45 @@
)
)
)
+ (func $ref-types-first
+ ;; 6 reference types and 3 MVP types. The binary format should emit all the
+ ;; reference types first since a reference type appears first. In addition,
+ ;; types should be emitted in blocks there, that is, locals of identical
+ ;; types should be adjacent.
+ (local $r1 (ref null $mixed_results))
+ (local $r2 (ref null $mixed_results))
+ (local $i1 i32)
+ (local $r3 anyref)
+ (local $i2 i64)
+ (local $r4 anyref)
+ (local $i3 i64)
+ (local $r5 anyref)
+ (local $r6 funcref)
+ )
+ (func $mvp-types-first
+ ;; Reversed from before, now an MVP type appears first, so they should all
+ ;; be before reference types in the binary format.
+ (local $i1 i32) ;; only this local was moved up.
+ (local $r1 (ref null $mixed_results))
+ (local $r2 (ref null $mixed_results))
+ (local $r3 anyref)
+ (local $i2 i64)
+ (local $r4 anyref)
+ (local $i3 i64)
+ (local $r5 anyref)
+ (local $r6 funcref)
+ )
+ (func $mvp-types-first-param (param $r0 (ref null $mixed_results))
+ ;; As before, but now there is a reference type *parameter*. We should
+ ;; ignore that and sort as in the last function.
+ (local $i1 i32) ;; only this local was moved up.
+ (local $r1 (ref null $mixed_results))
+ (local $r2 (ref null $mixed_results))
+ (local $r3 anyref)
+ (local $i2 i64)
+ (local $r4 anyref)
+ (local $i3 i64)
+ (local $r5 anyref)
+ (local $r6 funcref)
+ )
)