Skip to content

Commit 70ac213

Browse files
authored
Strings: Disable precomputing for now (#6412)
Our UTF implementation is still not fully stable it seems as we have reports of issues. Disable it for now.
1 parent f9dc569 commit 70ac213

3 files changed

Lines changed: 74 additions & 13 deletions

File tree

src/passes/Precompute.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,36 @@ class PrecomputingExpressionRunner
195195
}
196196
return Literal(canonical, curr->type.getHeapType());
197197
}
198+
199+
// Disable string operations pending investigation of the correctness of our
200+
// UTF implementation. FIXME
201+
Flow visitStringNew(StringNew* curr) { return Flow(NONCONSTANT_FLOW); }
202+
Flow visitStringConst(StringConst* curr) { return Flow(NONCONSTANT_FLOW); }
203+
Flow visitStringMeasure(StringMeasure* curr) {
204+
return Flow(NONCONSTANT_FLOW);
205+
}
206+
Flow visitStringConcat(StringConcat* curr) { return Flow(NONCONSTANT_FLOW); }
207+
Flow visitStringEncode(StringEncode* curr) { return Flow(NONCONSTANT_FLOW); }
208+
Flow visitStringEq(StringEq* curr) { return Flow(NONCONSTANT_FLOW); }
209+
Flow visitStringAs(StringAs* curr) { return Flow(NONCONSTANT_FLOW); }
210+
Flow visitStringWTF8Advance(StringWTF8Advance* curr) {
211+
return Flow(NONCONSTANT_FLOW);
212+
}
213+
Flow visitStringWTF16Get(StringWTF16Get* curr) {
214+
return Flow(NONCONSTANT_FLOW);
215+
}
216+
Flow visitStringIterNext(StringIterNext* curr) {
217+
return Flow(NONCONSTANT_FLOW);
218+
}
219+
Flow visitStringIterMove(StringIterMove* curr) {
220+
return Flow(NONCONSTANT_FLOW);
221+
}
222+
Flow visitStringSliceWTF(StringSliceWTF* curr) {
223+
return Flow(NONCONSTANT_FLOW);
224+
}
225+
Flow visitStringSliceIter(StringSliceIter* curr) {
226+
return Flow(NONCONSTANT_FLOW);
227+
}
198228
};
199229

200230
struct Precompute

