Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/passes/Precompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,36 @@ class PrecomputingExpressionRunner
}
return Literal(canonical, curr->type.getHeapType());
}

// Disable string operations pending investigation of the correctness of our
// UTF implementation. FIXME
Flow visitStringNew(StringNew* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringConst(StringConst* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringMeasure(StringMeasure* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringConcat(StringConcat* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringEncode(StringEncode* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringEq(StringEq* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringAs(StringAs* curr) { return Flow(NONCONSTANT_FLOW); }
Flow visitStringWTF8Advance(StringWTF8Advance* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringWTF16Get(StringWTF16Get* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringIterNext(StringIterNext* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringIterMove(StringIterMove* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringSliceWTF(StringSliceWTF* curr) {
return Flow(NONCONSTANT_FLOW);
}
Flow visitStringSliceIter(StringSliceIter* curr) {
return Flow(NONCONSTANT_FLOW);
}
};

struct Precompute
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/precompute-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,10 @@
;; CHECK-NEXT: (string.const "hello, world")
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $strings
;; CHECK-NEXT: (string.const "hello, world")
;; CHECK-NEXT: (local.get $s)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $strings
;; CHECK-NEXT: (string.const "hello, world")
;; CHECK-NEXT: (local.get $s)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $strings (param $param (ref string))
Expand Down
53 changes: 42 additions & 11 deletions test/lit/passes/precompute-strings.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
(module
;; CHECK: (type $0 (func (result i32)))

;; CHECK: (type $1 (func (result (ref string))))

;; CHECK: (type $array16 (array (mut i16)))
(type $array16 (array (mut i16)))

;; CHECK: (type $2 (func (result (ref string))))

;; CHECK: (export "get_codepoint-bad" (func $get_codepoint-bad))

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

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

;; CHECK: (func $eq-no (type $0) (result i32)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (string.eq
;; CHECK-NEXT: (string.const "ab")
;; CHECK-NEXT: (string.const "cdefg")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $eq-no (result i32)
(string.eq
Expand All @@ -27,7 +30,10 @@
)

;; CHECK: (func $eq-yes (type $0) (result i32)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: (string.eq
;; CHECK-NEXT: (string.const "ab")
;; CHECK-NEXT: (string.const "ab")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $eq-yes (result i32)
(string.eq
Expand All @@ -37,7 +43,13 @@
)

;; CHECK: (func $concat (type $0) (result i32)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: (string.eq
;; CHECK-NEXT: (string.concat
;; CHECK-NEXT: (string.const "a")
;; CHECK-NEXT: (string.const "b")
;; CHECK-NEXT: )
;; CHECK-NEXT: (string.const "ab")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $concat (result i32)
(string.eq
Expand All @@ -63,7 +75,11 @@
)

;; CHECK: (func $length (type $0) (result i32)
;; CHECK-NEXT: (i32.const 7)
;; CHECK-NEXT: (stringview_wtf16.length
;; CHECK-NEXT: (string.as_wtf16
;; CHECK-NEXT: (string.const "1234567")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $length (result i32)
(stringview_wtf16.length
Expand Down Expand Up @@ -91,7 +107,12 @@
)

;; CHECK: (func $get_codepoint (type $0) (result i32)
;; CHECK-NEXT: (i32.const 95)
;; CHECK-NEXT: (stringview_wtf16.get_codeunit
;; CHECK-NEXT: (string.as_wtf16
;; CHECK-NEXT: (string.const "$_\c2\a3_\e2\82\ac_\f0\90\8d\88")
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $get_codepoint (result i32)
;; This is computable because everything up to the requested index is ascii. Returns 95 ('_').
Expand Down Expand Up @@ -124,7 +145,13 @@
)

;; CHECK: (func $encode (type $0) (result i32)
;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: (string.encode_wtf16_array
;; CHECK-NEXT: (string.const "$_")
;; CHECK-NEXT: (array.new_default $array16
;; CHECK-NEXT: (i32.const 20)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $encode (result i32)
(string.encode_wtf16_array
Expand Down Expand Up @@ -156,8 +183,12 @@
)
)

;; CHECK: (func $slice (type $1) (result (ref string))
;; CHECK-NEXT: (string.const "def")
;; CHECK: (func $slice (type $2) (result (ref string))
;; CHECK-NEXT: (stringview_wtf16.slice
;; CHECK-NEXT: (string.const "abcdefgh")
;; CHECK-NEXT: (i32.const 3)
;; CHECK-NEXT: (i32.const 6)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $slice (export "slice") (result (ref string))
;; Slicing [3:6] here should definitely output "def".
Expand All @@ -168,7 +199,7 @@
)
)

;; CHECK: (func $slice-bad (type $1) (result (ref string))
;; CHECK: (func $slice-bad (type $2) (result (ref string))
;; CHECK-NEXT: (stringview_wtf16.slice
;; CHECK-NEXT: (string.const "abcd\c2\a3fgh")
;; CHECK-NEXT: (i32.const 3)
Expand Down