Skip to content

Require specific array types for string ops #7810

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 6 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

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
address comments
  • Loading branch information
tlively committed Aug 9, 2025
commit 9ee9393b6accfb092b2b09214aba6d4bb0693d3b
4 changes: 2 additions & 2 deletions src/passes/Precompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ class PrecomputingExpressionRunner

Flow visitStringNew(StringNew* curr) {
if (curr->op != StringNewWTF16Array) {
// TOOD: handle other string ops. For now we focus on JS-like strings.
// TODO: handle other string ops. For now we focus on JS-like strings.
return Flow(NONCONSTANT_FLOW);
}

// string.encode_wtf16_array is effectively an Array read operation, so
// string.new_wtf16_array is effectively an Array read operation, so
// we cannot optimize mutable arrays. Unfortunately, it is only valid with
// mutable arrays, so we cannot generally precompute it. As a special
// exception, we can precompute if the child is an array allocation because
Expand Down
2 changes: 2 additions & 0 deletions test/lit/passes/precompute-strings.wast
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $string.new-mutable-indirect (result externref)
;; Now the allocation is not the immediate child, so we do not precompute.
;; TODO: be smarter and optimize this.
(string.new_wtf16_array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment comparing to the above.

(block (result (ref $array16))
(array.new_fixed $array16 4
Expand Down