summaryrefslogtreecommitdiff
path: root/test/lit/exec
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-05-15 12:05:33 -0700
committerGitHub <noreply@github.com>2024-05-15 12:05:33 -0700
commitef4b57c2a491a2193435dccdc9305f6a79965715 (patch)
tree491562613897a0c467a456e05e8a92234509e02c /test/lit/exec
parent8a5dc1880d962a7c31a7a219720be343a0866e5c (diff)
downloadbinaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.tar.gz
binaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.tar.bz2
binaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.zip
[Strings] Remove stringview types and instructions (#6579)
The stringview types from the stringref proposal have three irregularities that break common invariants and require pervasive special casing to handle properly: they are supertypes of `none` but not subtypes of `any`, they cannot be the targets of casts, and they cannot be used to construct nullable references. At the same time, the stringref proposal has been superseded by the imported strings proposal, which does not have these irregularities. The cost of maintaing and improving our support for stringview types is no longer worth the benefit of supporting them. Simplify the code base by entirely removing the stringview types and related instructions that do not have analogues in the imported strings proposal and do not make sense in the absense of stringviews. Three remaining instructions, `stringview_wtf16.get_codeunit`, `stringview_wtf16.slice`, and `stringview_wtf16.length` take stringview operands in the stringref proposal but cannot be removed because they lower to operations from the imported strings proposal. These instructions are changed to take stringref operands in Binaryen IR, and to allow a graceful upgrade path for users of these instructions, the text and binary parsers still accept but ignore `string.as_wtf16`, which is the instruction used to convert stringrefs to stringviews. The binary writer emits code sequences that use scratch locals and `string.as_wtf16` to keep the output valid. Future PRs will further align binaryen with the imported strings proposal instead of the stringref proposal, for example by making `string` a subtype of `extern` instead of a subtype of `any` and by removing additional instructions that do not have analogues in the imported strings proposal.
Diffstat (limited to 'test/lit/exec')
-rw-r--r--test/lit/exec/strings.wast31
1 files changed, 4 insertions, 27 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast
index 0d5bb7dc4..ca77f9882 100644
--- a/test/lit/exec/strings.wast
+++ b/test/lit/exec/strings.wast
@@ -171,24 +171,11 @@
(func $get_codeunit (export "get_codeunit") (result i32)
;; Reads 'c' which is code 99.
(stringview_wtf16.get_codeunit
- (string.as_wtf16
- (string.const "abcdefg")
- )
+ (string.const "abcdefg")
(i32.const 2)
)
)
- ;; CHECK: [fuzz-exec] calling get_length
- ;; CHECK-NEXT: [fuzz-exec] note result: get_length => 7
- (func $get_length (export "get_length") (result i32)
- ;; This should return 7.
- (stringview_wtf16.length
- (string.as_wtf16
- (string.const "1234567")
- )
- )
- )
-
;; CHECK: [fuzz-exec] calling encode
;; CHECK-NEXT: [LoggingExternalInterface logging 3]
;; CHECK-NEXT: [LoggingExternalInterface logging 0]
@@ -280,9 +267,7 @@
(func $slice (export "slice") (result (ref string))
;; Slicing [3:6] here should definitely output "def".
(stringview_wtf16.slice
- (string.as_wtf16
- (string.const "abcdefgh")
- )
+ (string.const "abcdefgh")
(i32.const 3)
(i32.const 6)
)
@@ -293,9 +278,7 @@
(func $slice-big (export "slice-big") (result (ref string))
;; Slicing [3:huge unsigned value] leads to slicing til the end: "defgh".
(stringview_wtf16.slice
- (string.as_wtf16
- (string.const "abcdefgh")
- )
+ (string.const "abcdefgh")
(i32.const 3)
(i32.const -1)
)
@@ -400,9 +383,7 @@
(func $slice-unicode (export "slice-unicode") (result (ref string))
(stringview_wtf16.slice
;; abcd£fgh
- (string.as_wtf16
- (string.const "abcd\C2\A3fgh")
- )
+ (string.const "abcd\C2\A3fgh")
(i32.const 3)
(i32.const 6)
)
@@ -535,9 +516,6 @@
;; CHECK: [fuzz-exec] calling get_codeunit
;; CHECK-NEXT: [fuzz-exec] note result: get_codeunit => 99
-;; CHECK: [fuzz-exec] calling get_length
-;; CHECK-NEXT: [fuzz-exec] note result: get_length => 7
-
;; CHECK: [fuzz-exec] calling encode
;; CHECK-NEXT: [LoggingExternalInterface logging 3]
;; CHECK-NEXT: [LoggingExternalInterface logging 0]
@@ -629,7 +607,6 @@
;; CHECK-NEXT: [fuzz-exec] comparing eq.4
;; CHECK-NEXT: [fuzz-exec] comparing eq.5
;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit
-;; CHECK-NEXT: [fuzz-exec] comparing get_length
;; CHECK-NEXT: [fuzz-exec] comparing invalid_code_point
;; CHECK-NEXT: [fuzz-exec] comparing isolated_high_code_point
;; CHECK-NEXT: [fuzz-exec] comparing isolated_low_code_point