summaryrefslogtreecommitdiff
path: root/test/lit/passes/simplify-locals-strings.wast
diff options
context:
space:
mode:
authorJérôme Vouillon <jerome.vouillon@gmail.com>2023-05-12 23:43:09 +0200
committerGitHub <noreply@github.com>2023-05-12 14:43:09 -0700
commit71a151240241fd50c42d88fe0ba9800c03527387 (patch)
treede98957b6f5341c3b14147c0cf6e1753d38940fe /test/lit/passes/simplify-locals-strings.wast
parentd7b14a67ca4e9b111d5733239af88328cb779030 (diff)
downloadbinaryen-71a151240241fd50c42d88fe0ba9800c03527387.tar.gz
binaryen-71a151240241fd50c42d88fe0ba9800c03527387.tar.bz2
binaryen-71a151240241fd50c42d88fe0ba9800c03527387.zip
[Strings] Adopt new instruction binary encoding (#5714)
See WebAssembly/stringref#46. This format is already adopted by V8: https://chromium-review.googlesource.com/c/v8/v8/+/3892695. The text format is left unchanged (see #5607 for a discussion on the subject). I have also added support for string.encode_lossy_utf8 and string.encode_lossy_utf8 array (by allowing the replace policy for Binaryen's string.encode_wtf8 instruction).
Diffstat (limited to 'test/lit/passes/simplify-locals-strings.wast')
-rw-r--r--test/lit/passes/simplify-locals-strings.wast68
1 files changed, 64 insertions, 4 deletions
diff --git a/test/lit/passes/simplify-locals-strings.wast b/test/lit/passes/simplify-locals-strings.wast
index 176d6fbb8..646eee6bd 100644
--- a/test/lit/passes/simplify-locals-strings.wast
+++ b/test/lit/passes/simplify-locals-strings.wast
@@ -320,7 +320,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf16
+ ;; CHECK-NEXT: (string.encode_wtf8 replace
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (i32.const 30)
;; CHECK-NEXT: )
@@ -328,6 +328,20 @@
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $temp)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $temp
+ ;; CHECK-NEXT: (i32.load
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (string.encode_wtf16
+ ;; CHECK-NEXT: (local.get $ref)
+ ;; CHECK-NEXT: (i32.const 40)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $temp)
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $no-load-past-encode (param $ref stringref)
(local $temp i32)
@@ -366,7 +380,7 @@
)
)
(drop
- (string.encode_wtf16
+ (string.encode_wtf8 replace
(local.get $ref)
(i32.const 30)
)
@@ -374,6 +388,20 @@
(drop
(local.get $temp)
)
+ (local.set $temp
+ (i32.load
+ (i32.const 1)
+ )
+ )
+ (drop
+ (string.encode_wtf16
+ (local.get $ref)
+ (i32.const 40)
+ )
+ )
+ (drop
+ (local.get $temp)
+ )
)
;; CHECK: (func $no-load-past-encode-gc (type $stringref_ref|$array|_ref|$array16|_=>_none) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
@@ -417,10 +445,26 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (string.encode_wtf8_array replace
+ ;; CHECK-NEXT: (local.get $ref)
+ ;; CHECK-NEXT: (local.get $array)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $temp)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $temp
+ ;; CHECK-NEXT: (array.get_u $array
+ ;; CHECK-NEXT: (local.get $array)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.encode_wtf16_array
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (local.get $array16)
- ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: (i32.const 40)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
@@ -470,10 +514,26 @@
)
)
(drop
+ (string.encode_wtf8_array replace
+ (local.get $ref)
+ (local.get $array)
+ (i32.const 30)
+ )
+ )
+ (drop
+ (local.get $temp)
+ )
+ (local.set $temp
+ (array.get $array
+ (local.get $array)
+ (i32.const 0)
+ )
+ )
+ (drop
(string.encode_wtf16_array
(local.get $ref)
(local.get $array16)
- (i32.const 30)
+ (i32.const 40)
)
)
(drop