Skip to content

[Strings] Add a string-builtins feature, and lift/lower automatically when enabled #7601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
p
  • Loading branch information
kripken committed May 15, 2025
commit b72d7535574ac42a61fbc1a4ca903e87fb1953ab
6 changes: 5 additions & 1 deletion scripts/test/fuzzing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
unfuzzable = [
# Float16 is still experimental.
'f16.wast',
# TODO: fuzzer and interpreter support for strings
# TODO: fuzzer and interpreter support for strings, including limitations
# like the fuzzer not handling (ref extern) imports (there is no way
# to create a replacement value)
'strings.wast',
'simplify-locals-strings.wast',
'string-lowering-instructions.wast',
'O2_strings.wast',
'O2_O3_strings.wast',
# TODO: fuzzer and interpreter support for extern conversions
'extern-conversions.wast',
# ignore DWARF because it is incompatible with multivalue atm
Expand Down
28 changes: 28 additions & 0 deletions test/lit/string-builtins.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.

;; Run normal -O2, which should lift, optimize, and lower strings, if the
;; string builtins feature is enabled. We optimize in the last two here.

;; RUN: foreach %s %t wasm-opt -O2 -S -o - | filecheck %s --check-prefix=MVP
;; RUN: foreach %s %t wasm-opt -O2 -all -S -o - | filecheck %s --check-prefix=ALL
;; RUN: foreach %s %t wasm-opt -O2 --enable-string-builtins -S -o - | filecheck %s --check-prefix=ESB

(module
(type $array16 (array (mut i16)))

(import "\'" "foo" (global $foo (ref extern)))

(import "\'" "bar" (global $bar (ref extern)))

(import "wasm:js-string" "concat" (func $concat (param externref externref) (result (ref extern))))

(func $string.concat (export "string.concat") (result (ref extern))
;; When we optimize, we concatenate "foo" and "bar" here to "foobar". A new
;; imported global will appear for that, and we will get it here.
(call $concat
(global.get $foo)
(global.get $bar)
)
)
)