test/lit/passes/precompute-gc.wast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,10 @@
10191019
;; CHECK-NEXT: (string.const "hello, world")
10201020
;; CHECK-NEXT: )
10211021
;; CHECK-NEXT: (call $strings
1022-
;; CHECK-NEXT: (string.const "hello, world")
1022+
;; CHECK-NEXT: (local.get $s)
10231023
;; CHECK-NEXT: )
10241024
;; CHECK-NEXT: (call $strings
1025-
;; CHECK-NEXT: (string.const "hello, world")
1025+
;; CHECK-NEXT: (local.get $s)
10261026
;; CHECK-NEXT: )
10271027
;; CHECK-NEXT: )
10281028
(func $strings (param $param (ref string))

test/lit/passes/precompute-strings.wast

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
(module
66
;; CHECK: (type $0 (func (result i32)))
77

8-
;; CHECK: (type $1 (func (result (ref string))))
9-
108
;; CHECK: (type $array16 (array (mut i16)))
119
(type $array16 (array (mut i16)))
1210

11+
;; CHECK: (type $2 (func (result (ref string))))
12+
1313
;; CHECK: (export "get_codepoint-bad" (func $get_codepoint-bad))
1414

1515
;; CHECK: (export "slice" (func $slice))
1616

1717
;; CHECK: (export "slice-bad" (func $slice-bad))
1818

1919
;; CHECK: (func $eq-no (type $0) (result i32)
20-
;; CHECK-NEXT: (i32.const 0)
20+
;; CHECK-NEXT: (string.eq
21+
;; CHECK-NEXT: (string.const "ab")
22+
;; CHECK-NEXT: (string.const "cdefg")
23+
;; CHECK-NEXT: )
2124
;; CHECK-NEXT: )
2225
(func $eq-no (result i32)
2326
(string.eq
@@ -27,7 +30,10 @@
2730
)
2831

2932
;; CHECK: (func $eq-yes (type $0) (result i32)
30-
;; CHECK-NEXT: (i32.const 1)
33+
;; CHECK-NEXT: (string.eq
34+
;; CHECK-NEXT: (string.const "ab")
35+
;; CHECK-NEXT: (string.const "ab")
36+
;; CHECK-NEXT: )
3137
;; CHECK-NEXT: )
3238
(func $eq-yes (result i32)
3339
(string.eq
@@ -37,7 +43,13 @@
3743
)
3844

3945
;; CHECK: (func $concat (type $0) (result i32)
40-
;; CHECK-NEXT: (i32.const 1)
46+
;; CHECK-NEXT: (string.eq
47+
;; CHECK-NEXT: (string.concat
48+
;; CHECK-NEXT: (string.const "a")
49+
;; CHECK-NEXT: (string.const "b")
50+
;; CHECK-NEXT: )
51+
;; CHECK-NEXT: (string.const "ab")
52+
;; CHECK-NEXT: )
4153
;; CHECK-NEXT: )
4254
(func $concat (result i32)
4355
(string.eq
@@ -63,7 +75,11 @@
6375
)
6476

6577
;; CHECK: (func $length (type $0) (result i32)
66-
;; CHECK-NEXT: (i32.const 7)
78+
;; CHECK-NEXT: (stringview_wtf16.length
79+
;; CHECK-NEXT: (string.as_wtf16
80+
;; CHECK-NEXT: (string.const "1234567")
81+
;; CHECK-NEXT: )
82+
;; CHECK-NEXT: )
6783
;; CHECK-NEXT: )
6884
(func $length (result i32)
6985
(stringview_wtf16.length
@@ -91,7 +107,12 @@
91107
)
92108

93109
;; CHECK: (func $get_codepoint (type $0) (result i32)
94-
;; CHECK-NEXT: (i32.const 95)
110+
;; CHECK-NEXT: (stringview_wtf16.get_codeunit
111+
;; CHECK-NEXT: (string.as_wtf16
112+
;; CHECK-NEXT: (string.const "$_\c2\a3_\e2\82\ac_\f0\90\8d\88")
113+
;; CHECK-NEXT: )
114+
;; CHECK-NEXT: (i32.const 1)
115+
;; CHECK-NEXT: )
95116
;; CHECK-NEXT: )
96117
(func $get_codepoint (result i32)
97118
;; This is computable because everything up to the requested index is ascii. Returns 95 ('_').
@@ -124,7 +145,13 @@
124145
)
125146

126147
;; CHECK: (func $encode (type $0) (result i32)
127-
;; CHECK-NEXT: (i32.const 2)
148+
;; CHECK-NEXT: (string.encode_wtf16_array
149+
;; CHECK-NEXT: (string.const "$_")
150+
;; CHECK-NEXT: (array.new_default $array16
151+
;; CHECK-NEXT: (i32.const 20)
152+
;; CHECK-NEXT: )
153+
;; CHECK-NEXT: (i32.const 0)
154+
;; CHECK-NEXT: )
128155
;; CHECK-NEXT: )
129156
(func $encode (result i32)
130157
(string.encode_wtf16_array
@@ -156,8 +183,12 @@
156183
)
157184
)
158185

159-
;; CHECK: (func $slice (type $1) (result (ref string))
160-
;; CHECK-NEXT: (string.const "def")
186+
;; CHECK: (func $slice (type $2) (result (ref string))
187+
;; CHECK-NEXT: (stringview_wtf16.slice
188+
;; CHECK-NEXT: (string.const "abcdefgh")
189+
;; CHECK-NEXT: (i32.const 3)
190+
;; CHECK-NEXT: (i32.const 6)
191+
;; CHECK-NEXT: )
161192
;; CHECK-NEXT: )
162193
(func $slice (export "slice") (result (ref string))
163194
;; Slicing [3:6] here should definitely output "def".
@@ -168,7 +199,7 @@
168199
)
169200
)
170201

171-
;; CHECK: (func $slice-bad (type $1) (result (ref string))
202+
;; CHECK: (func $slice-bad (type $2) (result (ref string))
172203
;; CHECK-NEXT: (stringview_wtf16.slice
173204
;; CHECK-NEXT: (string.const "abcd\c2\a3fgh")
174205
;; CHECK-NEXT: (i32.const 3)

0 commit comments

Comments
 (0)