diff options
author | Alon Zakai <azakai@google.com> | 2024-04-23 08:33:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-23 08:33:43 -0700 |
commit | 4bbae113dc144f80ff4880c74c7068a9f7b14295 (patch) | |
tree | 568b756da8f53a148b1691a063f5a7f9a8c56466 /test | |
parent | bceb02d545aeabb21797ef4148e0f713c57e0e0d (diff) | |
download | binaryen-4bbae113dc144f80ff4880c74c7068a9f7b14295.tar.gz binaryen-4bbae113dc144f80ff4880c74c7068a9f7b14295.tar.bz2 binaryen-4bbae113dc144f80ff4880c74c7068a9f7b14295.zip |
Precompute: Ignore mutable arrays in StringNew (#6522)
All Struct/Array operations must ignore mutable fields in Precompute atm, which we
did, but StringNew has an array variant that does an effective ArrayGet operation,
which we didn't handle.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/precompute-strings.wast | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/test/lit/passes/precompute-strings.wast b/test/lit/passes/precompute-strings.wast index 6046ee6b1..a9d065fdc 100644 --- a/test/lit/passes/precompute-strings.wast +++ b/test/lit/passes/precompute-strings.wast @@ -8,9 +8,13 @@ ;; CHECK: (type $array16 (array (mut i16))) (type $array16 (array (mut i16))) + (type $array16-imm (array i16)) + ;; CHECK: (type $2 (func (result (ref string)))) - ;; CHECK: (type $3 (func (result (ref any)))) + ;; CHECK: (type $3 (func (result anyref))) + + ;; CHECK: (type $4 (func (result (ref any)))) ;; CHECK: (export "get_codepoint-unicode" (func $get_codepoint-unicode)) @@ -169,7 +173,7 @@ ) ) - ;; CHECK: (func $encode-stashed (type $3) (result (ref any)) + ;; CHECK: (func $encode-stashed (type $4) (result (ref any)) ;; CHECK-NEXT: (local $1 (ref $array16)) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (array.new_default $array16 @@ -234,4 +238,48 @@ (i32.const 6) ) ) + + ;; CHECK: (func $string.new-mutable (type $3) (result anyref) + ;; CHECK-NEXT: (string.new_wtf16_array + ;; CHECK-NEXT: (array.new_fixed $array16 4 + ;; CHECK-NEXT: (i32.const 65) + ;; CHECK-NEXT: (i32.const 66) + ;; CHECK-NEXT: (i32.const 67) + ;; CHECK-NEXT: (i32.const 68) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string.new-mutable (result anyref) + ;; We do not precompute this because the array is mutable, and we do not yet + ;; do an analysis to see that it does not "escape" into places that modify it. + (string.new_wtf16_array + (array.new_fixed $array16 4 + (i32.const 65) + (i32.const 66) + (i32.const 67) + (i32.const 68) + ) + (i32.const 0) + (i32.const 4) + ) + ) + + ;; CHECK: (func $string.new-immutable (type $3) (result anyref) + ;; CHECK-NEXT: (string.const "ABCD") + ;; CHECK-NEXT: ) + (func $string.new-immutable (result anyref) + ;; This array is immutable and we can optimize here. + (string.new_wtf16_array + (array.new_fixed $array16-imm 4 + (i32.const 65) + (i32.const 66) + (i32.const 67) + (i32.const 68) + ) + (i32.const 0) + (i32.const 4) + ) + ) ) |